-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add storybook * add wip stories * prettier * build-demo * coverage * ignore all new-components * snaps, nav blocks, layout blocks, contain layout * auto take snaps * Update babel.config.js * NOT PINK Co-authored-by: Rikki Schulte <rikki.schulte@gmail.com>
- Loading branch information
Showing
23 changed files
with
2,733 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { configure, addDecorator } from '@storybook/react'; | ||
import ThemeProvider from '../src/new-components/theme/ThemeProvider'; | ||
import ThemeProvider from '../src/new-components/themes/provider'; | ||
import React from 'react'; | ||
import requireContext from 'require-context.macro'; | ||
|
||
addDecorator(story => <ThemeProvider>{story()}</ThemeProvider>); | ||
|
||
configure( | ||
require.context('../src/new-components', true, /\.stories\.js$/), | ||
requireContext('../src/new-components', true, /\.stories\.js$/), | ||
module, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,112 @@ | ||
import React from 'react'; | ||
import Layout from './Layout'; | ||
import Nav from './Nav'; | ||
import List, { ListRow } from './List'; | ||
import { useThemeLayout } from './themes/provider'; | ||
|
||
const explorer = { | ||
input: ( | ||
<List> | ||
<ListRow>{'Input'}</ListRow> | ||
</List> | ||
), | ||
response: ( | ||
<List> | ||
<ListRow>{'Response'}</ListRow> | ||
</List> | ||
), | ||
console: ( | ||
<List> | ||
<ListRow>{'Console/Inspector'}</ListRow> | ||
</List> | ||
), | ||
}; | ||
const nav = <Nav />; | ||
const slots = { nav, explorer }; | ||
|
||
export default { title: 'Layout' }; | ||
|
||
export const withDefaultSlots = () => <Layout />; | ||
export const withSlots = () => { | ||
const Layout = useThemeLayout(); | ||
return <Layout {...slots} />; | ||
}; | ||
|
||
export const withManySidebars = () => { | ||
const Layout = useThemeLayout(); | ||
return ( | ||
<Layout | ||
{...slots} | ||
navPanels={[ | ||
{ | ||
key: 1, | ||
size: 'sidebar', | ||
component: ( | ||
<List> | ||
<ListRow>{'Sidebar'}</ListRow> | ||
</List> | ||
), | ||
}, | ||
{ | ||
key: 2, | ||
size: 'aside', | ||
component: ( | ||
<List> | ||
<ListRow>{'aside'}</ListRow> | ||
</List> | ||
), | ||
}, | ||
{ | ||
key: 3, | ||
size: 'aside', | ||
component: ( | ||
<List> | ||
<ListRow>{'Another aside'}</ListRow> | ||
</List> | ||
), | ||
}, | ||
]} | ||
/> | ||
); | ||
}; | ||
|
||
export const withFullScreenPanel = () => { | ||
const Layout = useThemeLayout(); | ||
return ( | ||
<Layout | ||
{...slots} | ||
navPanels={[ | ||
{ | ||
key: 1, | ||
size: 'full-screen', | ||
component: ( | ||
<List> | ||
<ListRow>{'Woooo'}</ListRow> | ||
</List> | ||
), | ||
}, | ||
]} | ||
/> | ||
); | ||
}; | ||
|
||
export const withCustomSlots = () => <Layout nav={<Nav />} />; | ||
export const withStringsOnly = () => { | ||
const Layout = useThemeLayout(); | ||
return ( | ||
<Layout | ||
{...{ | ||
explorer: { | ||
input: 'input', | ||
response: 'response', | ||
console: 'console', | ||
}, | ||
nav: 'nav', | ||
navPanels: [ | ||
{ | ||
component: 'sidebar', | ||
key: 'sidebar', | ||
size: 'sidebar', | ||
}, | ||
], | ||
}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** @jsx jsx */ | ||
import { jsx } from 'theme-ui'; | ||
|
||
import PropTypes from 'prop-types'; | ||
|
||
const ListRow = ({ children, flex = false, padding = true }) => ( | ||
<div | ||
sx={{ | ||
overflow: 'auto', | ||
flex: flex && '1 1 auto', | ||
padding: padding && 2, | ||
}}> | ||
{children} | ||
</div> | ||
); | ||
ListRow.propTypes = { | ||
flex: PropTypes.bool, | ||
padding: PropTypes.bool, | ||
}; | ||
|
||
const List = ({ children }) => ( | ||
<div | ||
sx={{ | ||
backgroundColor: 'cardBackground', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
overflow: 'hidden', | ||
'> *:not(:first-of-type)': { | ||
borderTop: theme => `1px solid ${theme.colors.border}`, | ||
}, | ||
'> *': { | ||
flex: '0 0 auto', | ||
}, | ||
}}> | ||
{children} | ||
</div> | ||
); | ||
|
||
List.propTypes = { | ||
mini: PropTypes.bool, | ||
}; | ||
|
||
export default List; | ||
export { ListRow }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** @jsx jsx */ | ||
import { jsx } from 'theme-ui'; | ||
import List, { ListRow } from './List'; | ||
|
||
export default { title: 'Lists' }; | ||
|
||
const longText = Array(300) | ||
.fill('scroll') | ||
.map((c, i) => <div key={i}>{c}</div>); | ||
|
||
export const withFlexChild = () => ( | ||
<div style={{ height: '100vh', display: 'grid' }}> | ||
<List> | ||
<ListRow> | ||
{ | ||
'Lists are a vertical stack of components and form the basis of most modules. This one is very long' | ||
} | ||
</ListRow> | ||
<ListRow flex> | ||
{'You normally want 1 flex area that grows forever like this one'} | ||
{longText} | ||
{'the end'} | ||
</ListRow> | ||
</List> | ||
</div> | ||
); | ||
|
||
export const withStackedRows = () => ( | ||
<div style={{ height: '100vh', display: 'grid' }}> | ||
<List> | ||
<ListRow>{'Title'}</ListRow> | ||
<ListRow>{'Navigation'}</ListRow> | ||
<ListRow>{'Search'}</ListRow> | ||
<ListRow>{'Filter'}</ListRow> | ||
<ListRow flex> | ||
{'Actual content'} | ||
{longText} | ||
{'Actual content ends here'} | ||
</ListRow> | ||
<ListRow>{'Footer'}</ListRow> | ||
<ListRow>{'Footers footer'}</ListRow> | ||
</List> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** @jsx jsx */ | ||
import { jsx } from 'theme-ui'; | ||
|
||
const SectionHeader = ({ children }) => ( | ||
<h2 sx={{ color: 'primary', fontSize: [2] }}>{children}</h2> | ||
); | ||
|
||
const Explainer = ({ children }) => ( | ||
<span sx={{ fontSize: [0] }}>{children}</span> | ||
); | ||
|
||
export { SectionHeader, Explainer }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** @jsx jsx */ | ||
import { jsx } from 'theme-ui'; | ||
import List, { ListRow } from './List'; | ||
import { SectionHeader, Explainer } from './Type'; | ||
|
||
export default { title: 'Type' }; | ||
|
||
export const type = () => ( | ||
<List> | ||
<ListRow> | ||
<SectionHeader>{'Title'}</SectionHeader> | ||
</ListRow> | ||
<ListRow> | ||
<Explainer>{'Small explainer text'}</Explainer> | ||
</ListRow> | ||
<ListRow>{'Normal text'}</ListRow> | ||
</List> | ||
); |
15 changes: 0 additions & 15 deletions
15
packages/graphiql/src/new-components/__tests__/Layout.spec.js
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
packages/graphiql/src/new-components/__tests__/Nav.spec.js
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
packages/graphiql/src/new-components/__tests__/__snapshots__/Layout.spec.js.snap
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.