Skip to content
This repository was archived by the owner on Jun 29, 2021. It is now read-only.

Commit 5c65825

Browse files
Merge pull request #7 from commitd/je-improvements2
2 parents e485dc3 + 1eea26e commit 5c65825

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+11951
-4173
lines changed

.drone.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ steps:
2020
image: node:latest
2121
commands:
2222
- npm publish --access public
23+
- yarn deploy-storybook --ci
2324
when:
2425
ref:
2526
- refs/tags/v*

.storybook/main.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
stories: ['../stories/**/*.stories.(ts|tsx|mdx)'],
3+
addons: [
4+
'@storybook/addon-knobs/register',
5+
'@storybook/preset-typescript',
6+
{
7+
name: '@storybook/addon-docs',
8+
options: {
9+
configureJSX: true,
10+
},
11+
},
12+
'./.storybook/register.js',
13+
],
14+
}

.storybook/manager.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { addons } from '@storybook/addons'
2+
import committedTheme from './theme.js'
3+
4+
addons.setConfig({
5+
theme: committedTheme
6+
})

.storybook/preview.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
import { addParameters } from '@storybook/react'
3+
import committedTheme from './theme.js'
4+
5+
addParameters({
6+
options: {
7+
// Currently required here as well as in manager.js - should be able to remove in 6.0
8+
theme: committedTheme,
9+
},
10+
})

.storybook/register.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { STORIES_CONFIGURED, STORY_MISSING } from '@storybook/core-events'
2+
import { addons } from '@storybook/addons'
3+
4+
addons.register('committed/components', storybookAPI => {
5+
storybookAPI.on(STORIES_CONFIGURED, (kind, story) => {
6+
if (storybookAPI.getUrlState().path === '/story/*') {
7+
storybookAPI.selectStory('Layout')
8+
}
9+
})
10+
storybookAPI.on(STORY_MISSING, (kind, story) => {
11+
storybookAPI.selectStory('Layout')
12+
})
13+
})

.storybook/theme.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { create } from '@storybook/theming'
2+
3+
export default create({
4+
colorPrimary: '#ffbb00',
5+
colorSecondary: '#4098D7',
6+
7+
// Typography
8+
fontBase:
9+
'-apple-system, BlinkMacSystemFont, "San Francisco", Roboto, "Segoe UI", "Helvetica Neue"', // fonts.defaultFonts.typography.fontFamily,
10+
fontCode:
11+
'"SFMono-Regular", Consolas, "Liberation Mono", "Andale Mono", "Ubuntu Mono", Menlo, Courier, monospace', // fonts.defaultFonts.monospace.fontFamily,
12+
13+
brandTitle: 'Committed Layout',
14+
brandUrl: '/',
15+
})

README.md

Lines changed: 86 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Committed Badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fcommitted.software%2Fbadge)](https://committed.io)
44
[![Build Status](https://drone.committed.software/api/badges/commitd/layout/status.svg)](https://drone.committed.software/commitd/layout)
5+
[![Storybook](https://raw.githubusercontent.com/storybooks/brand/master/badge/badge-storybook.svg)](https://committed.software/layout)
56

67
This is a simple layout for standard looking material based apps, based on [Mui Layout](https://mui-treasury.com/components/layout)
78
but using `@committed/components` as its base.
@@ -12,7 +13,7 @@ but using `@committed/components` as its base.
1213

1314
## 🔗 Live Demo
1415

15-
Here's a [live demo](https://committed.software/docs)
16+
Here's a [live demo](https://committed.software/docs) using layout and the [storybook](https://committed.software/layout)
1617

1718
## 🚀 Quickstart
1819

@@ -34,28 +35,34 @@ yarn add @committed/components @material-ui/core @material-ui/icons react react-
3435
import React from 'react'
3536
import ReactDOM from 'react-dom'
3637
import { ThemeProvider } from '@committed/components'
37-
import { Root, Header, Nav, Content, Footer } from '/layout'
38+
import {
39+
Root,
40+
Header,
41+
Nav,
42+
NavListItem,
43+
Content,
44+
Footer,
45+
LayoutConfig,
46+
} from '@committed/layout'
47+
48+
const config: Partial<LayoutConfig> = {
49+
// Only permanently show nav drawer at higher resolutions
50+
navVariant: {
51+
sm: 'temporary',
52+
lg: 'permanent',
53+
},
54+
}
3855

3956
const App = () => (
40-
<ThemeProvider>
41-
<Root
42-
style={{ minHeight: '100vh' }}
43-
config={
44-
{
45-
// adjust behavior here!
46-
// See LayoutConfig
47-
}
48-
}
49-
>
50-
<Header>Header</Header>
51-
<Nav
52-
header={
53-
// you can provide fixed header inside nav
54-
// change null to some react element
55-
ctx => null
56-
}
57-
>
58-
Nav
57+
<ThemeProvider theme={theme}>
58+
<Root config={config}>
59+
<Header>
60+
<Typography variant="h5">Application Name</Typography>
61+
</Header>
62+
<Nav header={(ctx) => null}>
63+
<List>
64+
<NavListItem text="Menu Item 1" icon={<AccountCircle />} />
65+
</List>
5966
</Nav>
6067
<Content>Content</Content>
6168
<Footer>Footer</Footer>
@@ -66,6 +73,8 @@ const App = () => (
6673
ReactDOM.render(<App />, document.getElementById('root'))
6774
```
6875

76+
If your own components need to respond to the layout use the `useLayout` hook to obtain the current layout details.
77+
6978
## 📱 Responsive
7079

7180
The layout adjusts for small screen sizes.
@@ -76,74 +85,80 @@ The layout adjusts for small screen sizes.
7685

7786
## 📝 Config
7887

79-
For each config parameter a single value or an object with breakpoint keys can be supplied, e.g.
88+
For each config parameter a single value or an object with breakpoint keys (`'xs' | 'sm' | 'md' | 'lg' | 'xl'`) can be supplied, e.g.
8089

8190
```javascript
8291
const config = {
83-
navWidth: {
84-
// xs is 256px by default
85-
sm: 200, // in sm
86-
md: 256 // mdUp
92+
clipped: false,
93+
collapsible: {
94+
// fully specified
95+
xs: true,
96+
sm: false,
97+
md: true,
98+
lg: false,
99+
xl: true,
87100
}
101+
navWidth: {
102+
// partial specified, other use closest
103+
sm: 200, // smDown and in sm
104+
md: 256, // mdUp
105+
},
88106
}
89107
```
90108

91-
## Props
92-
93-
### Root.config
94-
95-
|Prop|Type|Description|Default Value|
96-
|-|-|-|-|
97-
|clipped|boolean \| ScreenProps\<boolean>|Clipped moves the header over the top of the navigation drawer, unclipped makes navigation full height|false
98-
|collapsible|boolean \| ScreenProps\<boolean>|Can the navigation be collapsed to a smaller form|true|
99-
|collapsedWidth|number \| ScreenProps\<number>|Width of the collapsed navigation|64|
100-
|footerShrink|boolean \| ScreenProps\<boolean>|Footer to adjust the size to fit when nav expanded,set false to keep the same width and overflow the screen.|true|
101-
|navAnchor|Orientation \| ScreenProps\<Orientation>|Which side of the screen to show the nav panel|left|
102-
|navVariant|Variant \| ScreenProps\<Variant>|**Permanent**: stays all the time. **Persistent**: remains open but can be hidden with button. **Temporary**: hides on click away (and selection).|permanent|
103-
|navWidth|number \| ScreenProps\<number>|Width of the navigation drawer|256|
104-
|headerPosition|Position \| ScreenProps\<Position>|Position applied to the AppBar header. one of 'static', 'relative', 'sticky', 'fixed', 'absolute' See https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Positioning|relative|
105-
|squeezed|boolean \| ScreenProps\<>|Both header and content adjust the size to fit when nav expanded, set false to keep the same width and overflow the screen.|boolean|
106-
107-
### Root.component
108-
109-
### Nav.component
110-
### Nav.header
111-
`ReactNode`
112-
### Nav.closeButtonProps
113-
Props to pass to the underlying Close Button. `IconButtonProps`
114-
### Nav.collapsedIcon
115-
```
116-
{
117-
active: ReactNode
118-
inactive: ReactNode
119-
}
120-
```
109+
## 📝 Config
121110

122-
### Content.component
111+
For each config parameter a single value or an object with breakpoint keys (`'xs' | 'sm' | 'md' | 'lg' | 'xl'`) can be supplied, e.g.
123112

124-
### Header.position
125-
One of 'static', 'relative', 'sticky', 'fixed', 'absolute'. See `Root.headerPosition`.
126-
### Header.toolbarProps
127-
Props to pass to the underlying Toolbar. `commitd/components ToolbarProps`
128-
### Header.menuButtonProps
129-
Props to pass to the underlying Menu Button. `IconButtonProps`
130-
### Header.menuIcon
131-
```
132-
{
133-
active: ReactNode
134-
inactive: ReactNode
113+
```javascript
114+
const config = {
115+
clipped: false,
116+
collapsible: {
117+
// fully specified
118+
xs: true,
119+
sm: false,
120+
md: true,
121+
lg: false,
122+
xl: true,
123+
}
124+
navWidth: {
125+
// partial specified, other use closest
126+
sm: 200, // smDown and in sm
127+
md: 256, // mdUp
128+
},
135129
}
136130
```
137-
### Header.color
138131

139-
### Footer.component
132+
| Config parameter | Type | Description | Default Value |
133+
| ---------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
134+
| collapsible | boolean \| ScreenProps\<boolean\> | Can the navigation be collapsed to a smaller form | true |
135+
| collapsedWidth | number \| ScreenProps\<number\> | Width of the collapsed navigation | 64 |
136+
| navAnchor | Orientation \| ScreenProps\<Orientation\> | Which side of the screen to show the nav panel | left |
137+
| navVariant | Variant \| ScreenProps\<Variant\> | **Permanent**: stays all the time. **Persistent**: remains open but can be hidden with button. **Temporary**: hides on click away (and selection). | permanent |
138+
| navWidth | number \| ScreenProps\<number\> | Width of the navigation drawer | 256 |
139+
| headerPosition | Position \| ScreenProps\<Position\> | Position applied to the AppBar header. one of 'static', 'relative', 'sticky', 'fixed', 'absolute' See https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Positioning | relative |
140+
| headerResponse | HeaderResponse \| ScreenProps\<HeaderResponse\> | How should the Header adjust its size and position when navigation expanded . One of 'clipped', 'static', 'squeezed', 'pushed'. | 'squeezed' |
141+
| contentResponse | Response \| ScreenProps\<Response\> | How should the Content adjust its size and position when navigation expanded. One of 'static', 'squeezed', 'pushed'. | 'squeezed' |
142+
| footerResponse | Response \| ScreenProps\<Response\> | How should the Footer adjust its size and position when navigation expanded. One of 'static', 'squeezed', 'pushed'. | 'squeezed' |
143+
144+
### Response
145+
146+
How the elements respond to the navigation position changes is configured using the `xxxResponse` parameters. The values are:
147+
148+
- **static**: does not move for the navigation drawer, which sits on top
149+
- **squeezed**: size is reduced to allow for the navigation draw
150+
- **pushed**: the size remains the same but is moved over to allow for the drawer, only effective for navAnchor `left`
151+
- **clipped**: (Header only) moves the header over the top of the navigation drawer
152+
153+
### Props
140154

155+
For component props, see the [storybook](https://committed.software/layout)
141156

142157
## 💻 Development
143158

144159
On first use run `yarn install` in both the root folder and the example folder.
145160

146-
The main build is currently performed using Rollup:
161+
The main build is performed using:
147162

148163
```bash
149164
yarn build

0 commit comments

Comments
 (0)