Skip to content

Commit

Permalink
docs(storybook): regroup components
Browse files Browse the repository at this point in the history
  • Loading branch information
tw15egan committed Feb 24, 2021
1 parent 25d6cdb commit e65f137
Show file tree
Hide file tree
Showing 68 changed files with 119 additions and 81 deletions.
3 changes: 2 additions & 1 deletion packages/react/.storybook/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import './polyfills';

import React, { useEffect } from 'react';

function Container({ story }) {
function Container({ story, id }) {
useEffect(() => {
const originalDirection = document.documentElement.dir;
if (process.env.CARBON_REACT_STORYBOOK_USE_RTL === 'true') {
Expand All @@ -28,6 +28,7 @@ function Container({ story }) {
return (
<React.StrictMode>
<div
className={id.toLowerCase()}
data-floating-menu-container
role="main"
style={{
Expand Down
24 changes: 24 additions & 0 deletions packages/react/.storybook/Welcome/Welcome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import bg from './carbon_bg.png';
import './welcome.scss';
import PackageInfo from './../../package.json';

export const Welcome = () => {
return (
<div
className="welcome__container"
style={{
background: `url(${bg}) no-repeat center center fixed`,
backgroundSize: 'cover',
}}>
<h2 className="welcome__heading">Carbon Components</h2>
<h4 className="welcome__heading welcome__heading--subtitle">{`React v${PackageInfo.version}`}</h4>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import React from 'react';
import { Welcome as Intro } from './Welcome';

export default {
title: ' Welcome',
title: ' Getting Started/ Welcome',
component: Intro,
};

Expand Down
22 changes: 22 additions & 0 deletions packages/react/.storybook/Welcome/welcome.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@import '~carbon-components/scss/globals/scss/typography';

.container-welcome {
/* stylelint-disable-next-line declaration-no-important */
padding: 0 !important;
}

.welcome__container {
width: 100vw;
height: 100vh;
padding: 3rem;
}

.welcome__heading {
@include type-style('productive-heading-07');

color: $inverse-01;
}

.welcome__heading--subtitle {
font-weight: 600;
}
12 changes: 0 additions & 12 deletions packages/react/.storybook/WelcomePage/Welcome.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/react/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
module.exports = {
addons: ['storybook-preset-carbon'],
stories: [
'./WelcomePage/Welcome-story.js',
'./Welcome/Welcome.stories.js',
'../src/**/*-story.js',
'../src/**/*.stories.mdx',
],
Expand Down
9 changes: 6 additions & 3 deletions packages/react/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const customPropertyPrefix = 'cds';
addParameters({
options: {
theme: carbonTheme,
showRoots: true,
/**
* We sort our stories by default alphabetically, however there are specific
* keywords that will be sorted further down the sidebar, including
Expand Down Expand Up @@ -68,8 +69,6 @@ addParameters({
if (idB.includes(keyword)) {
matches.set(idB, weight);
}

console.log(idA);
}

// If we have matches for either id, then we will compare the ids based on
Expand Down Expand Up @@ -97,7 +96,11 @@ configureActions({
limit: 10,
});

addDecorator((story) => <Container story={story} />);
addDecorator((story, i) => {
return (
<Container id={`container-${story().type?.displayName}`} story={story} />
);
});

addons.getChannel().on(CARBON_CURRENT_THEME, (theme) => {
document.documentElement.setAttribute('storybook-carbon-theme', theme);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { AspectRatio } from './';
import mdx from './AspectRatio.mdx';

export default {
title: 'AspectRatio',
title: 'Components/AspectRatio',
component: AspectRatio,
decorators: [
withKnobs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Breadcrumb, BreadcrumbItem, BreadcrumbSkeleton } from '../Breadcrumb';
import mdx from './Breadcrumb.mdx';

export default {
title: 'Breadcrumb',
title: 'Components/Breadcrumb',
component: Breadcrumb,
subcomponents: {
BreadcrumbItem,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Button/Button-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const props = {
};

export default {
title: 'Button',
title: 'Components/Button',
decorators: [withKnobs],
parameters: {
component: Button,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Checkbox/Checkbox-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import mdx from './Checkbox.mdx';
const { prefix } = settings;

export default {
title: 'Checkbox',
title: 'Components/Checkbox',
component: Checkbox,
subcomponents: {
CheckboxSkeleton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import CodeSnippetSkeleton from './CodeSnippet.Skeleton';
import mdx from './CodeSnippet.mdx';

export default {
title: 'CodeSnippet',
title: 'Components/CodeSnippet',
component: CodeSnippet,
decorators: [withKnobs],
parameters: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/ComboBox/ComboBox-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const directions = {
};

export default {
title: 'ComboBox',
title: 'Components/ComboBox',
component: ComboBox,
parameters: {
docs: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const scrollingContent = (
);

export default {
title: 'ComposedModal',
title: 'Components/ComposedModal',
decorators: [withKnobs],
parameters: {
component: ComposedModal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const props = {
};

export default {
title: 'ContentSwitcher',
title: 'Components/ContentSwitcher',
decorators: [withKnobs],

parameters: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const props = () => ({
});

export default {
title: 'CopyButton',
title: 'Components/CopyButton',
decorators: [withKnobs],

parameters: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { rows, headers } from './shared';
import mdx from '../DataTable.mdx';

export default {
title: 'DataTable/Filtering',
title: 'Components/DataTable/Filtering',
component: DataTable,
subcomponents: {
TableToolbar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { rows, headers } from './shared';
import mdx from '../DataTable.mdx';

export default {
title: 'DataTable/Selection',
title: 'Components/DataTable/Selection',
component: DataTable,
subcomponents: {
TableSelectAll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { rows, headers } from './shared';
import mdx from '../DataTable.mdx';

export default {
title: 'DataTable/Sorting',
title: 'Components/DataTable/Sorting',
component: DataTable,
subcomponents: {
Table,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import DataTable, {
import { batchActionClick, rows, headers } from '../shared';

export default {
title: 'DataTable/Development',
title: 'Components/DataTable/Development',
};

export const Example = (props) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { rows, headers } from '../shared';
import mdx from '../../DataTable.mdx';

export default {
title: 'DataTable/Expansion',
title: 'Components/DataTable/Expansion',
component: DataTable,
subcomponents: {
TableExpandHeader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ const props = () => ({
});

export default {
title: 'DataTableSkeleton',
title: 'Components/DataTable',
decorators: [withKnobs],

parameters: {
component: DataTableSkeleton,
},
};

export const Default = () => (
export const Skeleton = () => (
<div style={{ width: '800px' }}>
<DataTableSkeleton {...props()} />
<br />
</div>
);

Default.storyName = 'default';
Skeleton.storyName = 'default';

Default.parameters = {
Skeleton.parameters = {
info: {
text: `
Skeleton states are used as a progressive loading state while the user waits for content to load.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const props = {
};

export default {
title: 'DatePicker',
title: 'Components/DatePicker',
decorators: [withKnobs],

parameters: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Dropdown/Dropdown-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const props = () => ({
});

export default {
title: 'Dropdown',
title: 'Components/Dropdown',
decorators: [withKnobs],

parameters: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ErrorBoundary, ErrorBoundaryContext } from './';
import Button from '../Button';

export default {
title: 'ErrorBoundary',
title: 'Components/ErrorBoundary',

parameters: {
component: ErrorBoundary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const props = {
};

export default {
title: 'FileUploader',
title: 'Components/FileUploader',
decorators: [withKnobs],

parameters: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/FluidForm/FluidForm-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const InvalidPasswordProps = {
};

export default {
title: 'FluidForm',
title: 'Experimental/FluidForm',
decorators: [withKnobs],

parameters: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Form/Form-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const buttonEvents = {
RadioButton.displayName = 'RadioButton';

export default {
title: 'Form',
title: 'Components/Form',
decorators: [withKnobs],

parameters: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/FormLabel/FormLabel-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Tooltip from '../Tooltip';
import mdx from './FormLabel.mdx';

export default {
title: 'FormLabel',
title: 'Components/FormLabel',

parameters: {
component: FormLabel,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Grid/Grid-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Grid, Row, Column } from './';
import mdx from './Grid.mdx';

export default {
title: 'Grid',
title: 'Components/Grid',
component: Grid,
subcomponents: {
Row,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Icon/Icon-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const propsSkeleton2 = {
};

export default {
title: 'Icon',
title: 'Deprecated/Icon',
decorators: [withKnobs],

parameters: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const props = () => ({
});

export default {
title: 'InlineLoading',
title: 'Components/InlineLoading',
decorators: [withKnobs],

parameters: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Link/Link-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const props = () => ({
});

export default {
title: 'Link',
title: 'Components/Link',
decorators: [withKnobs],

parameters: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Loading/Loading-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const props = () => ({
});

export default {
title: 'Loading',
title: 'Components/Loading',
decorators: [withKnobs],

parameters: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Modal/Modal-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const props = {
};

export default {
title: 'Modal',
title: 'Components/Modal',
decorators: [withKnobs],
parameters: {
component: Modal,
Expand Down
Loading

0 comments on commit e65f137

Please sign in to comment.