Skip to content

Commit 901cb0f

Browse files
committed
Dashboard layout storybook
1 parent 79e8a25 commit 901cb0f

File tree

3 files changed

+40
-22
lines changed

3 files changed

+40
-22
lines changed

src/_common/AppHeader/AppHeader.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@ import HeaderSearch from './AppHeaderSearch'
1515
import HeaderNotifications from './AppHeaderNotifications'
1616
import HeaderProfile from './AppHeaderProfile'
1717

18-
/**
19-
* The `Avatar` component is where all your avatars come to play.
20-
*/
21-
const Header = ({ onToggle }) => {
18+
const AppHeader = ({ onToggle }) => {
2219
const classes = useStyles()
2320

2421
return (
25-
<AppBar position="absolute" className={classes.header}>
22+
<AppBar position="static" className={classes.header}>
2623
<Toolbar className={classes.toolbar}>
2724
<IconButton
2825
edge="start"
@@ -44,7 +41,7 @@ const Header = ({ onToggle }) => {
4441
)
4542
}
4643

47-
Header.propTypes = {
44+
AppHeader.propTypes = {
4845
onToggle: PropTypes.func,
4946
}
5047

@@ -69,4 +66,4 @@ const useStyles = makeStyles(theme => ({
6966
},
7067
}))
7168

72-
export default Header
69+
export default AppHeader

src/_layouts/DashboardLayout/DashboardLayout.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ const useStyles = makeStyles(theme => ({
197197
display: 'flex',
198198
},
199199
contentContainer: {
200+
display: 'flex',
200201
position: 'relative',
201202
flex: 1,
202203
},

src/_layouts/DashboardLayout/DashboardLayout.stories.mdx

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { Meta, Story, Preview, Props } from '@storybook/addon-docs/blocks'
22
import DashboardLayout from './DashboardLayout.js'
33

4+
import AppHeader from '../../_common/AppHeader'
5+
import AppSidebar from '../../_common/AppSidebar'
6+
import AppFooter from '../../_common/AppFooter'
7+
48
<Meta title="General/Components/DashboardLayout" component={DashboardLayout} />
59

610

711
# Dashboard Layout
812

913
Application dashboard layout.
1014

11-
export const Placeholder = ({ children }) => <div
15+
export const DemoPlaceholder = ({ children }) => <div
1216
style={{
1317
padding: 10,
1418
top: 10,
@@ -35,20 +39,20 @@ export const Placeholder = ({ children }) => <div
3539
</div>
3640
</div>
3741

38-
export const Header = () => <div
42+
export const DemoHeader = () => <div
3943
style={{
4044
width: '100%',
4145
background: 'rgb(152, 173, 153)',
4246
display: 'flex',
4347
flexDirection: 'column',
4448
}}
4549
>
46-
<Placeholder>
50+
<DemoPlaceholder>
4751
Header
48-
</Placeholder>
52+
</DemoPlaceholder>
4953
</div>
5054

51-
export const Sidebar = () => <div
55+
export const DemoSidebar = () => <div
5256
style={{
5357
position: 'absolute',
5458
width: '100%',
@@ -59,33 +63,49 @@ export const Sidebar = () => <div
5963
flexDirection: 'column',
6064
}}
6165
>
62-
<Placeholder>
66+
<DemoPlaceholder>
6367
Sidebar
64-
</Placeholder>
68+
</DemoPlaceholder>
6569
</div>
6670

67-
export const Footer = () => <div
71+
export const DemoFooter = () => <div
6872
style={{
6973
background: '#bfb8ab',
7074
display: 'flex',
7175
flexDirection: 'column',
7276
}}
7377
>
74-
<Placeholder>
78+
<DemoPlaceholder>
7579
Footer
76-
</Placeholder>
80+
</DemoPlaceholder>
7781
</div>
7882

7983
<Preview>
8084
<Story name="dashboard layout">
8185
<DashboardLayout
82-
header={Header}
83-
sidebar={Sidebar}
84-
footer={Footer}
86+
header={DemoHeader}
87+
sidebar={DemoSidebar}
88+
footer={DemoFooter}
89+
>
90+
<DemoPlaceholder>
91+
Content
92+
</DemoPlaceholder>
93+
</DashboardLayout>
94+
</Story>
95+
</Preview>
96+
97+
## With real header/footer/sidebar
98+
99+
<Preview>
100+
<Story name="with components">
101+
<DashboardLayout
102+
header={AppHeader}
103+
sidebar={AppSidebar}
104+
footer={AppFooter}
85105
>
86-
<Placeholder>
106+
<DemoPlaceholder>
87107
Content
88-
</Placeholder>
108+
</DemoPlaceholder>
89109
</DashboardLayout>
90110
</Story>
91111
</Preview>

0 commit comments

Comments
 (0)