-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70ff8d8
commit a19cc3b
Showing
9 changed files
with
1,990 additions
and
1,290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import 'jest-styled-components'; | ||
|
||
import { Flex } from './index'; | ||
import { ThemeProvider } from '../theme-provider'; | ||
|
||
test('it works', () => { | ||
const tree = renderer | ||
.create( | ||
<ThemeProvider> | ||
<Flex> | ||
<p>Hello world!</p> | ||
</Flex> | ||
</ThemeProvider> | ||
) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
test('it works with styles', () => { | ||
const tree = renderer | ||
.create( | ||
<ThemeProvider> | ||
<Flex | ||
styles={{ | ||
flex: '1 1 auto', | ||
padding: '2' | ||
}} | ||
> | ||
<p>Hello world!</p> | ||
</Flex> | ||
</ThemeProvider> | ||
) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
The Flex component creates flexbox layouts. | ||
|
||
```jsx harmony | ||
import { ThemeProvider, Box, Text, Flex } from '@lapidist/components'; | ||
|
||
<ThemeProvider> | ||
<Flex> | ||
<Box | ||
styles={{ | ||
flex: '1 1 auto' | ||
}} | ||
> | ||
<Text | ||
styles={{ | ||
padding: 4, | ||
backgroundColor: { group: 'primary', shade: 'base' }, | ||
textColor: { group: 'base', shade: 'light' } | ||
}} | ||
> | ||
Hello world! | ||
</Text> | ||
</Box> | ||
<Box> | ||
<Text | ||
styles={{ | ||
padding: 4, | ||
backgroundColor: { group: 'primary', shade: 'light' }, | ||
textColor: { group: 'base', shade: 'light' } | ||
}} | ||
> | ||
Hello world! | ||
</Text> | ||
</Box> | ||
</Flex> | ||
</ThemeProvider> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`it works 1`] = ` | ||
.c0 { | ||
display: -webkit-box; | ||
display: -webkit-flex; | ||
display: -ms-flexbox; | ||
display: flex; | ||
} | ||
<div | ||
className="c0" | ||
> | ||
<p> | ||
Hello world! | ||
</p> | ||
</div> | ||
`; | ||
|
||
exports[`it works with styles 1`] = ` | ||
.c0 { | ||
display: -webkit-box; | ||
display: -webkit-flex; | ||
display: -ms-flexbox; | ||
display: flex; | ||
-webkit-flex: 1 1 auto; | ||
-ms-flex: 1 1 auto; | ||
flex: 1 1 auto; | ||
padding: 0.5rem; | ||
} | ||
<div | ||
className="c0" | ||
> | ||
<p> | ||
Hello world! | ||
</p> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import deepMerge from 'lodash.merge'; | ||
import { Box, BoxProps } from '../box'; | ||
|
||
export type FlexPropType = BoxProps & React.HTMLProps<HTMLDivElement>; | ||
|
||
export const Flex: React.FC<FlexPropType> = ({ | ||
as = 'div', | ||
styles, | ||
...restProps | ||
}) => ( | ||
<Box | ||
as={as} | ||
styles={deepMerge({ display: 'flex' }, styles)} | ||
{...restProps} | ||
/> | ||
); | ||
|
||
Flex.displayName = 'Flex'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters