diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index d07b4befe..a86de59d0 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -7,10 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Use Node.js 16 + - name: Use Node.js 20 uses: actions/setup-node@v2 with: - node-version: 16 + node-version: 20 - run: yarn install --immutable - run: yarn dist - run: npm version prerelease --preid=$GITHUB_HEAD_REF-`git rev-parse --short HEAD` --git-tag-version=false --commit-hooks=false diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 4ddb4def4..2c6ce482c 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/setup-node@v2 with: - node-version: 16 + node-version: 20 - uses: google-github-actions/release-please-action@v3 id: release-please with: @@ -51,7 +51,7 @@ jobs: if: ${{ steps.release.outputs.release_created }} - uses: actions/setup-node@v2 with: - node-version: 16 + node-version: 20 if: ${{ steps.release.outputs.release_created }} - run: yarn install --immutable if: ${{ steps.release.outputs.release_created }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4295eb8cd..ddd67be80 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,10 +15,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use Node.js 16 + - name: Use Node.js 20 uses: actions/setup-node@v1 with: - node-version: 16 + node-version: 20 - run: yarn install --immutable - run: yarn lint - run: yarn format diff --git a/.storybook/main.js b/.storybook/main.js index e67245147..da4198965 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -4,26 +4,14 @@ module.exports = { '../src/**/*.stories.{js,tsx}', './stories/More.stories.js', ], + addons: [ - { - name: '@storybook/addon-essentials', - options: { - backgrounds: false, - controls: false, - docs: false, - }, - }, - '@storybook/addon-knobs', + '@storybook/addon-essentials', + '@storybook/addon-controls', '@storybook/addon-actions', 'storybook-source-link', - { - name: '@storybook/addon-storysource', - options: { - rule: { - enforce: 'pre', - }, - }, - }, + '@storybook/addon-webpack5-compiler-babel', + '@chromatic-com/storybook', '@storybook/addon-viewport', { name: '@storybook/addon-a11y', @@ -32,5 +20,13 @@ module.exports = { }, }, ], - framework: '@storybook/react', + + framework: { + name: '@storybook/react-webpack5', + options: {}, + }, + + typescript: { + reactDocgen: false, + }, }; diff --git a/.storybook/manager.js b/.storybook/manager.js index 8e7a55431..6b8207090 100644 --- a/.storybook/manager.js +++ b/.storybook/manager.js @@ -1,4 +1,4 @@ -import { addons } from '@storybook/addons'; +import { addons } from '@storybook/manager-api'; import { create } from '@storybook/theming/create'; import pkg from '../package.json'; diff --git a/.storybook/preview.js b/.storybook/preview.js index d0d892055..af08951ec 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -15,7 +15,7 @@ import allThemes from './themes'; export const parameters = { sourceLinkPrefix: 'https://github.com/appfolio/react-gears/tree/master/src/components/', -} +}; const changeTheme = (url) => { const link = document.getElementById('theme'); @@ -76,3 +76,4 @@ export const decorators = [ ), ]; +export const tags = ['autodocs']; diff --git a/.tool-versions b/.tool-versions index 8d8150475..9e1e7e1e1 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1 @@ -nodejs lts-gallium -yarn 1.22.19 +nodejs 20.14.0 \ No newline at end of file diff --git a/package.json b/package.json index 139304e3b..de791a9dc 100644 --- a/package.json +++ b/package.json @@ -27,15 +27,16 @@ "format:fix": "prettier --write src", "test": "jest --coverage", "test:watch": "jest --watch", - "start": "start-storybook -p 6006", - "docs": "build-storybook -o docs", + "start": "storybook dev -p 6006", + "docs": "storybook build -o docs", "version": "yarn docs && git add -A docs", "clean": "rm -rf esm lib", "dist:types": "tsc --project tsconfig.build.json", "dist:types:js": "scripts/copyDTSFiles.js", "dist:esm": "babel src --out-dir esm --config-file ./babel.esm.config.js --extensions '.js,.ts,.tsx'", "dist:lib": "babel src --out-dir lib --config-file ./babel.build.config.js --extensions '.js,.ts,.tsx'", - "dist": "yarn clean && concurrently \"yarn:dist:*\"" + "dist": "yarn clean && concurrently \"yarn:dist:*\"", + "storybook:doctor": "npx storybook doctor" }, "peerDependencies": { "react": ">= 16.8", @@ -75,7 +76,6 @@ "react-transition-group": "^2.9.0", "react-use": "^17.3.2", "reactstrap": "^9.2.2", - "storybook-source-link": "^2.0.8", "styled-jsx": "^5.1.1", "text-mask-addons": "^3.8.0", "tributejs": "^5.1.3", @@ -90,16 +90,17 @@ "@babel/preset-env": "^7.16.11", "@babel/preset-react": "^7.16.7", "@babel/preset-typescript": "^7.16.7", + "@chromatic-com/storybook": "^1.5.0", "@jest/types": "^27.5.1", - "@storybook/addon-a11y": "^6.3.11", - "@storybook/addon-actions": "^6.3.11", - "@storybook/addon-essentials": "^6.3.11", - "@storybook/addon-knobs": "^6.3.1", - "@storybook/addon-links": "^6.3.11", - "@storybook/addon-storysource": "^6.3.11", - "@storybook/addon-viewport": "^6.3.11", - "@storybook/addons": "^6.3.11", - "@storybook/react": "^6.3.11", + "@storybook/addon-a11y": "^8.1.5", + "@storybook/addon-actions": "^8.1.5", + "@storybook/addon-controls": "^8.1.5", + "@storybook/addon-essentials": "^8.1.5", + "@storybook/addon-links": "^8.1.5", + "@storybook/addon-viewport": "^8.1.5", + "@storybook/addon-webpack5-compiler-babel": "^3.0.3", + "@storybook/react": "^8.1.5", + "@storybook/react-webpack5": "^8.1.5", "@testing-library/dom": "^8.13.0", "@testing-library/jest-dom": "^5.16.3", "@testing-library/react": "^11.2.6", @@ -151,6 +152,8 @@ "react-dom": "^16.14.0", "regenerator-runtime": "^0.13.7", "sinon": "^9.2.1", + "storybook": "^8.1.5", + "storybook-source-link": "^4.0.1", "ts-node": "^10.7.0", "typescript": "^4.6.3", "uncontrollable": "^4.1.0" diff --git a/src/components/Accordion/Accordion.stories.js b/src/components/Accordion/Accordion.stories.js index 2e293079a..86df42176 100644 --- a/src/components/Accordion/Accordion.stories.js +++ b/src/components/Accordion/Accordion.stories.js @@ -1,4 +1,3 @@ -import { boolean } from '@storybook/addon-knobs'; import React, { useState } from 'react'; import { Accordion, @@ -17,7 +16,7 @@ export default { }, }; -export const Example = () => { +export const Example = (args) => { const [open, setOpen] = useState('1'); const toggle = (id) => { if (open === id) { @@ -29,7 +28,7 @@ export const Example = () => { return (
- + Accordion Item 1 @@ -61,14 +60,11 @@ export const Example = () => {
); }; +Example.args = { flush: false }; -export const Uncontrolled = () => ( +export const Uncontrolled = (args) => (
- + Accordion Item 1 @@ -99,3 +95,7 @@ export const Uncontrolled = () => (
); +Uncontrolled.args = { + flush: false, + stayOpen: false, +}; diff --git a/src/components/Activity/Activity.stories.js b/src/components/Activity/Activity.stories.js index 42acfef19..2f3e5120d 100644 --- a/src/components/Activity/Activity.stories.js +++ b/src/components/Activity/Activity.stories.js @@ -1,28 +1,37 @@ -import { action } from '@storybook/addon-actions'; -import { boolean, select, text } from '@storybook/addon-knobs'; +import { action as sbAction } from '@storybook/addon-actions'; import React from 'react'; import { colors } from '../../tooling/colors'; import Activity from './Activity'; export default { - title: 'ActivityLog', + title: 'ActivityOnly', component: Activity, parameters: { sourceLink: 'Activity/Activity.tsx', }, }; -export const ActivityOnly = () => ( - - {text('content')} +export const ActivityOnly = ({ content, ...args }) => ( + + {content} ); +ActivityOnly.args = { + action: 'Published', + active: false, + by: 'Joel Bandi', + color: '', + dateFormat: undefined, + disabled: false, + onClick: sbAction('onClick'), + content: '', +}; +ActivityOnly.argTypes = { + color: { + options: ['', ...colors], + control: { type: 'select' }, + }, + dateFormat: { + control: 'text', + }, +}; diff --git a/src/components/Activity/ActivityLog.stories.js b/src/components/Activity/ActivityLog.stories.js index bd2264eaa..c9687328c 100644 --- a/src/components/Activity/ActivityLog.stories.js +++ b/src/components/Activity/ActivityLog.stories.js @@ -1,4 +1,3 @@ -import { boolean } from '@storybook/addon-knobs'; import React from 'react'; import Activity from './Activity'; import ActivityLog from './ActivityLog'; @@ -11,8 +10,8 @@ export default { }, }; -export const WithProps = () => ( - +export const WithProps = (args) => ( + @@ -22,9 +21,12 @@ export const WithProps = () => ( Nothing to see here, move on ); +WithProps.args = { + flush: false, +}; -export const AddingCustomComponents = () => ( - +export const AddingCustomComponents = (args) => ( + diff --git a/src/components/Address/AddressInput.stories.js b/src/components/Address/AddressInput.stories.js index 7b2321609..faedf460a 100644 --- a/src/components/Address/AddressInput.stories.js +++ b/src/components/Address/AddressInput.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean, text, select, object } from '@storybook/addon-knobs'; import React from 'react'; import Label from '../Label/Label'; import AddressInput from './AddressInput'; @@ -22,7 +21,7 @@ const defaultLabels = { countryCode: 'Country', }; -export const Default = () => ( +export const Default = (args) => (
( postal: '12345-1234', countryCode: 'US', }} - compact={boolean('compact', false)} - onBlur={action('address onBlur')} - onChange={action('address onChange')} - countries={object('countries', ['US'])} - disabled={boolean('disabled')} - error={object('error', {})} - showCountry={boolean('showCountry', true)} - showLabels={boolean('showLabels', false)} - labels={object('labels', defaultLabels)} - hints={object('hints', {})} + {...args} />
); +Default.args = { + compact: false, + onBlur: action('address onBlur'), + onChange: action('address onChange'), + countries: ['US'], + disabled: false, + error: {}, + showCountry: true, + showLabels: false, + labels: defaultLabels, + hints: {}, +}; -export const WithId = () => ( +export const WithId = (args) => (
( countryCode: 'US', }} id="myid" + {...args} />
); -export const Controlled = () => ( +export const Controlled = ({ address1, address2, city, state, postal, countryCode, ...args }) => (
s.value), - 'AL' - ), - postal: text('postal', '12345-1234'), - countryCode: text('countryCode', 'US'), + address1, + address2, + city, + state, + postal, + countryCode, }} - error={object('error', { address1: 'bad stuff', state: 'no' })} - onChange={action('address onChange')} - disabled={boolean('disabled')} + {...args} />
); +Controlled.args = { + address1: '123 No Way', + address2: 'Suite 16', + city: 'Smallsville', + state: 'AL', + postal: '12345-1234', + countryCode: 'US', + error: { address1: 'bad stuff', state: 'no' }, + onChange: action('address onChange'), + disabled: undefined, +}; +Controlled.argTypes = { + state: { + control: 'select', + options: states.map((s) => s.value), + }, + disabled: { + control: 'boolean', + }, +}; diff --git a/src/components/Address/CountryInput.stories.js b/src/components/Address/CountryInput.stories.js index 72ab27b48..80e5a5ba4 100644 --- a/src/components/Address/CountryInput.stories.js +++ b/src/components/Address/CountryInput.stories.js @@ -10,4 +10,4 @@ export default { }, }; -export const Country = () => ; +export const Country = (args) => ; diff --git a/src/components/Address/InternationalAddressInput.stories.js b/src/components/Address/InternationalAddressInput.stories.js index 0f2a7a8b0..c2e69557f 100644 --- a/src/components/Address/InternationalAddressInput.stories.js +++ b/src/components/Address/InternationalAddressInput.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean, object } from '@storybook/addon-knobs'; import React from 'react'; import uncontrollable from 'uncontrollable'; import InternationalAddressInput from './InternationalAddressInput'; @@ -18,16 +17,22 @@ const UncontrolledInternationalAddressInput = uncontrollable(InternationalAddres }); UncontrolledInternationalAddressInput.displayName = 'InternationalAddressInput'; -export const International = () => ( +export const International = (args) => (
- +
); +International.args = { + showLabels: InternationalAddressInput.defaultProps.showLabels, + onBlur: action('address onBlur'), + onChange: action('address onChange'), + disabled: undefined, + error: {}, + labels: InternationalAddressInput.defaultProps.labels, + hints: InternationalAddressInput.defaultProps.hints, +}; +International.argTypes = { + disabled: { + control: 'boolean', + }, +}; diff --git a/src/components/Address/StateInput.stories.js b/src/components/Address/StateInput.stories.js index 98dffd3b7..77cdcf42e 100644 --- a/src/components/Address/StateInput.stories.js +++ b/src/components/Address/StateInput.stories.js @@ -10,4 +10,4 @@ export default { }, }; -export const State = () => ; +export const State = (args) => ; diff --git a/src/components/Alert/Alert.stories.js b/src/components/Alert/Alert.stories.js index ac4be146e..2287b83bd 100644 --- a/src/components/Alert/Alert.stories.js +++ b/src/components/Alert/Alert.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { text, boolean, select } from '@storybook/addon-knobs'; import React from 'react'; import { colors } from '../../tooling/colors'; import Alert from './Alert'; @@ -12,31 +11,34 @@ export default { }, }; -export const LiveExample = () => ( - - {text( - 'content', - `Lorem ipsum dolor sit amet, consectetur adipiscing -elit, sed do eiusmod tempor incididunt ut labore -et dolore magna aliqua. Ut enim ad minim veniam, -quis nostrud exercitation ullamco laboris nisi ut -aliquip ex ea commodo consequat.` - )} - -); +export const LiveExample = ({ content, ...args }) => {content}; +LiveExample.args = { + icon: false, + dismissible: false, + color: 'info', + onToggle: action('onToggle'), + content: `Lorem ipsum dolor sit amet, consectetur adipiscing + elit, sed do eiusmod tempor incididunt ut labore + et dolore magna aliqua. Ut enim ad minim veniam, + quis nostrud exercitation ullamco laboris nisi ut + aliquip ex ea commodo consequat.`, +}; +LiveExample.argTypes = { + color: { + options: ['', ...colors], + control: { type: 'select' }, + }, +}; -export const Icons = () => ( +export const Icons = (args) => (
- You can also add an icon! - + + You can also add an icon! + + You can specify an alert color. This one has color="success" - + Humblebrag prism twee, gochujang seitan whatever asymmetrical ramps enamel pin austin salvia swag helvetica. Chartreuse food truck tofu raclette, 3 wolf moon poke chia paleo skateboard. Pickled tote bag echo park raclette. Irony fashion axe sartorial, cornhole jean shorts @@ -45,23 +47,23 @@ export const Icons = () => ( pour-over, helvetica chia brooklyn swag pug scenester kogi pitchfork leggings yuccie. Ethical put a bird on it portland vape YOLO. - + Heads up! This alert needs your attention, but it's not super important.
); -export const Dismissible = () => ( +export const Dismissible = (args) => (
- + Alerts can also be dismissed. Simply add the dismissible prop.
); -export const Extras = () => ( +export const Extras = (args) => (
- +

Well done!

You can use the alert-heading class on a heading to make it stand out! diff --git a/src/components/Badge/Badge.stories.tsx b/src/components/Badge/Badge.stories.tsx index 2d8291d7f..ca2a427d8 100644 --- a/src/components/Badge/Badge.stories.tsx +++ b/src/components/Badge/Badge.stories.tsx @@ -10,20 +10,22 @@ export default { }, }; -export const Default = () => ( +export const Default = (args: any) => (

{colors.map((color) => (
- {color} + + {color} +
))}
); -export const Pills = () => ( +export const Pills = (args: any) => (
{colors.map((color) => ( - + {color} ))} diff --git a/src/components/BlockPanel/BlockPanel.stories.js b/src/components/BlockPanel/BlockPanel.stories.js index 734b11bfa..74f9f07ee 100644 --- a/src/components/BlockPanel/BlockPanel.stories.js +++ b/src/components/BlockPanel/BlockPanel.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean, select, text } from '@storybook/addon-knobs'; import React from 'react'; import Button from '../Button/Button'; import ButtonGroup from '../Button/ButtonGroup'; @@ -22,26 +21,9 @@ export default { }, }; -export const LiveExample = () => ( - action('onEdit')} - color={select('color', [ - '', - 'primary', - 'secondary', - 'info', - 'success', - 'warning', - 'danger', - 'light', - 'dark', - ])} - expandable={boolean('expandable', true)} - hideOnToggle={boolean('hideOnToggle', false)} - open={boolean('open', true)} - > - {text('title') ? ( +export const LiveExample = (args) => ( + + {args.title ? (
The header is shown when a title prop is provided
@@ -52,34 +34,45 @@ export const LiveExample = () => ( )}
); +LiveExample.args = { + title: 'Some simple content would go here', + onEdit: action('onEdit'), + color: '', + expandable: true, + hideOnToggle: false, + open: true, +}; +LiveExample.argTypes = { + color: { + options: ['', 'primary', 'secondary', 'info', 'success', 'warning', 'danger', 'light', 'dark'], + control: { type: 'select' }, + }, +}; -export const InitiallyClosed = () => ( - action('onEdit')} - expandable={boolean('expandable', true)} - open={false} - > +export const InitiallyClosed = (args) => ( + Now you don't. ); +InitiallyClosed.args = { + title: 'Some simple content would go here', + onEdit: action('onEdit'), + expandable: true, +}; -export const OnToggle = () => ( - - Now you don't. - -); +export const OnToggle = (args) => Now you don't.; +OnToggle.args = { + title: 'Click me you fool', + onToggle: action('onToggle'), + expandable: true, +}; -export const ComponentsForTitleAndControls = () => ( +export const ComponentsForTitleAndControls = ({ title }) => ( - {text('title', 'Invoices')}{' '} + {title}{' '} It means nothing. @@ -105,11 +98,14 @@ export const ComponentsForTitleAndControls = () => ( Hello ); +ComponentsForTitleAndControls.args = { + title: 'Invoices', +}; -export const DropdownForControls = () => ( +export const DropdownForControls = ({ title }) => ( {text('title', 'Invoices')}} + title={{title}} controls={[ ( entities in a service that somehow match red ); +DropdownForControls.args = { + title: 'Invoices', +}; -export const StickyBlockPanel = () => ( - +export const StickyBlockPanel = ({ title }) => ( + I feel sticky, oh so sticky, I feel sticky, and witty, and wise. ); +StickyBlockPanel.args = { + title: 'I remember open/close', +}; diff --git a/src/components/Breadcrumb/Breadcrumb.stories.js b/src/components/Breadcrumb/Breadcrumb.stories.js index f8cd285fc..4e7e55e61 100644 --- a/src/components/Breadcrumb/Breadcrumb.stories.js +++ b/src/components/Breadcrumb/Breadcrumb.stories.js @@ -10,9 +10,9 @@ export default { }, }; -export const LiveExample = () => ( +export const LiveExample = (args) => (
- + Home diff --git a/src/components/Button/Button.stories.js b/src/components/Button/Button.stories.js index a5c6ffd73..c11a75f2f 100644 --- a/src/components/Button/Button.stories.js +++ b/src/components/Button/Button.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { text, boolean, select } from '@storybook/addon-knobs'; import React from 'react'; import { buttonColors } from '../../tooling/colors'; import DropdownItem from '../Dropdown/DropdownItem'; @@ -20,22 +19,30 @@ export default { }, }; -export const LiveExample = () => ( - -); +export const LiveExample = ({ label, ...args }) => ; +LiveExample.args = { + color: 'primary', + block: false, + disabled: false, + outline: false, + active: false, + size: undefined, + label: 'Click Me', +}; +LiveExample.argTypes = { + color: { + options: buttonColors, + control: { type: 'select' }, + }, + size: { + options: ['', 'sm', 'lg'], + control: { type: 'select' }, + }, +}; -export const Colors = () => ( +export const Colors = (args) => ( - + @@ -48,9 +55,11 @@ export const Colors = () => ( ); -export const Disabled = () => ( +export const Disabled = (args) => ( - + @@ -81,9 +90,11 @@ export const Disabled = () => ( ); -export const Outline = () => ( +export const Outline = (args) => ( - + @@ -114,9 +125,9 @@ export const Outline = () => ( ); -export const Sizes = () => ( +export const Sizes = (args) => (
-   @@ -130,22 +141,32 @@ export const Sizes = () => (
); -export const TooltipButtonExample = () => ( - - {text('Label', 'Click Me')} - +export const TooltipButtonExample = ({ label, ...args }) => ( + {label} ); +TooltipButtonExample.args = { + color: 'primary', + disabled: false, + onClick: action('onClick'), + tooltip: 'Here is a tooltip.', + placement: 'top', + label: 'Click Me', +}; +TooltipButtonExample.argTypes = { + color: { + options: buttonColors, + control: { type: 'select' }, + }, + placement: { + options: ['top', 'left', 'bottom', 'right'], + control: { type: 'select' }, + }, +}; -export const ButtonGroupExample = () => ( +export const ButtonGroupExample = (args) => (
-
@@ -197,8 +218,8 @@ export const ButtonGroupExample = () => (
); -export const ConfirmationButtonExample = () => ( - +export const ConfirmationButtonExample = (args) => ( + Do the thing! ); diff --git a/src/components/Calendar/Calendar.stories.tsx b/src/components/Calendar/Calendar.stories.tsx index 6bf149585..2639289e4 100644 --- a/src/components/Calendar/Calendar.stories.tsx +++ b/src/components/Calendar/Calendar.stories.tsx @@ -1,19 +1,27 @@ import { action } from '@storybook/addon-actions'; -import { select } from '@storybook/addon-knobs'; -import React from 'react'; +import type { Meta, StoryObj } from '@storybook/react'; import Calendar from './Calendar'; -export default { +const meta: Meta = { title: 'Calendar', component: Calendar, parameters: { sourceLink: 'Calendar/Calendar.tsx', }, + argTypes: { + weekDayFormat: { + options: [undefined, 'dd', 'ddd', 'dddd'], + control: { type: 'select' }, + }, + }, }; -export const CalendarExample = () => ( - -); +export default meta; +type Story = StoryObj; + +export const CalendarExample: Story = { + args: { + onSelect: action('onSelect'), + weekDayFormat: undefined, + }, +}; diff --git a/src/components/Calendar/MonthCalendar.stories.tsx b/src/components/Calendar/MonthCalendar.stories.tsx index dbb20c3ac..939ffdb6a 100644 --- a/src/components/Calendar/MonthCalendar.stories.tsx +++ b/src/components/Calendar/MonthCalendar.stories.tsx @@ -1,28 +1,52 @@ import { action } from '@storybook/addon-actions'; -import { boolean, select } from '@storybook/addon-knobs'; +import { Meta, StoryObj } from '@storybook/react'; import React, { useState } from 'react'; import MonthCalendar from './MonthCalendar'; -export default { - title: 'Calendar', +const meta: Meta = { + title: 'MonthCalendar', component: MonthCalendar, parameters: { sourceLink: 'Calendar/MonthCalendar.tsx', }, + argTypes: { + monthFormat: { + options: ['M', 'MM', 'MMM', 'MMMM'], + control: { + type: 'select', + }, + }, + yearFormat: { + options: ['YY', 'YYYY'], + control: { + type: 'select', + }, + }, + }, }; -export const MonthCalendarExample = () => { - const [date, setDate] = useState(new Date()); - return ( - { - setDate(e); - action('onSelect')(e); - }} - centerYearSelection={boolean('Center Year Selection', false)} - monthFormat={select('Month Format', ['M', 'MM', 'MMM', 'MMMM'], 'MMM')} - yearFormat={select('Year Format', ['YY', 'YYYY'], 'YYYY')} - /> - ); +export default meta; +type Story = StoryObj; + +export const MonthCalendarExample: Story = { + args: { + centerYearSelection: false, + monthFormat: 'MMM', + yearFormat: 'YYYY', + }, + render: function Render({ centerYearSelection, monthFormat, yearFormat }) { + const [date, setDate] = useState(new Date()); + return ( + { + setDate(e); + action('onSelect')(e); + }} + centerYearSelection={centerYearSelection} + monthFormat={monthFormat} + yearFormat={yearFormat} + /> + ); + }, }; diff --git a/src/components/Callout/Callout.stories.js b/src/components/Callout/Callout.stories.js index 18567188a..6aa4818b6 100644 --- a/src/components/Callout/Callout.stories.js +++ b/src/components/Callout/Callout.stories.js @@ -1,4 +1,3 @@ -import { select, text } from '@storybook/addon-knobs'; import React from 'react'; import { colors } from '../../tooling/colors'; import Callout from './Callout'; @@ -11,26 +10,35 @@ export default { }, }; -export const LiveExample = () => ( +export const LiveExample = ({ content, ...args }) => (
- +

Hello World

- {text( - 'content', - `Lorem ipsum dolor sit amet, consectetur adipiscing - elit, sed do eiusmod tempor incididunt ut labore - et dolore magna aliqua. Ut enim ad minim veniam, - quis nostrud exercitation ullamco laboris nisi ut - aliquip ex ea commodo consequat.` - )} + {content}
); +LiveExample.args = { + color: Callout.defaultProps.color, + background: Callout.defaultProps.background, + placement: Callout.defaultProps.placement, + content: `Lorem ipsum dolor sit amet, consectetur adipiscing + elit, sed do eiusmod tempor incididunt ut labore + et dolore magna aliqua. Ut enim ad minim veniam, + quis nostrud exercitation ullamco laboris nisi ut + aliquip ex ea commodo consequat.`, +}; +LiveExample.argTypes = { + color: { + options: [...colors], + control: { type: 'select' }, + }, + background: { + options: [...colors], + control: { type: 'select' }, + }, + placement: { + options: ['top', 'right', 'bottom', 'left'], + control: { type: 'select' }, + }, +}; diff --git a/src/components/Card/Card.stories.js b/src/components/Card/Card.stories.js index bb2543d25..13c2ff2e0 100644 --- a/src/components/Card/Card.stories.js +++ b/src/components/Card/Card.stories.js @@ -1,4 +1,3 @@ -import { text, boolean } from '@storybook/addon-knobs'; import React from 'react'; import { colors } from '../../tooling/colors'; import Card from './Card'; @@ -15,30 +14,27 @@ export default { }, }; -export const LiveExample = () => { - const outline = boolean('outline', false); - const footer = text('footer', ''); - - return ( -
- - - {text('title', 'Hello World!')} - - - {text( - 'content', - `Lorem ipsum dolor sit amet, consectetur adipiscing - elit, sed do eiusmod tempor incididunt ut labore - et dolore magna aliqua. Ut enim ad minim veniam, - quis nostrud exercitation ullamco laboris nisi ut - aliquip ex ea commodo consequat.` - )} - - {footer && {footer}} - -
- ); +export const LiveExample = ({ outline, footer, inverse, title, content }) => ( +
+ + + {title} + + {content} + {footer && {footer}} + +
+); +LiveExample.args = { + outline: false, + footer: '', + inverse: false, + title: 'Hello World!', + content: `Lorem ipsum dolor sit amet, consectetur adipiscing + elit, sed do eiusmod tempor incididunt ut labore + et dolore magna aliqua. Ut enim ad minim veniam, + quis nostrud exercitation ullamco laboris nisi ut + aliquip ex ea commodo consequat.`, }; export const Colors = () => ( @@ -55,28 +51,27 @@ export const Colors = () => (
); -export const Outline = () => { - const squareCorners = boolean('square corners', true); +export const Outline = ({ squareCorners }) => ( +
+ + + Default + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore et dolore magna aliqua. + + - return ( -
- + {colors.map((color) => ( + - Default + {color} Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - - {colors.map((color) => ( - - - {color} - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor - incididunt ut labore et dolore magna aliqua. - - - ))} -
- ); + ))} +
+); +Outline.args = { + squareCorners: true, }; diff --git a/src/components/Carousel/Carousel.stories.js b/src/components/Carousel/Carousel.stories.js index 8472d80ba..c6a996e70 100644 --- a/src/components/Carousel/Carousel.stories.js +++ b/src/components/Carousel/Carousel.stories.js @@ -30,4 +30,4 @@ export default { }, }; -export const Uncontrolled = () => ; +export const Uncontrolled = (args) => ; diff --git a/src/components/Carousel/ImageCarousel.stories.js b/src/components/Carousel/ImageCarousel.stories.js index 1a29bbdbb..91b036d42 100644 --- a/src/components/Carousel/ImageCarousel.stories.js +++ b/src/components/Carousel/ImageCarousel.stories.js @@ -1,4 +1,3 @@ -import { boolean, number } from '@storybook/addon-knobs'; import React from 'react'; import Jumbotron from '../Jumbotron/Jumbotron'; import ImageCarousel from './ImageCarousel'; @@ -33,23 +32,35 @@ const items = [ ]; export default { - title: 'Carousel', + title: 'ImageCarousel', component: ImageCarousel, parameters: { sourceLink: 'Carousel/ImageCarousel.js', + docs: { + // contain modal within iframe to enable user interaction + // https://github.com/storybookjs/storybook/issues/16949#issuecomment-1106586570 + // unfortunately, it seems to break the controls functionality, but only in the Docs view + story: { + inline: false, + iframeHeight: 500, + }, + }, + }, + argTypes: { + interval: { + control: 'number', + }, }, }; -export const DefaultProps = () => ( - -); +export const DefaultProps = (args) => ; +DefaultProps.args = { + autoPlay: ImageCarousel.defaultProps.autoPlay, + controls: true, + fade: ImageCarousel.defaultProps.fade, + slide: ImageCarousel.defaultProps.slide, + index: 0, + indicators: true, + interval: ImageCarousel.defaultProps.interval, + isOpen: true, +}; diff --git a/src/components/Checkbox/CheckboxGroup.stories.js b/src/components/Checkbox/CheckboxGroup.stories.js index a1b1cac44..8bdad0b9d 100644 --- a/src/components/Checkbox/CheckboxGroup.stories.js +++ b/src/components/Checkbox/CheckboxGroup.stories.js @@ -24,7 +24,7 @@ export default { }, }; -export const LiveExample = () => { +export const LiveExample = (args) => { const [selected, setSelected] = useState([]); const handleChange = (values) => { @@ -32,10 +32,10 @@ export const LiveExample = () => { action('onChange')(values); }; - return ; + return ; }; -export const SomeDisabled = () => { +export const SomeDisabled = (args) => { const [selected, setSelected] = useState([]); const handleChange = (values) => { @@ -44,11 +44,16 @@ export const SomeDisabled = () => { }; return ( - + ); }; -export const Horizontal = () => { +export const Horizontal = (args) => { const [selected, setSelected] = useState([]); const handleChange = (values) => { @@ -62,6 +67,7 @@ export const Horizontal = () => { options={options} onChange={handleChange} selected={selected} + {...args} /> ); }; diff --git a/src/components/CollapsableText/CollapsableText.stories.js b/src/components/CollapsableText/CollapsableText.stories.js index 6a7fc165a..bcc878a11 100644 --- a/src/components/CollapsableText/CollapsableText.stories.js +++ b/src/components/CollapsableText/CollapsableText.stories.js @@ -1,5 +1,4 @@ /* eslint-disable jsx-a11y/anchor-is-valid */ -import { boolean, number, text, radios } from '@storybook/addon-knobs'; import React from 'react'; import Icon from '../Icon/Icon'; import CollapsableText from './CollapsableText'; @@ -19,61 +18,76 @@ export default { }, }; -export const LiveExample = () => ( - +export const LiveExample = (args) => ( + Some text with bold and links and other things
{loremIpsum}
); +LiveExample.args = { + collapsed: CollapsableText.defaultProps.collapsed, + maxLines: CollapsableText.defaultProps.maxLines, + moreLabel: CollapsableText.defaultProps.moreLabel, + lessLabel: CollapsableText.defaultProps.lessLabel, + alignToggleButton: CollapsableText.defaultProps.alignToggleButton, +}; +LiveExample.argTypes = { + alignToggleButton: { + options: ['start', 'center', 'end', 'auto'], + control: { type: 'radio' }, + }, +}; -export const ShorterThanMaxLines = () => ( +export const ShorterThanMaxLines = ({ maxLines }) => (
- Short text + Short text
); +ShorterThanMaxLines.args = { + maxLines: 2, +}; -export const CustomComponents = () => ( +export const CustomComponents = (args) => (
} lessLabel={} + {...args} > {loremIpsum}
); -export const AlignToggleButtonStart = () => ( +export const AlignToggleButtonStart = (args) => (
- {loremIpsum} + + {loremIpsum} +
); -export const AlignToggleButtonCenter = () => ( +export const AlignToggleButtonCenter = (args) => (
- {loremIpsum} + + {loremIpsum} +
); -export const AlignToggleButtonEnd = () => ( +export const AlignToggleButtonEnd = (args) => (
- {loremIpsum} + + {loremIpsum} +
); -export const AlignToggleButtonAuto = () => ( +export const AlignToggleButtonAuto = (args) => (
- {loremIpsum} + + {loremIpsum} +
); diff --git a/src/components/Collapse/Collapse.stories.js b/src/components/Collapse/Collapse.stories.js index e2f5572ae..0e1ab0b3a 100644 --- a/src/components/Collapse/Collapse.stories.js +++ b/src/components/Collapse/Collapse.stories.js @@ -11,24 +11,26 @@ export default { }, }; -export const Controlled = () => { +export const Controlled = (args) => { const [open, setOpen] = useState(false); return (
- This content will fade in and out as the button is pressed + + This content will fade in and out as the button is pressed +
); }; -export const Uncontrolled = () => ( +export const Uncontrolled = (args) => (
- + Lorem ipsum dolor sit amet consectetur adipisicing elit. Nesciunt magni, voluptas debitis similique porro a molestias consequuntur earum odio officiis natus, amet hic, iste sed dignissimos esse fuga! Minus, alias. diff --git a/src/components/Combobox/Combobox.stories.js b/src/components/Combobox/Combobox.stories.js index c51e96b5d..2300aca05 100644 --- a/src/components/Combobox/Combobox.stories.js +++ b/src/components/Combobox/Combobox.stories.js @@ -1,4 +1,3 @@ -import { boolean, text, select } from '@storybook/addon-knobs'; import React, { useState } from 'react'; import Icon from '../Icon/Icon'; import Combobox from './Combobox'; @@ -67,159 +66,179 @@ const options = [ { label: 'Virgin Islands', value: 'VI' }, ]; -export default { +const meta = { title: 'Combobox', component: Combobox, parameters: { sourceLink: 'Combobox/Combobox.tsx', }, + argTypes: { + direction: { + options: ['', 'down', 'up'], + control: { type: 'select' }, + }, + disabled: { control: 'boolean' }, + noResultsLabel: { control: 'text' }, + placeholder: { control: 'text' }, + }, }; -export const LiveExample = () => { - const [value, setValue] = useState(); - return ( - <> -
value: {value}
- - - ); +export default meta; + +export const LiveExample = { + args: { + direction: '', + disabled: Combobox.defaultProps.disabled, + noResultsLabel: Combobox.defaultProps.noResultsLabel, + placeholder: Combobox.defaultProps.placeholder, + inputClassName: '', + }, + render: function Render(args) { + const [value, setValue] = useState(); + return ( + <> +
value: {value}
+ + + ); + }, }; -export const Multi = () => { - const [value, setValue] = useState(); - return ( - - ); +export const Multi = { + args: { + direction: '', + disabled: Combobox.defaultProps.disabled, + noResultsLabel: Combobox.defaultProps.noResultsLabel, + placeholder: Combobox.defaultProps.placeholder, + inputClassName: '', + }, + render: function Render(args) { + const [value, setValue] = useState(); + return ; + }, }; -export const Grouped = () => { - const [value, setValue] = useState(); - return ( - - ); +export const Grouped = { + args: { + multi: false, + direction: '', + disabled: Combobox.defaultProps.disabled, + noResultsLabel: Combobox.defaultProps.noResultsLabel, + placeholder: Combobox.defaultProps.placeholder, + inputClassName: '', + }, + render: function Render(args) { + const [value, setValue] = useState(); + return ( + + ); + }, }; -export const CreatableOptions = () => { - const [value, setValue] = useState(); - const [opts, setOpts] = useState(options); +export const CreatableOptions = { + args: { + direction: '', + disabled: Combobox.defaultProps.disabled, + noResultsLabel: Combobox.defaultProps.noResultsLabel, + placeholder: Combobox.defaultProps.placeholder, + inputClassName: '', + }, + render: function Render(args) { + const [value, setValue] = useState(); + const [opts, setOpts] = useState(options); - const onCreate = (str) => { - const newOpt = { value: str, label: str }; - setOpts([...opts, newOpt]); + const onCreate = (str) => { + const newOpt = { value: str, label: str }; + setOpts([...opts, newOpt]); - return newOpt.value; - }; + return newOpt.value; + }; - return ( - - ); + return ( + + ); + }, }; -export const CustomOptions = () => { - const [value, setValue] = useState(); - const mixedOptions = [ - { - label: '71548561868 Super-duper long word like impossibly long Lane', - value: 'address-1', - type: 'address', - }, - { label: '439 Sunset Drive', value: 'address-2', disabled: true, type: 'address' }, - { label: '940 Penguin Ct', value: 'address-3', type: 'address' }, - { label: 'Ice Bear', value: 'tenant-1', type: 'tenant' }, - { label: 'Panda', value: 'tenant-2', type: 'tenant' }, - { label: '77 Snowball Blvd', value: 'address-4', type: 'address' }, - { label: 'Bob', value: 'tenant-3', type: 'tenant' }, - ]; - const renderOption = (option) => ( -
- - {option.label} -
- ); +export const CustomOptions = { + render: function Render(args) { + const [value, setValue] = useState(); + const mixedOptions = [ + { + label: '71548561868 Super-duper long word like impossibly long Lane', + value: 'address-1', + type: 'address', + }, + { label: '439 Sunset Drive', value: 'address-2', disabled: true, type: 'address' }, + { label: '940 Penguin Ct', value: 'address-3', type: 'address' }, + { label: 'Ice Bear', value: 'tenant-1', type: 'tenant' }, + { label: 'Panda', value: 'tenant-2', type: 'tenant' }, + { label: '77 Snowball Blvd', value: 'address-4', type: 'address' }, + { label: 'Bob', value: 'tenant-3', type: 'tenant' }, + ]; + const renderOption = (option) => ( +
+ + {option.label} +
+ ); - const renderInputValue = (option) => ( -
- {option.label} -
- ); + const renderInputValue = (option) => ( +
+ {option.label} +
+ ); - return ( - - ); -}; - -export const PortalElement = () => { - const [value, setValue] = useState(); - return ( - <> -
value: {value}
+ return ( - - ); + ); + }, +}; + +export const PortalElement = { + args: { + direction: '', + disabled: Combobox.defaultProps.disabled, + noResultsLabel: Combobox.defaultProps.noResultsLabel, + placeholder: Combobox.defaultProps.placeholder, + inputClassName: '', + }, + render: function Render(args) { + const [value, setValue] = useState(); + return ( + <> +
value: {value}
+ + + ); + }, }; diff --git a/src/components/Datapair/Datapair.stories.js b/src/components/Datapair/Datapair.stories.js index 814ebf313..f05184266 100644 --- a/src/components/Datapair/Datapair.stories.js +++ b/src/components/Datapair/Datapair.stories.js @@ -1,4 +1,3 @@ -import { boolean, select, text } from '@storybook/addon-knobs'; import React from 'react'; import Badge from '../Badge/Badge'; import Button from '../Button/Button'; @@ -14,35 +13,40 @@ export default { }, }; -export const WithProps = () => { - const stacked = boolean('stacked', false); - const labelSize = select('labelSize', ['sm', 'md', 'lg'], 'md'); - return ( - - - - - - - ); +export const WithProps = ({ stacked, labelSize, label, value, feedback, hint }) => ( + + + + + + +); +WithProps.args = { + stacked: false, + labelSize: 'md', + label: 'Key', + value: 'Some simple content would go here', + feedback: undefined, + hint: '', +}; +WithProps.argTypes = { + labelSize: { + options: ['sm', 'md', 'lg'], + control: { type: 'select' }, + }, }; -export const WithHTMLValue = () => ( +export const WithHTMLValue = (args) => ( - + Custom markup ( ); -export const WithNodeInLabel = () => ( +export const WithNodeInLabel = (args) => ( ( } value="Stuff" + {...args} /> diff --git a/src/components/Dropdown/Dropdown.stories.js b/src/components/Dropdown/Dropdown.stories.js index 4c10bf43e..d9aa96a93 100644 --- a/src/components/Dropdown/Dropdown.stories.js +++ b/src/components/Dropdown/Dropdown.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean, select, text } from '@storybook/addon-knobs'; import React from 'react'; import { colors } from '../../tooling/colors'; import Dropdown from './Dropdown'; @@ -8,56 +7,77 @@ import DropdownMenu from './DropdownMenu'; import DropdownToggle from './DropdownToggle'; import UncontrolledDropdown from './UncontrolledDropdown'; -export default { +const meta = { title: 'Dropdown', component: Dropdown, parameters: { sourceLink: 'Dropdown/Dropdown.tsx', }, + argTypes: { + direction: { + options: ['', 'down', 'up', 'left', 'right'], + control: { type: 'select' }, + }, + color: { + options: colors, + control: { type: 'select' }, + }, + size: { + options: ['', 'sm', 'lg'], + control: { type: 'select' }, + }, + }, }; +export default meta; -export const Uncontrolled = () => ( - - - {text('text', 'Click Me')} - - - Action - Another Action - - Header - Disabled Action - - -); +export const Uncontrolled = { + args: { + direction: '', + color: 'primary', + disabled: false, + outline: false, + size: undefined, + text: 'Click Me', + }, + render: ({ direction, color, disabled, outline, size, text }) => ( + + + {text} + + + Action + Another Action + + Header + Disabled Action + + + ), +}; -export const Controlled = () => ( - - - {text('text', 'Click Me')} - - - Action - Another Action - - Header - Disabled Action - - -); +export const Controlled = { + args: { + direction: '', + isOpen: false, + toggle: action('toggle'), + color: 'primary', + disabled: false, + outline: false, + size: undefined, + text: 'Click Me', + }, + render: ({ direction, isOpen, toggle, color, disabled, outline, size, text }) => ( + + + {text} + + + Action + Another Action + + Header + Disabled Action + + + ), +}; diff --git a/src/components/ExpandableSection/ExpandableSection.stories.js b/src/components/ExpandableSection/ExpandableSection.stories.js index 1d776d841..b1ce04be5 100644 --- a/src/components/ExpandableSection/ExpandableSection.stories.js +++ b/src/components/ExpandableSection/ExpandableSection.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean, text } from '@storybook/addon-knobs'; import React from 'react'; import Button from '../Button/Button'; import ExpandableSection from './ExpandableSection'; @@ -12,27 +11,29 @@ export default { }, }; -export const Default = () => ( - +export const Default = (args) => ( +

BOO!

); +Default.args = { + title: 'Click to expand me', + open: ExpandableSection.defaultProps.open, + onToggle: action('onToggle'), +}; -export const Open = () => ( - +export const Open = (args) => ( +

BOO!

); +Open.args = { + title: 'Expanded by default', + open: true, + onToggle: action('onToggle'), +}; -export const Header = () => ( +export const Header = (args) => ( @@ -47,9 +48,12 @@ export const Header = () => ( } - open={boolean('open', true)} - onToggle={action('onToggle')} + {...args} >

BOO!

); +Header.args = { + open: true, + onToggle: action('onToggle'), +}; diff --git a/src/components/Fade/Fade.stories.js b/src/components/Fade/Fade.stories.js index 0ed78d690..8c1dc48dc 100644 --- a/src/components/Fade/Fade.stories.js +++ b/src/components/Fade/Fade.stories.js @@ -10,14 +10,14 @@ export default { }, }; -export const LiveExample = () => { +export const LiveExample = (args) => { const [open, setOpen] = useState(false); return (
- + This content will fade in and out as the button is pressed
diff --git a/src/components/FeatureBanner/FeatureBanner.stories.tsx b/src/components/FeatureBanner/FeatureBanner.stories.tsx index ddacc4b6a..98f17b361 100644 --- a/src/components/FeatureBanner/FeatureBanner.stories.tsx +++ b/src/components/FeatureBanner/FeatureBanner.stories.tsx @@ -1,28 +1,40 @@ -import { select, text } from '@storybook/addon-knobs'; +import { Meta, StoryObj } from '@storybook/react'; import React from 'react'; import { colors } from '../../tooling/colors'; import Button from '../Button/Button'; import Icon from '../Icon/Icon'; import FeatureBanner from './FeatureBanner'; -export default { +const meta: Meta = { title: 'FeatureBanner', component: FeatureBanner, parameters: { sourceLink: 'FeatureBanner/FeatureBanner.tsx', }, + argTypes: { + color: { + options: colors, + control: { type: 'select' }, + }, + }, }; -export const LiveExample = () => ( - - - -); +export default meta; +type Story = StoryObj; + +export const LiveExample: Story = { + args: { + alertText: 'New', + color: 'info', + title: 'Company-Wide View of Text Messages', + subtitle: 'View all text messages sent by your company from this page.', + }, + render: (args) => ( + + + + ), +}; diff --git a/src/components/FeedbackButton/FeedbackButton.spec.tsx b/src/components/FeedbackButton/FeedbackButton.spec.tsx index 33dd6838c..63f26d256 100644 --- a/src/components/FeedbackButton/FeedbackButton.spec.tsx +++ b/src/components/FeedbackButton/FeedbackButton.spec.tsx @@ -28,7 +28,7 @@ describe('', () => { const feedbackModal = await findByRole('dialog'); - const heading = within(feedbackModal).getByRole('heading', { level: 5 }); + const heading = within(feedbackModal).getByRole('heading', { level: 2 }); expect(heading.textContent).toEqual('Give Feedback'); const ratingSubtitle = within(feedbackModal).getByText( @@ -129,7 +129,7 @@ describe('', () => { const feedbackModal = await findByRole('dialog'); - const heading = within(feedbackModal).getByRole('heading', { level: 5 }); + const heading = within(feedbackModal).getByRole('heading', { level: 2 }); expect(heading.textContent).toEqual('Give Feedback2'); const ratingSubtitle = within(feedbackModal).getByText( @@ -217,7 +217,7 @@ describe('', () => { const feedbackModal = await findByRole('dialog'); - const heading = within(feedbackModal).getByRole('heading', { level: 5 }); + const heading = within(feedbackModal).getByRole('heading', { level: 2 }); expect(heading.textContent).toEqual('Give Feedback'); const feedbackModalRating = within(feedbackModal).getByTestId('feedback-modal-rating'); @@ -293,7 +293,7 @@ describe('', () => { const feedbackModal = await findByRole('dialog'); - const heading = within(feedbackModal).getByRole('heading', { level: 5 }); + const heading = within(feedbackModal).getByRole('heading', { level: 2 }); expect(heading.textContent).toEqual('Give Feedback'); within(feedbackModal).getByText('How could we improve the way this works for you?'); @@ -346,7 +346,7 @@ describe('', () => { const feedbackModal = await findByRole('dialog'); - const heading = within(feedbackModal).getByRole('heading', { level: 5 }); + const heading = within(feedbackModal).getByRole('heading', { level: 2 }); expect(heading.textContent).toEqual('Give Feedback'); within(feedbackModal).getByText('How could we improve the way this works for you?'); diff --git a/src/components/FeedbackButton/FeedbackButton.stories.tsx b/src/components/FeedbackButton/FeedbackButton.stories.tsx index 8513b303f..a668321ac 100644 --- a/src/components/FeedbackButton/FeedbackButton.stories.tsx +++ b/src/components/FeedbackButton/FeedbackButton.stories.tsx @@ -1,68 +1,74 @@ import { action } from '@storybook/addon-actions'; -import * as knobs from '@storybook/addon-knobs'; +import { Meta, StoryObj } from '@storybook/react'; import React from 'react'; import { buttonColors } from '../../tooling/colors'; import FeedbackButton from './FeedbackButton'; -export default { +const meta: Meta = { title: 'FeedbackButton', component: FeedbackButton, parameters: { sourceLink: 'FeedbackButton/FeedbackButton.tsx', }, + argTypes: { + color: { + options: buttonColors, + control: { type: 'select' }, + }, + size: { + options: ['lg', 'md', 'sm'], + control: { type: 'inline-radio' }, + }, + }, }; -export const Default = () => ( - { +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + backdrop: false, + className: '', + color: 'default', + disabled: false, + doSubmit: async () => { action('doSubmit'); - }} - feature={knobs.text('feature', 'default')} - modalTitle={knobs.text('modalTitle', 'Modal Title')} - outline={knobs.boolean('outline', false)} - recipient={knobs.text('recipient', 'my_team_name')} - /> -); + }, + feature: 'default', + modalTitle: 'Modal Title', + outline: false, + recipient: 'my_team_name', + }, + render: (args) => , +}; -export const AllProps = () => ( - { +export const AllProps: Story = { + args: { + backdrop: true, + block: true, + cancelButtonText: 'Cancel', + className: '', + color: 'default', + commentIncluded: false, + commentPlaceholder: 'Please give as much detail as you can. Thanks!', + commentRequired: false, + commentSubtitle: 'How could we improve the way this works for you?', + disabled: false, + doSubmit: async () => { action('doSubmit'); - }} - feature={knobs.text('feature', 'default')} - highRatingText={knobs.text('highRatingText', 'Very satisfied')} - lowRatingText={knobs.text('lowRatingText', 'Not satisfied at all')} - modalTitle={knobs.text('modalTitle', 'Give Feedback')} - outline={knobs.boolean('outline', false)} - pleaseWaitButtonText={knobs.text('pleaseWaitButtonText', 'Please Wait...')} - ratingIncluded={knobs.boolean('ratingIncluded', false)} - ratingRequired={knobs.boolean('ratingRequired', false)} - ratingSubtitle={knobs.text( - 'ratingSubtitle', - 'So far, how satisfied are you with this feature?' - )} - recipient={knobs.text('recipient', 'recipient@example.com')} - size={knobs.select('size', ['lg', 'md', 'sm'], 'md')} - submitButtonText={knobs.text('submitButtonText', 'Send')} - /> -); + }, + feature: 'default', + highRatingText: 'Very satisfied', + lowRatingText: 'Not satisfied at all', + modalTitle: 'Give Feedback', + outline: false, + pleaseWaitButtonText: 'Please Wait...', + ratingIncluded: false, + ratingRequired: false, + ratingSubtitle: 'So far, how satisfied are you with this feature?', + recipient: 'recipient@example.com', + size: 'md', + submitButtonText: 'Send', + }, + render: (args) => , +}; diff --git a/src/components/FilterList/FilterList.stories.js b/src/components/FilterList/FilterList.stories.js index 04b32473e..90f10ad0c 100644 --- a/src/components/FilterList/FilterList.stories.js +++ b/src/components/FilterList/FilterList.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { number } from '@storybook/addon-knobs'; import React from 'react'; import FilterList from './FilterList'; @@ -11,7 +10,7 @@ export default { }, }; -export const LiveExample = () => { +export const LiveExample = (args) => { const filters = [ { label: 'User', @@ -29,11 +28,11 @@ export const LiveExample = () => { ]; return (
- action('onRemove', filter)} - /> +
); }; +LiveExample.args = { + maxWidth: 14, + onRemove: action('onRemove'), +}; diff --git a/src/components/Form/Form.stories.js b/src/components/Form/Form.stories.js index ac2ebb679..9a136cfaa 100644 --- a/src/components/Form/Form.stories.js +++ b/src/components/Form/Form.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { object } from '@storybook/addon-knobs'; import React from 'react'; import AddressInput from '../Address/AddressInput'; import CountryInput from '../Address/CountryInput'; @@ -40,9 +39,9 @@ export default { }, }; -export const Inputs = () => ( +export const Inputs = (args) => (
- +

@@ -82,7 +81,7 @@ export const Inputs = () => (

); -export const FloatingLabels = () => ( +export const FloatingLabels = (args) => ( <>

Wrap a pair of <Input> and <Label> components in{' '} @@ -92,7 +91,7 @@ export const FloatingLabels = () => ( Also note that the <Input> must come first so we can utilize a sibling selector (e.g., ~).

-
+ @@ -106,9 +105,9 @@ export const FloatingLabels = () => ( ); -export const FormRows = () => ( +export const FormRows = (args) => ( - + @@ -147,12 +146,8 @@ export const FormRows = () => ( ); -export const Bound = () => ( - +export const Bound = (args) => ( + ( ); +Bound.args = { + errors: { lastName: 'Last Name is required' }, + onSubmit: action('submit'), +}; diff --git a/src/components/Form/FormLabelGroup.stories.js b/src/components/Form/FormLabelGroup.stories.js index cb8da287e..8a6b2b042 100644 --- a/src/components/Form/FormLabelGroup.stories.js +++ b/src/components/Form/FormLabelGroup.stories.js @@ -1,4 +1,3 @@ -import { boolean, object, text, select } from '@storybook/addon-knobs'; import React from 'react'; import Alert from '../Alert/Alert'; import Input from '../Input/Input'; @@ -14,28 +13,35 @@ export default { }, }; -export const LiveExample = () => ( +export const LiveExample = (args) => (
- + Your content here
); +LiveExample.args = { + label: 'Some Input', + labelSize: 'md', + feedback: 'You must give a first name', + validFeedback: undefined, + hint: '', + width: {}, + required: false, + inline: false, + stacked: false, +}; +LiveExample.argTypes = { + labelSize: { + control: { type: 'select' }, + options: ['sm', 'md', 'lg'], + }, +}; -export const RadioExample = () => ( - +export const RadioExample = (args) => ( + diff --git a/src/components/Form/FormRow.stories.js b/src/components/Form/FormRow.stories.js index bf6db33ff..82448d5a7 100644 --- a/src/components/Form/FormRow.stories.js +++ b/src/components/Form/FormRow.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean, object, text, select } from '@storybook/addon-knobs'; import React, { useState } from 'react'; import FormChoice from './FormChoice'; import FormRow from './FormRow'; @@ -12,36 +11,45 @@ export default { }, }; -export const LiveExample = () => ( +export const LiveExample = (args) => (
- +
); +LiveExample.args = { + label: 'First Name', + labelSize: 'md', + feedback: 'You must give a first name', + validFeedback: undefined, + hint: '', + width: {}, + required: false, + inline: false, + onChange: action('onChange'), + stacked: false, + type: 'text', + value: '2', +}; +LiveExample.argTypes = { + labelSize: { + control: { type: 'select' }, + options: ['sm', 'md', 'lg'], + }, + type: { + control: { type: 'select' }, + options: ['checkbox', 'number', 'password', 'radio', 'static', 'text'], + }, +}; -export const WithSelect = () => { +export const WithSelect = (args) => { const [favorite, setFavorite] = useState('Bravo'); return ( setFavorite(e.target.value)} - stacked={boolean('stacked', false)} type="select" value={favorite} + {...args} > Alpha @@ -58,112 +66,85 @@ export const WithSelect = () => { ); }; +LiveExample.args = { + label: 'Favorite NATO Phonetic', + stacked: false, +}; -export const WithCheckboxes = () => { +export const WithCheckboxes = ({ label, stacked, inline }) => { const [favorites, setFavorites] = useState(['Bravo']); return ( setFavorites(selection)} type="checkbox" > - + Alpha - + Bravo - + Charlie - + Delta ); }; +WithCheckboxes.args = { + label: 'Favorite NATO Phonetics', + stacked: false, + inline: false, +}; -export const WithRadioButtons = () => { +export const WithRadioButtons = ({ label, stacked, inline }) => { const [favorite, setFavorite] = useState('Bravo'); return ( setFavorite(e.target.value)} - stacked={boolean('stacked', false)} + stacked={stacked} type="radio" > - + Alpha - + Bravo Charlie - + Delta ); }; +WithRadioButtons.args = { + label: 'Favorite NATO Phonetic', + stacked: false, + inline: false, +}; -export const ControlledValue = () => { +export const ControlledValue = (args) => { const [value, setValue] = React.useState(''); - return ( - setValue(e.target.value)} - stacked={boolean('stacked', false)} - type={text('type', 'text')} - value={value} - /> - ); + return setValue(e.target.value)} value={value} {...args} />; +}; +ControlledValue.args = { + label: 'Label', + stacked: false, + type: 'text', }; diff --git a/src/components/HasManyFields/HasManyFields.stories.js b/src/components/HasManyFields/HasManyFields.stories.js index c05b673f3..18066687f 100644 --- a/src/components/HasManyFields/HasManyFields.stories.js +++ b/src/components/HasManyFields/HasManyFields.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean, number, select, text } from '@storybook/addon-knobs'; import React from 'react'; import AddressInput from '../Address/AddressInput'; import Input from '../Input/Input'; @@ -42,7 +41,7 @@ export default { }, }; -export const LiveExample = () => ( +export const LiveExample = (args) => ( ( countryCode: 'US', }} label="Add an Address" - disabled={boolean('disabled', false)} - onAdd={action('hasManyFields onAdd')} - onRemove={action('hasManyFields onRemove')} - onUpdate={action('hasManyFields onUpdate')} - onChange={action('hasManyFields onChange')} - minimumRows={number('minimumRows', 1)} - maximumRows={number('maximumRows', 5)} - reorderable={boolean('reorderable', false)} + {...args} /> ); +LiveExample.args = { + disabled: false, + onAdd: action('hasManyFields onAdd'), + onRemove: action('hasManyFields onRemove'), + onUpdate: action('hasManyFields onUpdate'), + onChange: action('hasManyFields onChange'), + minimumRows: 1, + maximumRows: 5, + reorderable: false, +}; -export const RowWrapper = () => ( - +export const RowWrapper = (args) => ( + ); +RowWrapper.args = { + onDelete: action('onDelete'), + disabled: false, + disabledReason: undefined, + disabledReasonPlacement: 'top', +}; +RowWrapper.argTypes = { + disabledReasonPlacement: { + control: { type: 'select' }, + options: ['top', 'left', 'bottom', 'right'], + }, +}; -export const AddItemButton = () => ( - Button Label Content +export const AddItemButton = (args) => ( + + Button Label Content + ); diff --git a/src/components/HelpBubble/HelpBubble.stories.js b/src/components/HelpBubble/HelpBubble.stories.js index 05ac105ea..96f3898e4 100644 --- a/src/components/HelpBubble/HelpBubble.stories.js +++ b/src/components/HelpBubble/HelpBubble.stories.js @@ -1,4 +1,3 @@ -import { text, select } from '@storybook/addon-knobs'; import React from 'react'; import HelpBubble from './HelpBubble'; @@ -10,16 +9,12 @@ export default { }, }; -export const LiveExample = () => ( +export const LiveExample = ({ title, placement, content }) => (

I can be placed in context to provide some contextual help! - - {text('content', 'Help bubbles are a handy way of explaining things.')} + + {content}

@@ -30,3 +25,14 @@ export const LiveExample = () => (

); +LiveExample.args = { + title: 'What does this mean?', + placement: 'bottom', + content: 'Help bubbles are a handy way of explaining things.', +}; +LiveExample.argTypes = { + placement: { + control: { type: 'select' }, + options: ['top', 'left', 'bottom', 'right'], + }, +}; diff --git a/src/components/Highlight/Highlight.stories.js b/src/components/Highlight/Highlight.stories.js index b83842c34..2dc91e10d 100644 --- a/src/components/Highlight/Highlight.stories.js +++ b/src/components/Highlight/Highlight.stories.js @@ -1,4 +1,3 @@ -import { text, boolean } from '@storybook/addon-knobs'; import React from 'react'; import Highlight from './Highlight'; @@ -10,22 +9,16 @@ export default { }, }; -export const LiveExample = () => ( - - {text('children', 'The quick brown fox jumps over the lazy dog.')} - -); +export const LiveExample = ({ children, ...args }) => {children}; +LiveExample.args = { + caseSensitive: false, + ignoreSpecial: false, + pattern: 'dog', + children: 'The quick brown fox jumps over the lazy dog.', +}; -export const DOMNodesAsChildren = () => ( - +export const DOMNodesAsChildren = (args) => ( +
The quick brown fox jumps over the lazy dog.
Henlo, I am doge. Gib treatos pls. @@ -33,15 +26,21 @@ export const DOMNodesAsChildren = () => (
); +DOMNodesAsChildren.args = { + caseSensitive: false, + ignoreSpecial: false, + pattern: 'dog', +}; -export const UseRegexAsPattern = () => ( - +export const UseRegexAsPattern = (args) => ( +
The quick brown fox jumps over the lazy dog.
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
); +UseRegexAsPattern.args = { + caseSensitive: false, + ignoreSpecial: false, + escape: false, + pattern: '(fox)|(dog)', +}; diff --git a/src/components/Icon/Icon.stories.js b/src/components/Icon/Icon.stories.js index 443004682..3cd467de9 100644 --- a/src/components/Icon/Icon.stories.js +++ b/src/components/Icon/Icon.stories.js @@ -1,4 +1,3 @@ -import { text, boolean, select } from '@storybook/addon-knobs'; import React from 'react'; import Button from '../Button/Button'; import Icon from './Icon'; @@ -15,46 +14,65 @@ export default { }; // React component for font awesome v6 -export const LiveExample = () => ( - -); +export const LiveExample = (args) => ; +LiveExample.args = { + name: 'motorcycle', + size: '4x', + spin: false, + pulse: false, + rotate: '', + flip: '', + border: false, + iconStyle: 'solid', +}; +LiveExample.argTypes = { + size: { + control: { type: 'select' }, + options: ['', 'xs', 'sm', 'lg', '2x', '3x', '4x', '5x'], + }, + rotate: { + control: { type: 'radio' }, + options: ['', '90', '180', '270'], + }, + flip: { + control: { type: 'radio' }, + options: ['', 'horizontal', 'vertical'], + }, + iconStyle: { + control: { type: 'select' }, + options: ['regular', 'solid', 'thin', 'light', 'duotone', 'brands'], + }, +}; -export const AvailableIcons = () => { - const size = select('size', ['', 'xs', 'sm', 'lg', '2x', '3x', '4x', '5x'], '4x'); - return ( -
- Hover over icon to view name: -
- {icons.map((name, i) => ( - - ))} -
- ); +export const AvailableIcons = ({ size }) => ( +
+ Hover over icon to view name: +
+ {icons.map((name, i) => ( + + ))} +
+); +AvailableIcons.args = { + size: '4x', +}; +AvailableIcons.argTypes = { + size: { + control: { type: 'radio' }, + options: ['', 'xs', 'sm', 'lg', '2x', '3x', '4x', '5x'], + }, }; -export const InlineText = () => ( +export const InlineText = (args) => (

- Print + Print

Add Item @@ -68,11 +86,11 @@ export const InlineText = () => (

); -export const Buttons = () => ( +export const Buttons = (args) => (

@@ -93,9 +111,9 @@ export const Buttons = () => (

); -export const Size = () => ( +export const Size = (args) => (
- xs + xs
sm
@@ -112,9 +130,9 @@ export const Size = () => (
); -export const Animation = () => ( +export const Animation = (args) => (
- + @@ -122,9 +140,9 @@ export const Animation = () => (
); -export const RotateAndFlip = () => ( +export const RotateAndFlip = (args) => (
- 90 + 90
180
@@ -137,10 +155,10 @@ export const RotateAndFlip = () => (
); -export const OtherProps = () => ( +export const OtherProps = (args) => (

- Default + Default

fixedWidth diff --git a/src/components/InfoBox/InfoBox.stories.js b/src/components/InfoBox/InfoBox.stories.js index 54cc6d90c..035215cc1 100644 --- a/src/components/InfoBox/InfoBox.stories.js +++ b/src/components/InfoBox/InfoBox.stories.js @@ -1,4 +1,3 @@ -import { boolean, select, text } from '@storybook/addon-knobs'; import React from 'react'; import { colors } from '../../tooling/colors'; import InfoBox from './InfoBox'; @@ -11,18 +10,26 @@ export default { }, }; -export const LiveExample = () => ( +export const LiveExample = ({ color, title, icon, vertical, children }) => (

(Background color added for contrast)
- - {text('children', 'Jenny, I got your number')} + + {children}
); +LiveExample.args = { + color: 'success', + title: '$86,753.09', + icon: 'check', + vertical: false, + children: 'Jenny, I got your number', +}; +LiveExample.argTypes = { + color: { + control: { type: 'select' }, + options: colors, + }, +}; diff --git a/src/components/Input/CreditCardNumber.stories.js b/src/components/Input/CreditCardNumber.stories.js index 511e78de1..0402b8c50 100644 --- a/src/components/Input/CreditCardNumber.stories.js +++ b/src/components/Input/CreditCardNumber.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { array } from '@storybook/addon-knobs'; import React from 'react'; import uncontrollable from 'uncontrollable'; import CreditCardNumber from './CreditCardNumber'; @@ -18,16 +17,8 @@ export default { }, }; -export const LiveExample = () => ( - -); +export const LiveExample = (args) => ; +LiveExample.args = { + onChange: action('onChange'), + types: ['visa', 'master-card', 'american-express', 'discover', 'diners-club', 'jcb'], +}; diff --git a/src/components/Input/CurrencyInput.stories.js b/src/components/Input/CurrencyInput.stories.js index 9dc0e83d1..a49991f09 100644 --- a/src/components/Input/CurrencyInput.stories.js +++ b/src/components/Input/CurrencyInput.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean } from '@storybook/addon-knobs'; import React from 'react'; import CurrencyInput from './CurrencyInput'; @@ -11,16 +10,18 @@ export default { }, }; -export const Example = () => ( - -); +export const Example = (args) => ; +Example.args = { + onChange: action('onChange'), + allowDecimal: true, + allowNegative: true, + includeThousandsSeparator: true, + padZeros: true, +}; -export const RightAligned = () => ( - +export const RightAligned = (args) => ( + ); +RightAligned.args = { + onChange: action('onChange'), +}; diff --git a/src/components/Input/DateInput.stories.js b/src/components/Input/DateInput.stories.js index aabef8ea0..9042024b6 100644 --- a/src/components/Input/DateInput.stories.js +++ b/src/components/Input/DateInput.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean, text } from '@storybook/addon-knobs'; import classNames from 'classnames'; import React from 'react'; import Calendar from '../Calendar/Calendar'; @@ -16,37 +15,40 @@ export default { }, }; -export const WithProps = () => ( +export const WithProps = (args) => (
- +
); +WithProps.args = { + dateFormat: DateInput.defaultProps.dateFormat, + showOnFocus: DateInput.defaultProps.showOnFocus, + direction: 'down', + disabled: DateInput.defaultProps.disabled, + readOnly: false, + onBlur: action('onBlur'), + onChange: action('onChange'), + onClose: action('onClose'), + positionFixed: false, +}; -export const WithId = () => ( +export const WithId = (args) => (
- +
); +WithId.args = { + dateFormat: DateInput.defaultProps.dateFormat, + showOnFocus: DateInput.defaultProps.showOnFocus, + disabled: DateInput.defaultProps.disabled, + onBlur: action('onBlur'), + onChange: action('onChange'), +}; -export const UncontrolledDefaultValue = () => ( +// declaring any arguments is required to enable displaying code in storybook docs +// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars +export const UncontrolledDefaultValue = (args) => (

When defaultValue is set, component is 'uncontrolled' and maintains its own state. @@ -80,7 +82,9 @@ export const UncontrolledDefaultValue = () => (

); -export const ValueControlled = () => ( +// declaring any arguments is required to enable displaying code in storybook docs +// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars +export const ValueControlled = (args) => (

When value is set, component is 'controlled' and does not maintain its own state. @@ -105,7 +109,7 @@ export const ValueControlled = () => (

); -export const CustomHeaderAndFooter = () => ( +export const CustomHeaderAndFooter = (args) => (
PIRELLI} @@ -118,23 +122,28 @@ export const CustomHeaderAndFooter = () => (
} + {...args} />
); -export const DateEnabled = () => ( +export const DateEnabled = (args) => (
- date.getDay() > 0 && date.getDay() < 6} /> + date.getDay() > 0 && date.getDay() < 6} {...args} />
); -export const CalendarDefault = () => ( +export const CalendarDefault = (args) => (
- +
); +CalendarDefault.args = { + dateFormat: 'D', + onSelect: action('onSelect'), +}; -export const CalendarCustomDay = () => ( +export const CalendarCustomDay = (args) => (
{ @@ -150,6 +159,7 @@ export const CalendarCustomDay = () => ( ); }} + {...args} />
); diff --git a/src/components/Input/MaskedInput.stories.js b/src/components/Input/MaskedInput.stories.js index 6cba12a0d..d0a4966d0 100644 --- a/src/components/Input/MaskedInput.stories.js +++ b/src/components/Input/MaskedInput.stories.js @@ -1,4 +1,3 @@ -import { boolean, text } from '@storybook/addon-knobs'; import React from 'react'; import MaskedInput from './MaskedInput'; @@ -10,13 +9,16 @@ export default { }, }; -export const PhoneNumber = () => ( +export const PhoneNumber = (args) => ( ); +PhoneNumber.args = { + placeholder: '(555) 495-3947', + guide: false, + placeholderChar: undefined, + keepCharPositions: false, + showMask: false, +}; diff --git a/src/components/Input/MonthInput.stories.js b/src/components/Input/MonthInput.stories.js index 4a491190e..d2a4d4783 100644 --- a/src/components/Input/MonthInput.stories.js +++ b/src/components/Input/MonthInput.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean, text } from '@storybook/addon-knobs'; import React from 'react'; import FormRow from '../Form/FormRow'; import Icon from '../Icon/Icon'; @@ -13,25 +12,25 @@ export default { }, }; -export const WithProps = () => ( +export const WithProps = (args) => (
- +
); +WithProps.args = { + centerYearSelection: MonthInput.defaultProps.centerYearSelection, + dateFormat: MonthInput.defaultProps.dateFormat, + monthFormat: MonthInput.defaultProps.monthFormat, + yearFormat: MonthInput.defaultProps.yearFormat, + showOnFocus: MonthInput.defaultProps.showOnFocus, + disabled: MonthInput.defaultProps.disabled, + onBlur: action('onBlur'), + onChange: action('onChange'), +}; -export const DefaultValueUncontrolled = () => ( +// declaring any arguments is required to enable displaying code in storybook docs +// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars +export const DefaultValueUncontrolled = (args) => (

When defaultValue is set, component is 'uncontrolled' and maintains its own state. @@ -65,7 +64,9 @@ export const DefaultValueUncontrolled = () => (

); -export const ValueControlled = () => ( +// declaring any arguments is required to enable displaying code in storybook docs +// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars +export const ValueControlled = (args) => (

When value is set, component is 'uncontrolled' and does not maintain its own state. @@ -95,7 +96,7 @@ export const ValueControlled = () => (

); -export const CustomHeaderAndFooter = () => ( +export const CustomHeaderAndFooter = (args) => (
PIRELLI} @@ -108,6 +109,7 @@ export const CustomHeaderAndFooter = () => (
} + {...args} />
); diff --git a/src/components/Input/PatternInput.stories.js b/src/components/Input/PatternInput.stories.js index ffe27af7b..5110ae9ef 100644 --- a/src/components/Input/PatternInput.stories.js +++ b/src/components/Input/PatternInput.stories.js @@ -1,4 +1,3 @@ -import { text, boolean } from '@storybook/addon-knobs'; import React, { useState } from 'react'; import PatternInput from './PatternInput'; @@ -10,15 +9,18 @@ export default { }, }; -export const LiveExample = () => { +export const LiveExample = ({ pattern, restrictInput }) => { const [value, setValue] = useState(''); - const pattern = text('pattern', '^\\d{0,3}(\\.\\d{0,2})?$'); return ( setValue(e.target.value)} /> ); }; +LiveExample.args = { + pattern: '^\\d{0,3}(\\.\\d{0,2})?$', + restrictInput: true, +}; diff --git a/src/components/Input/TimeInput.stories.js b/src/components/Input/TimeInput.stories.js index 00e5e7765..c8bf704e6 100644 --- a/src/components/Input/TimeInput.stories.js +++ b/src/components/Input/TimeInput.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean, number, text } from '@storybook/addon-knobs'; import React from 'react'; import FormRow from '../Form/FormRow'; import TimeInput from './TimeInput'; @@ -10,24 +9,35 @@ export default { parameters: { sourceLink: 'Input/TimeInput.js', }, + argTypes: { + max: { + control: 'text', + }, + min: { + control: 'text', + }, + }, }; -export const WithProps = () => ( +export const WithProps = (args) => (
- +
); +WithProps.args = { + allowOtherTimes: true, + disabled: false, + max: undefined, + min: undefined, + onChange: action('onChange'), + placeholder: TimeInput.defaultProps.placeholder, + step: TimeInput.defaultProps.step, + timeFormat: TimeInput.defaultProps.timeFormat, +}; -export const DefaultValueUncontrolled = () => ( +// declaring any arguments is required to enable displaying code in storybook docs +// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars +export const DefaultValueUncontrolled = (args) => (

When defaultValue is set, component is 'uncontrolled' and maintains its own state. @@ -44,7 +54,9 @@ export const DefaultValueUncontrolled = () => (

); -export const ValueControlled = () => ( +// declaring any arguments is required to enable displaying code in storybook docs +// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars +export const ValueControlled = (args) => (

When value is set, component is 'controlled' and does not maintain its own state. diff --git a/src/components/InputGroup/InputGroup.stories.js b/src/components/InputGroup/InputGroup.stories.js index c9f6e851b..195c0f6ec 100644 --- a/src/components/InputGroup/InputGroup.stories.js +++ b/src/components/InputGroup/InputGroup.stories.js @@ -12,9 +12,9 @@ export default { }, }; -export const WithProps = () => ( +export const WithProps = (args) => (

- + @ @@ -47,9 +47,9 @@ export const WithProps = () => (
); -export const Addons = () => ( +export const Addons = (args) => (
- + To the Left! @@ -67,9 +67,9 @@ export const Addons = () => (
); -export const AddonSizing = () => ( +export const AddonSizing = (args) => (
- + @lg @@ -86,9 +86,9 @@ export const AddonSizing = () => (
); -export const ButtonShorthand = () => ( +export const ButtonShorthand = (args) => (
- + @@ -106,8 +106,8 @@ export const ButtonShorthand = () => (
); -export const MultipleInputs = () => ( - +export const MultipleInputs = (args) => ( + diff --git a/src/components/LabelBadge/LabelBadge.stories.js b/src/components/LabelBadge/LabelBadge.stories.js index f3d797a65..7dd1c6755 100644 --- a/src/components/LabelBadge/LabelBadge.stories.js +++ b/src/components/LabelBadge/LabelBadge.stories.js @@ -1,5 +1,4 @@ import { action } from '@storybook/addon-actions'; -import { boolean, number, text } from '@storybook/addon-knobs'; import React from 'react'; import LabelBadge from './LabelBadge'; @@ -11,14 +10,15 @@ export default { }, }; -export const LiveExample = () => ( +export const LiveExample = (args) => (
- action('onRemove')} - /> +
); +LiveExample.args = { + label: 'User', + value: 'Mischa Lewis Norelle', + removable: true, + maxWidth: 20, + onRemove: action('onRemove'), +}; diff --git a/src/components/Layout/Layout.stories.js b/src/components/Layout/Layout.stories.js index 580a7e19b..3151d005f 100644 --- a/src/components/Layout/Layout.stories.js +++ b/src/components/Layout/Layout.stories.js @@ -1,4 +1,3 @@ -import { select } from '@storybook/addon-knobs'; import React from 'react'; import Col from './Col'; import Container from './Container'; @@ -11,7 +10,9 @@ export default { }, }; -export const Grid = () => ( +// declaring any arguments is required to enable displaying code in storybook docs +// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars +export const Default = (args) => ( 1 @@ -78,7 +79,9 @@ export const Grid = () => ( ); -export const Offsets = () => ( +// declaring any arguments is required to enable displaying code in storybook docs +// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars +export const Offsets = (args) => (