From 2570bc14043804d8973c7019dec68132398b1f60 Mon Sep 17 00:00:00 2001 From: Valerie Rutsch Date: Wed, 16 Mar 2022 21:22:13 -0500 Subject: [PATCH] Revert --- lib/ui/src/components/sidebar/Sidebar.tsx | 146 +++++++++++----------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/lib/ui/src/components/sidebar/Sidebar.tsx b/lib/ui/src/components/sidebar/Sidebar.tsx index 7c6e5e52d52..554fef817b5 100644 --- a/lib/ui/src/components/sidebar/Sidebar.tsx +++ b/lib/ui/src/components/sidebar/Sidebar.tsx @@ -88,8 +88,8 @@ export interface SidebarProps { enableShortcuts?: boolean; } -export const Sidebar: FunctionComponent = React.memo((props) => { - const { +export const Sidebar: FunctionComponent = React.memo( + ({ storyId = null, refId = DEFAULT_REF_ID, stories: storiesHash, @@ -99,78 +99,78 @@ export const Sidebar: FunctionComponent = React.memo((props) => { menuHighlighted = false, enableShortcuts = true, refs = {}, - } = props; + }) => { + const collapseFn = DOCS_MODE ? collapseAllStories : collapseDocsOnlyStories; + const selected: Selection = useMemo(() => storyId && { storyId, refId }, [storyId, refId]); + const stories = useMemo(() => collapseFn(storiesHash), [DOCS_MODE, storiesHash]); - const collapseFn = DOCS_MODE ? collapseAllStories : collapseDocsOnlyStories; - const selected: Selection = useMemo(() => storyId && { storyId, refId }, [storyId, refId]); - const stories = useMemo(() => collapseFn(storiesHash), [DOCS_MODE, storiesHash]); + const adaptedRefs = useMemo(() => { + return Object.entries(refs).reduce((acc: Refs, [id, ref]: [string, ComposedRef]) => { + if (ref.stories) { + acc[id] = { + ...ref, + stories: collapseFn(ref.stories), + }; + } else { + acc[id] = ref; + } + return acc; + }, {}); + }, [DOCS_MODE, refs]); - const adaptedRefs = useMemo(() => { - return Object.entries(refs).reduce((acc: Refs, [id, ref]: [string, ComposedRef]) => { - if (ref.stories) { - acc[id] = { - ...ref, - stories: collapseFn(ref.stories), - }; - } else { - acc[id] = ref; - } - return acc; - }, {}); - }, [DOCS_MODE, refs]); + const dataset = useCombination(stories, storiesConfigured, storiesFailed, adaptedRefs); + const isLoading = !dataset.hash[DEFAULT_REF_ID].ready; + const lastViewedProps = useLastViewed(selected); - const dataset = useCombination(stories, storiesConfigured, storiesFailed, adaptedRefs); - const isLoading = !dataset.hash[DEFAULT_REF_ID].ready; - const lastViewedProps = useLastViewed(selected); + return ( + + + + - return ( - - - - - - - {({ - query, - results, - isBrowsing, - closeMenu, - getMenuProps, - getItemProps, - highlightedIndex, - }) => ( - - - - - )} - - - - - ); -}); + + {({ + query, + results, + isBrowsing, + closeMenu, + getMenuProps, + getItemProps, + highlightedIndex, + }) => ( + + + + + )} + + + + + ); + } +);