From b677f5425222c345f439007348a6583591854682 Mon Sep 17 00:00:00 2001 From: Alessandra Davila Date: Mon, 18 Oct 2021 09:30:59 -0500 Subject: [PATCH] feat(carbon-react): add layer stories (#9861) --- .../CodeSnippet/CodeSnippet.stories.js | 148 ++++++++++++++++++ .../components/ComboBox/ComboBox.stories.js | 37 +++++ .../ContentSwitcher.stories.js | 27 ++++ .../DatePicker/DatePicker.stories.js | 112 +++++++++++++ .../components/Dropdown/Dropdown.stories.js | 67 ++++++++ .../MultiSelect/MultiSelect.stories.js | 77 +++++++++ .../NumberInput/NumberInput.stories.js | 15 ++ .../Overflow/OverflowMenu.stories.js | 33 ++++ .../src/components/Search/Search.stories.js | 74 +++++++++ .../src/components/Slider/Slider.stories.js | 87 ++++++++++ .../src/components/Tabs/Tabs.stories.js | 75 +++++++++ 11 files changed, 752 insertions(+) diff --git a/packages/carbon-react/src/components/CodeSnippet/CodeSnippet.stories.js b/packages/carbon-react/src/components/CodeSnippet/CodeSnippet.stories.js index 864b1f06ac02..8b6a05b3f7ae 100644 --- a/packages/carbon-react/src/components/CodeSnippet/CodeSnippet.stories.js +++ b/packages/carbon-react/src/components/CodeSnippet/CodeSnippet.stories.js @@ -7,6 +7,7 @@ import React from 'react'; import { CodeSnippet, CodeSnippetSkeleton } from 'carbon-components-react'; +import { Layer } from '../Layer'; export default { title: 'Components/CodeSnippet', @@ -60,6 +61,153 @@ export const singleline = () => ( ); +export const inlineWithLayer = () => { + return ( + <> + + {'node -v'} + + + + {'node -v'} + + + + {'node -v'} + + + + + ); +}; + +export const multilineWithLayer = () => { + return ( + <> + + {` "scripts": { + "build": "lerna run build --stream --prefix --npm-client yarn", + "ci-check": "carbon-cli ci-check", + "clean": "lerna run clean && lerna clean --yes && rimraf node_modules", + "doctoc": "doctoc --title '## Table of Contents'", + "format": "prettier --write '**/*.{js,md,scss,ts}' '!**/{build,es,lib,storybook,ts,umd}/**'", + "format:diff": "prettier --list-different '**/*.{js,md,scss,ts}' '!**/{build,es,lib,storybook,ts,umd}/**' '!packages/components/**'", + "lint": "eslint actions config codemods packages", + "lint:styles": "stylelint '**/*.{css,scss}' --report-needless-disables --report-invalid-scope-disables", + "sync": "carbon-cli sync", + "test": "cross-env BABEL_ENV=test jest", + "test:e2e": "cross-env BABEL_ENV=test jest --testPathPattern=e2e --testPathIgnorePatterns='examples,/packages/components/,/packages/react/'" + }, + "resolutions": { + "react": "~16.9.0", + "react-dom": "~16.9.0", + "react-is": "~16.9.0", + "react-test-renderer": "~16.9.0" + }, + "devDependencies": { + "@babel/core": "^7.10.0", + "@babel/plugin-proposal-class-properties": "^7.7.4", + "@babel/plugin-proposal-export-default-from": "^7.7.4", + "@babel/plugin-proposal-export-namespace-from": "^7.7.4", + "@babel/plugin-transform-runtime": "^7.10.0", + "@babel/preset-env": "^7.10.0", + "@babel/preset-react": "^7.10.0", + "@babel/runtime": "^7.10.0", + "@commitlint/cli": "^8.3.5",`} + + + + {` "scripts": { + "build": "lerna run build --stream --prefix --npm-client yarn", + "ci-check": "carbon-cli ci-check", + "clean": "lerna run clean && lerna clean --yes && rimraf node_modules", + "doctoc": "doctoc --title '## Table of Contents'", + "format": "prettier --write '**/*.{js,md,scss,ts}' '!**/{build,es,lib,storybook,ts,umd}/**'", + "format:diff": "prettier --list-different '**/*.{js,md,scss,ts}' '!**/{build,es,lib,storybook,ts,umd}/**' '!packages/components/**'", + "lint": "eslint actions config codemods packages", + "lint:styles": "stylelint '**/*.{css,scss}' --report-needless-disables --report-invalid-scope-disables", + "sync": "carbon-cli sync", + "test": "cross-env BABEL_ENV=test jest", + "test:e2e": "cross-env BABEL_ENV=test jest --testPathPattern=e2e --testPathIgnorePatterns='examples,/packages/components/,/packages/react/'" + }, + "resolutions": { + "react": "~16.9.0", + "react-dom": "~16.9.0", + "react-is": "~16.9.0", + "react-test-renderer": "~16.9.0" + }, + "devDependencies": { + "@babel/core": "^7.10.0", + "@babel/plugin-proposal-class-properties": "^7.7.4", + "@babel/plugin-proposal-export-default-from": "^7.7.4", + "@babel/plugin-proposal-export-namespace-from": "^7.7.4", + "@babel/plugin-transform-runtime": "^7.10.0", + "@babel/preset-env": "^7.10.0", + "@babel/preset-react": "^7.10.0", + "@babel/runtime": "^7.10.0", + "@commitlint/cli": "^8.3.5",`} + + + + {` "scripts": { + "build": "lerna run build --stream --prefix --npm-client yarn", + "ci-check": "carbon-cli ci-check", + "clean": "lerna run clean && lerna clean --yes && rimraf node_modules", + "doctoc": "doctoc --title '## Table of Contents'", + "format": "prettier --write '**/*.{js,md,scss,ts}' '!**/{build,es,lib,storybook,ts,umd}/**'", + "format:diff": "prettier --list-different '**/*.{js,md,scss,ts}' '!**/{build,es,lib,storybook,ts,umd}/**' '!packages/components/**'", + "lint": "eslint actions config codemods packages", + "lint:styles": "stylelint '**/*.{css,scss}' --report-needless-disables --report-invalid-scope-disables", + "sync": "carbon-cli sync", + "test": "cross-env BABEL_ENV=test jest", + "test:e2e": "cross-env BABEL_ENV=test jest --testPathPattern=e2e --testPathIgnorePatterns='examples,/packages/components/,/packages/react/'" + }, + "resolutions": { + "react": "~16.9.0", + "react-dom": "~16.9.0", + "react-is": "~16.9.0", + "react-test-renderer": "~16.9.0" + }, + "devDependencies": { + "@babel/core": "^7.10.0", + "@babel/plugin-proposal-class-properties": "^7.7.4", + "@babel/plugin-proposal-export-default-from": "^7.7.4", + "@babel/plugin-proposal-export-namespace-from": "^7.7.4", + "@babel/plugin-transform-runtime": "^7.10.0", + "@babel/preset-env": "^7.10.0", + "@babel/preset-react": "^7.10.0", + "@babel/runtime": "^7.10.0", + "@commitlint/cli": "^8.3.5",`} + + + + + ); +}; + +export const singlelineWithLayer = () => { + return ( + <> + + yarn add carbon-components@latest carbon-components-react@latest + @carbon/icons-react@latest carbon-icons@latest + + + + yarn add carbon-components@latest carbon-components-react@latest + @carbon/icons-react@latest carbon-icons@latest + + + + yarn add carbon-components@latest carbon-components-react@latest + @carbon/icons-react@latest carbon-icons@latest + + + + + ); +}; + export const skeleton = () => (
diff --git a/packages/carbon-react/src/components/ComboBox/ComboBox.stories.js b/packages/carbon-react/src/components/ComboBox/ComboBox.stories.js index 0b997e2db9d7..5203768c6986 100644 --- a/packages/carbon-react/src/components/ComboBox/ComboBox.stories.js +++ b/packages/carbon-react/src/components/ComboBox/ComboBox.stories.js @@ -7,6 +7,7 @@ import React from 'react'; import { ComboBox } from 'carbon-components-react'; +import { Layer } from '../Layer'; const items = [ { @@ -54,3 +55,39 @@ export const Combobox = () => ( />
); + +export const withLayer = () => ( +
+ {}} + id="carbon-combobox" + items={items} + itemToString={(item) => (item ? item.text : '')} + placeholder="Filter..." + titleText="First Layer" + helperText="Combobox helper text" + /> + + {}} + id="carbon-combobox" + items={items} + itemToString={(item) => (item ? item.text : '')} + placeholder="Filter..." + titleText="Second Layer" + helperText="Combobox helper text" + /> + + {}} + id="carbon-combobox" + items={items} + itemToString={(item) => (item ? item.text : '')} + placeholder="Filter..." + titleText="Third Layer" + helperText="Combobox helper text" + /> + + +
+); diff --git a/packages/carbon-react/src/components/ContentSwitcher/ContentSwitcher.stories.js b/packages/carbon-react/src/components/ContentSwitcher/ContentSwitcher.stories.js index efdeef12bb1b..82daf616a49a 100644 --- a/packages/carbon-react/src/components/ContentSwitcher/ContentSwitcher.stories.js +++ b/packages/carbon-react/src/components/ContentSwitcher/ContentSwitcher.stories.js @@ -7,6 +7,7 @@ import React from 'react'; import { ContentSwitcher, Switch } from 'carbon-components-react'; +import { Layer } from '../Layer'; export default { title: 'Components/ContentSwitcher', @@ -27,3 +28,29 @@ export const Default = () => ( ); + +export const withLayer = () => { + return ( + <> + {}}> + + + + + + {}}> + + + + + + {}}> + + + + + + + + ); +}; diff --git a/packages/carbon-react/src/components/DatePicker/DatePicker.stories.js b/packages/carbon-react/src/components/DatePicker/DatePicker.stories.js index c82738966093..bfb80349c536 100644 --- a/packages/carbon-react/src/components/DatePicker/DatePicker.stories.js +++ b/packages/carbon-react/src/components/DatePicker/DatePicker.stories.js @@ -12,6 +12,7 @@ import { DatePickerInput, DatePickerSkeleton, } from 'carbon-components-react'; +import { Layer } from '../Layer'; // const patterns = { // 'Short (d{1,2}/d{4})': '\\d{1,2}/\\d{4}', @@ -108,6 +109,117 @@ export const RangeWithCalendar = () => { ); }; +export const SimpleWithLayer = () => { + return ( + <> + + + + + + + + + + + + + + + ); +}; + +export const SingleWithCalendarWithLayer = () => { + return ( + <> + + + + + + + + + + + + + + + ); +}; + +export const RangeWithCalendarWithLayer = () => { + return ( + <> + + + + + + + + + + + + + + + + + + ); +}; + /* eslint-disable react/prop-types */ export const DatePickerPlayground = () => ( diff --git a/packages/carbon-react/src/components/Dropdown/Dropdown.stories.js b/packages/carbon-react/src/components/Dropdown/Dropdown.stories.js index 06fb5251c320..92ae3ab55f0d 100644 --- a/packages/carbon-react/src/components/Dropdown/Dropdown.stories.js +++ b/packages/carbon-react/src/components/Dropdown/Dropdown.stories.js @@ -7,6 +7,7 @@ import React from 'react'; import { Dropdown, DropdownSkeleton } from 'carbon-components-react'; +import { Layer } from '../Layer'; const items = [ { @@ -73,6 +74,72 @@ export const Inline = () => ( ); +export const withLayer = () => ( +
+ (item ? item.text : '')} + /> + + (item ? item.text : '')} + /> + + (item ? item.text : '')} + /> + + +
+); + +export const InlineWithLayer = () => ( +
+ (item ? item.text : '')} + /> + + (item ? item.text : '')} + /> + + (item ? item.text : '')} + /> + + +
+); + export const Skeleton = () => (
diff --git a/packages/carbon-react/src/components/MultiSelect/MultiSelect.stories.js b/packages/carbon-react/src/components/MultiSelect/MultiSelect.stories.js index 70b0afc23cb2..ee8df2d982fd 100644 --- a/packages/carbon-react/src/components/MultiSelect/MultiSelect.stories.js +++ b/packages/carbon-react/src/components/MultiSelect/MultiSelect.stories.js @@ -7,6 +7,7 @@ import React from 'react'; import { MultiSelect } from 'carbon-components-react'; +import { Layer } from '../Layer'; const items = [ { @@ -94,3 +95,79 @@ export const _Filterable = () => {
); }; + +export const withLayer = () => { + return ( +
+ (item ? item.text : '')} + selectionFeedback="top-after-reopen" + /> + + (item ? item.text : '')} + selectionFeedback="top-after-reopen" + /> + + (item ? item.text : '')} + selectionFeedback="top-after-reopen" + /> + + +
+ ); +}; + +export const _FilterableWithLayer = () => { + return ( +
+ (item ? item.text : '')} + placeholder="Filter" + selectionFeedback="top-after-reopen" + /> + + (item ? item.text : '')} + placeholder="Filter" + selectionFeedback="top-after-reopen" + /> + + (item ? item.text : '')} + placeholder="Filter" + selectionFeedback="top-after-reopen" + /> + + +
+ ); +}; diff --git a/packages/carbon-react/src/components/NumberInput/NumberInput.stories.js b/packages/carbon-react/src/components/NumberInput/NumberInput.stories.js index b403c8622861..8109f350e78a 100644 --- a/packages/carbon-react/src/components/NumberInput/NumberInput.stories.js +++ b/packages/carbon-react/src/components/NumberInput/NumberInput.stories.js @@ -7,6 +7,7 @@ import React from 'react'; import { NumberInput, NumberInputSkeleton } from 'carbon-components-react'; +import { Layer } from '../Layer'; export default { title: 'Components/NumberInput', @@ -33,6 +34,20 @@ export const Default = () => { return ; }; +export const withLayer = () => { + return ( + <> + + + + + + + + + ); +}; + export const Skeleton = () => (
diff --git a/packages/carbon-react/src/components/Overflow/OverflowMenu.stories.js b/packages/carbon-react/src/components/Overflow/OverflowMenu.stories.js index 53d22796348d..b0b46cbf9538 100644 --- a/packages/carbon-react/src/components/Overflow/OverflowMenu.stories.js +++ b/packages/carbon-react/src/components/Overflow/OverflowMenu.stories.js @@ -7,6 +7,7 @@ import { OverflowMenu, OverflowMenuItem } from 'carbon-components-react'; import React from 'react'; +import { Layer } from '../Layer'; export default { title: 'Components/OverflowMenu', @@ -23,3 +24,35 @@ export const Default = () => { ); }; + +export const withLayer = () => { + return ( + <> + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; diff --git a/packages/carbon-react/src/components/Search/Search.stories.js b/packages/carbon-react/src/components/Search/Search.stories.js index aca667e6aa2e..a99ab03d57d0 100644 --- a/packages/carbon-react/src/components/Search/Search.stories.js +++ b/packages/carbon-react/src/components/Search/Search.stories.js @@ -7,6 +7,7 @@ import { Search, ExpandableSearch } from 'carbon-components-react'; import React from 'react'; +import { Layer } from '../Layer'; export default { title: 'Components/Search' }; @@ -32,3 +33,76 @@ export const Expandable = () => ( onKeyDown={() => {}} /> ); + +export const withLayer = () => { + return ( + <> + {}} + onKeyDown={() => {}} + /> + + {}} + onKeyDown={() => {}} + /> + + {}} + onKeyDown={() => {}} + /> + + + + ); +}; + +export const ExpandableWithLayer = () => { + return ( + <> + {}} + onKeyDown={() => {}} + /> + + {}} + onKeyDown={() => {}} + /> + + {}} + onKeyDown={() => {}} + /> + + + + ); +}; diff --git a/packages/carbon-react/src/components/Slider/Slider.stories.js b/packages/carbon-react/src/components/Slider/Slider.stories.js index b968c3d39bc5..802a63d55843 100644 --- a/packages/carbon-react/src/components/Slider/Slider.stories.js +++ b/packages/carbon-react/src/components/Slider/Slider.stories.js @@ -11,6 +11,7 @@ import React, { useState } from 'react'; // import { withKnobs, boolean, number, text } from '@storybook/addon-knobs'; import { Slider, SliderSkeleton } from '.'; // import { sliderValuePropSync } from '../../../../react/src/internal/FeatureFlags'; +import { Layer } from '../Layer'; import mdx from './Slider.mdx'; export default { @@ -63,4 +64,90 @@ export const ControlledSlider = () => { ); }; +export const withLayer = () => { + return ( + <> + + + + + + + + + ); +}; + +export const ControlledSliderWithLayer = () => { + const [val, setVal] = useState(87); + return ( + <> + + setVal(value)} + /> +

{val}

+ + + setVal(value)} + /> +

{val}

+ + + setVal(value)} + /> +

{val}

+
+
+ + ); +}; + export const Skeleton = () => ; diff --git a/packages/carbon-react/src/components/Tabs/Tabs.stories.js b/packages/carbon-react/src/components/Tabs/Tabs.stories.js index 08482fdb9108..1c04f224b089 100644 --- a/packages/carbon-react/src/components/Tabs/Tabs.stories.js +++ b/packages/carbon-react/src/components/Tabs/Tabs.stories.js @@ -7,6 +7,7 @@ import React from 'react'; import { Button, Tab, Tabs, TabsSkeleton } from '../Tabs'; +import { Layer } from '../Layer'; export default { title: 'Components/Tabs', @@ -42,3 +43,77 @@ export const Default = () => ( ); + +export const withLayer = () => { + return ( + <> + + +

First Layer. Content for first tab goes here.

+
+ +

Content for second tab goes here.

+ +
+ +

Content for third tab goes here.

+
+ +

Content for fourth tab goes here.

+
+ Custom Label
}> +

Content for fifth tab goes here.

+ + + + + +

Second Layer. Content for first tab goes here.

+
+ +

Content for second tab goes here.

+ +
+ +

Content for third tab goes here.

+
+ +

Content for fourth tab goes here.

+
+ Custom Label}> +

Content for fifth tab goes here.

+
+
+ + + +

Third Layer. Content for first tab goes here.

+
+ +

Content for second tab goes here.

+ +
+ +

Content for third tab goes here.

+
+ +

Content for fourth tab goes here.

+
+ Custom Label}> +

Content for fifth tab goes here.

+
+
+
+
+ + ); +};