-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
STCOM-1176 Upgrade storybook to v7 (#2219)
* upgrade to storybook 7 * remove unused storybook addon * whittle the babel config * remove commented plugins * add comments to storybook setup files. * add blank lines to end of babel config. * remove commented code in preview * just use the usual babel config... * remove the babel subset * add replacements for intl, direction plugins * Update CHANGELOG.md * add blank line at the end of IntlWrap.css
- Loading branch information
Showing
64 changed files
with
222 additions
and
410 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.iwControls { | ||
position: sticky; | ||
inset: 0; | ||
background-color: #fff; | ||
border-bottom: 1px solid #e7e7e7; | ||
z-index: 1; | ||
margin-bottom: 1rem; | ||
padding-bottom: .5rem; | ||
display: flex; | ||
gap: .5rem; | ||
align-items: center; | ||
} | ||
|
||
.iwLabel { | ||
font-weight: bold; | ||
display: inline; | ||
} | ||
|
||
.iwLegend { | ||
display: block; | ||
} | ||
|
||
.iwFieldSet { | ||
display: flex; | ||
flex-wrap: nowrap; | ||
gap: .5rem; | ||
} |
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,38 @@ | ||
// component providing both a switch for locale and a toggle switch for rtl. | ||
import React, { useState, useCallback } from 'react'; | ||
import { IntlProvider } from 'react-intl'; | ||
import css from './IntlWrap.css'; | ||
|
||
function updatePageDirection(direction) { | ||
document.body.dir = direction; | ||
console.log('setting direction'); | ||
} | ||
|
||
const IntlWrap = ({ messages, children }) => { | ||
const [locale, updateLocale] = useState('en'); | ||
const [direction, updateDirection ] = useState('LTR'); | ||
|
||
const handleDirectionChange = (e) => { | ||
updateDirection(e.target.value); | ||
updatePageDirection(e.target.value); | ||
}; | ||
|
||
return ( | ||
<IntlProvider locale={locale} messages={messages['en']}> | ||
<div className={css.iwControls} dir="ltr"><label className={css.iwLabel}>Locale: </label><select value={locale} onChange={e => updateLocale(e.target.value)}> | ||
{ | ||
Object.keys(messages).map(l => <option key={l}>{l}</option>) | ||
} | ||
</select> | ||
<div className={css.iwFieldSet}> | ||
<label className={`${css.iwLegend} ${css.iwLabel}`} >Direction: </label> | ||
<label><input type="radio" onChange={handleDirectionChange} name="direction" value="LTR" checked={direction === 'LTR'}/> LTR</label> | ||
<label><input type="radio" onChange={handleDirectionChange} name="direction" value="RTL" checked={direction === 'RTL'}/> RTL</label> | ||
</div> | ||
</div> | ||
{ children } | ||
</IntlProvider> | ||
) | ||
} | ||
|
||
export default IntlWrap; |
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,15 +1,7 @@ | ||
import { addons } from '@storybook/addons'; | ||
import { themes } from '@storybook/theming'; | ||
import pkg from '../package.json' | ||
import { addons } from '@storybook/manager-api'; | ||
import theme from './theme'; | ||
|
||
|
||
addons.setConfig({ | ||
docs: { | ||
theme: Object.assign( | ||
themes.light, | ||
{ | ||
brandTitle: `Stripes-Components v${pkg.version}`, | ||
brandUrl: 'https://github.com/folio-org/stripes-components' | ||
} | ||
) | ||
} | ||
theme: theme | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { create } from '@storybook/theming/create'; | ||
import pkg from '../package.json'; | ||
|
||
// Setting up this 'theme' renders the library version in the storybook UI. | ||
|
||
export default create({ | ||
base: 'light', | ||
brandTitle: `Stripes-Components v${pkg.version}`, | ||
brandUrl: 'https://github.com/folio-org/stripes-components', | ||
}); |
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
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,22 +1,15 @@ | ||
import React from 'react'; | ||
import withReadme from 'storybook-readme/with-readme'; | ||
import Readme from '../readme.md'; | ||
import BasicUsage from './BasicUsage'; | ||
import WithQueryBuilder from './WithQueryBuilder'; | ||
|
||
export default { | ||
title: 'AdvancedSearch', | ||
decorators: [withReadme(Readme)], | ||
}; | ||
|
||
export const WithDefaults = () => <BasicUsage />; | ||
|
||
WithDefaults.story = { | ||
name: 'with defaults', | ||
}; | ||
WithDefaults.storyName = 'with defaults'; | ||
|
||
export const WithCustomQueryBuilder = () => <WithQueryBuilder />; | ||
|
||
WithCustomQueryBuilder.story = { | ||
name: 'with custom queryBuilder', | ||
}; | ||
WithCustomQueryBuilder.storyName = 'with custom queryBuilder'; |
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,11 +1,8 @@ | ||
import React from 'react'; | ||
import withReadme from 'storybook-readme/with-readme'; | ||
import readme from '../readme.md'; | ||
import BasicUsage from './BasicUsage'; | ||
|
||
export default { | ||
title: 'AutoSuggest', | ||
decorators: [withReadme(readme)], | ||
}; | ||
|
||
export const _BasicUsage = () => <BasicUsage />; |
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,11 +1,8 @@ | ||
import React from 'react'; | ||
import withReadme from 'storybook-readme/with-readme'; | ||
import readme from '../readme.md'; | ||
import BasicUsage from './BasicUsage'; | ||
|
||
export default { | ||
title: 'Avatar', | ||
decorators: [withReadme(readme)], | ||
}; | ||
|
||
export const _BasicUsage = () => <BasicUsage />; |
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,11 +1,8 @@ | ||
import React from 'react'; | ||
import withReadme from 'storybook-readme/with-readme'; | ||
import readme from '../readme.md'; | ||
import BasicUsage from './BasicUsage'; | ||
|
||
export default { | ||
title: 'Badge', | ||
decorators: [withReadme(readme)], | ||
}; | ||
|
||
export const _BasicUsage = () => <BasicUsage />; |
Oops, something went wrong.