Skip to content

Commit

Permalink
docs(react): update grid docs
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblack committed Aug 26, 2020
1 parent 92992ef commit 49d9258
Show file tree
Hide file tree
Showing 5 changed files with 347 additions and 25 deletions.
3 changes: 2 additions & 1 deletion packages/react/src/components/Grid/Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ function getClassNameForBreakpoints(breakpoints) {

for (let i = 0; i < breakpoints.length; i++) {
const breakpoint = breakpoints[i];
if (!breakpoint) {
if (breakpoint === undefined || breakpoint === null) {
continue;
}

console.log(breakpoint);
const name = breakpointNames[i];

// If our breakpoint is a boolean, the user has specified that the column
Expand Down
102 changes: 82 additions & 20 deletions packages/react/src/components/Grid/Grid-story.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './Grid-story.scss';
import React from 'react';
import { Grid, Row, Column } from './';
import mdx from './Grid.mdx';

export default {
title: 'Grid',
Expand All @@ -9,7 +10,12 @@ export default {
Row,
Column,
},
decorators: [(storyFn) => <div id="templates">{storyFn()}</div>],
decorators: [storyFn => <div id="templates">{storyFn()}</div>],
parameters: {
docs: {
page: mdx,
},
},
};

function DemoContent({ children }) {
Expand All @@ -24,16 +30,16 @@ export const autoColumns = () => (
<Grid>
<Row>
<Column>
<DemoContent>1/4</DemoContent>
<DemoContent>Span 25%</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
<DemoContent>Span 25%</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
<DemoContent>Span 25%</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
<DemoContent>Span 25%</DemoContent>
</Column>
</Row>
</Grid>
Expand All @@ -42,17 +48,26 @@ export const autoColumns = () => (
export const responsiveGrid = () => (
<Grid>
<Row>
<Column sm={1} md={4} lg={8}>
<DemoContent>sm: 1/4, md: 1/2, lg: 2/3</DemoContent>
</Column>
<Column sm={1} md={2} lg={2}>
<DemoContent>sm: 1/4, md: 1/4, lg: 1/6</DemoContent>
</Column>
<Column sm={1} md={1} lg={1}>
<DemoContent>sm: 1/4, md: 1/8, lg: 1/12</DemoContent>
</Column>
<Column sm={1} md={1} lg={1}>
<DemoContent>sm: 1/4, md: 1/8, lg: 1/12</DemoContent>
<Column sm={2} md={4} lg={6}>
<DemoContent>
<p>Small: Span 2 of 4</p>
<p>Medium: Span 4 of 8</p>
<p>Large: Span 6 of 12</p>
</DemoContent>
</Column>
<Column sm={2} md={2} lg={3}>
<DemoContent>
<p>Small: Span 2 of 4</p>
<p>Medium: Span 2 of 8</p>
<p>Large: Span 3 of 12</p>
</DemoContent>
</Column>
<Column sm={0} md={2} lg={3}>
<DemoContent>
<p>Small: Span 0 of 4</p>
<p>Medium: Span 2 of 8</p>
<p>Large: Span 3 of 12</p>
</DemoContent>
</Column>
</Row>
</Grid>
Expand All @@ -62,16 +77,16 @@ export const offset = () => (
<Grid>
<Row>
<Column sm={{ span: 1, offset: 3 }}>
<DemoContent>Small Screen Offset 3</DemoContent>
<DemoContent>Small: offset 3</DemoContent>
</Column>
<Column sm={{ span: 2, offset: 2 }}>
<DemoContent>Small Screen Offset 2</DemoContent>
<DemoContent>Small: offset 2</DemoContent>
</Column>
<Column sm={{ span: 3, offset: 1 }}>
<DemoContent>Small Screen Offset 1</DemoContent>
<DemoContent>Small: offset 1</DemoContent>
</Column>
<Column sm={{ span: 4, offset: 0 }}>
<DemoContent>Small Screen Offset 0</DemoContent>
<DemoContent>Small: offset 0</DemoContent>
</Column>
</Row>
</Grid>
Expand Down Expand Up @@ -227,3 +242,50 @@ export const fullWidth = () => (
</Row>
</Grid>
);

export const mixedGridModes = () => (
<Grid>
<Row>
<Column>
<DemoContent>Wide</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
</Column>
</Row>
<Row narrow>
<Column>
<DemoContent>Narrow</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
</Column>
</Row>
<Row condensed>
<Column>
<DemoContent>Condensed</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
</Column>
<Column>
<DemoContent>1/4</DemoContent>
</Column>
</Row>
</Grid>
);
4 changes: 2 additions & 2 deletions packages/react/src/components/Grid/Grid-story.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
}

// grid styles
#root .outside {
.bx--grid .outside {
min-height: 80px;
height: 100%;
}

#root .inside {
.bx--grid .inside {
min-height: 80px;
height: 100%;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Grid/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Grid.propTypes = {
className: PropTypes.string,

/**
* Collapse the gutter to 2px. Useful for fluid layouts.
* Rows have 2px of margin between them to match gutter.
* Collapse the gutter to 1px. Useful for fluid layouts.
* Rows have 1px of margin between them to match gutter.
*/
condensed: PropTypes.bool,

Expand Down
Loading

0 comments on commit 49d9258

Please sign in to comment.