From 056e20ad7544ddef208e87d5f249ca1a1803d66c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Souza=20Liedke?= Date: Fri, 25 Sep 2020 15:12:37 -0300 Subject: [PATCH] Refactored page title splitting and space insertion --- lib/ui/src/containers/preview.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/ui/src/containers/preview.tsx b/lib/ui/src/containers/preview.tsx index 6d692f0758d..48abeda7a4b 100644 --- a/lib/ui/src/containers/preview.tsx +++ b/lib/ui/src/containers/preview.tsx @@ -7,12 +7,7 @@ import { Preview } from '../components/preview/preview'; export type Item = StoriesHash[keyof StoriesHash]; -const nonAlphanumSpace = /[^a-z0-9 ]/gi; -const doubleSpace = /\s\s/gi; -const replacer = (match: string) => ` ${match} `; - -const addExtraWhiteSpace = (input: string) => - input.replace(nonAlphanumSpace, replacer).replace(doubleSpace, ' '); +const splitTitleAddExtraSpace = (input: string) => input.split('/').join(' / '); const getDescription = (item: Item) => { if (isRoot(item)) { @@ -23,7 +18,7 @@ const getDescription = (item: Item) => { } if (isStory(item)) { const { kind, name } = item; - return kind && name ? addExtraWhiteSpace(`${kind} - ${name} ⋅ Storybook`) : 'Storybook'; + return kind && name ? splitTitleAddExtraSpace(`${kind} - ${name} ⋅ Storybook`) : 'Storybook'; } return 'Storybook';