-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
/
sidebar.tsx
executable file
·51 lines (44 loc) · 1.17 KB
/
sidebar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { FunctionComponent } from 'react';
import type { Combo, StoriesHash } from '@storybook/api';
import { Consumer } from '@storybook/api';
import { Sidebar as SidebarComponent } from '../components/sidebar/Sidebar';
import { useMenu } from './menu';
export type Item = StoriesHash[keyof StoriesHash];
const Sidebar: FunctionComponent<{}> = React.memo(() => {
const mapper = ({ state, api }: Combo) => {
const {
ui: { name, url, enableShortcuts },
viewMode,
storyId,
refId,
layout: { isFullscreen, showPanel, showNav },
storiesHash,
storiesConfigured,
storiesFailed,
refs,
} = state;
const menu = useMenu(api, isFullscreen, showPanel, showNav, enableShortcuts);
return {
title: name,
url,
stories: storiesHash,
storiesFailed,
storiesConfigured,
refs,
storyId,
refId,
viewMode,
menu,
menuHighlighted: api.versionUpdateAvailable(),
enableShortcuts,
};
};
return (
<Consumer filter={mapper}>
{(fromState) => {
return <SidebarComponent {...fromState} />;
}}
</Consumer>
);
});
export default Sidebar;