Skip to content

Commit

Permalink
feat: add <InlineWidthQuery> component
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 4, 2018
1 parent 75083eb commit d80ad66
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/InlineWidthQuery/__story__/story.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {Component, createElement as h} from 'react';
import {storiesOf} from '@storybook/react';
import {action} from '@storybook/addon-actions';
import {linkTo} from '@storybook/addon-links';
import {InlineWidthQuery} from '..';
import {View} from '../../View';
import {WindowSizeSensor} from '../../WindowSizeSensor';
import ShowDocs from '../../../.storybook/ShowDocs';

storiesOf('UI/InlineWidthQuery', module)
// .add('Documentation', () => h(ShowDocs, {md: require('../../../docs/en/InlineWidthQuery.md')}))
.add('Example', () =>
<InlineWidthQuery>
<View maxWidth={300}>
Up to 300px
</View>
<View>
More than 300px
</View>
</InlineWidthQuery>
)
.add('100px increments', () =>
<InlineWidthQuery>
<View maxWidth={100}>
Up to 100px
</View>
<View maxWidth={200}>
100px - 200px
</View>
<View maxWidth={300}>
200px - 300px
</View>
<View maxWidth={400}>
300px - 400px
</View>
<View maxWidth={500}>
400px - 500px
</View>
<View maxWidth={600}>
500px - 600px
</View>
<View maxWidth={700}>
600px - 700px
</View>
<View>
700px+
</View>
</InlineWidthQuery>
)
10 changes: 10 additions & 0 deletions src/InlineWidthQuery/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {h} from '../util';
import {WidthQuery} from '../WidthQuery';
import {SizeSensor} from '../SizeSensor';

export const InlineWidthQuery = (props) =>
h(SizeSensor, null, (state) =>
h('div', null,
h(WidthQuery, state, props.children)
)
);

0 comments on commit d80ad66

Please sign in to comment.