Skip to content

Commit

Permalink
docs(tabs): add example code snippet using renderContent to story
Browse files Browse the repository at this point in the history
  • Loading branch information
jendowns committed Feb 4, 2020
1 parent 1526db5 commit cfdba7b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
37 changes: 35 additions & 2 deletions packages/react/src/components/Tabs/Tabs-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { withKnobs, boolean, number, text } from '@storybook/addon-knobs';
import { settings } from 'carbon-components';
import classNames from 'classnames';
import './Tabs-story.scss';
import CodeSnippet from '../CodeSnippet';
import Tabs from '../Tabs';
import Tab from '../Tab';
import TabsSkeleton from '../Tabs/Tabs.Skeleton';
Expand Down Expand Up @@ -51,6 +52,32 @@ const props = {

const CustomLabel = ({ text }) => <>{text}</>;

const CodeSnippetExample = () => (
<CodeSnippet type="multi">
{`@mixin grid-container {
width: 100%;
padding-right: padding(mobile);
padding-left: padding(mobile);
@include breakpoint(bp--xs--major) {
padding-right: padding(xs);
padding-left: padding(xs);
}
}
$z-indexes: (
modal : 9000,
overlay : 8000,
dropdown : 7000,
header : 6000,
footer : 5000,
hidden : - 1,
overflowHidden: - 1,
floating: 10000
);`}
</CodeSnippet>
);

const TabContentRenderedOnlyWhenSelected = ({
selected,
children,
Expand Down Expand Up @@ -88,7 +115,10 @@ storiesOf('Tabs', module)
{...props.tab()}
label="Tab label 4"
renderContent={TabContentRenderedOnlyWhenSelected}>
<div className="some-content">Content for fourth tab goes here.</div>
<div className="some-content">
<p>Content for fourth tab goes here.</p>
<CodeSnippetExample />
</div>
</Tab>
<Tab
id="tab-5"
Expand Down Expand Up @@ -122,7 +152,10 @@ storiesOf('Tabs', module)
{...props.tab()}
label="Tab label 3"
renderContent={TabContentRenderedOnlyWhenSelected}>
<div className="some-content">Content for third tab goes here.</div>
<div className="some-content">
<p>Content for third tab goes here.</p>
<CodeSnippetExample />
</div>
</Tab>
<Tab
id="tab-4"
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Tabs/Tabs-story.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ $css--reset: false;
@import '~carbon-components/src/globals/scss/css--helpers';

.bx--tabs--container ~ div {
height: 320px;
min-height: 320px;
background-color: $ui-01;
}

0 comments on commit cfdba7b

Please sign in to comment.