Skip to content

Commit 11e0d2e

Browse files
committed
Add space component
1 parent da06ec1 commit 11e0d2e

File tree

1 file changed

+47
-0
lines changed
  • packages/gatsby-theme/src/components/shared

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import styled, { css } from '../style/styled';
2+
import { mobile } from '../style/media';
3+
import { SpaceSizes } from '../style/theme';
4+
5+
type Props = {
6+
width?: SpaceSizes;
7+
height?: SpaceSizes;
8+
widthOnMobile?: SpaceSizes;
9+
heightOnMobile?: SpaceSizes;
10+
fillRow?: boolean;
11+
fillColumn?: boolean;
12+
};
13+
14+
export const Space = styled.div<Props>`
15+
width: ${p => (typeof p.width === 'number' ? p.width + 'px' : 'auto')};
16+
height: ${p => (typeof p.height === 'number' ? p.height + 'px' : 'auto')};
17+
flex-shrink: 0;
18+
19+
${p =>
20+
mobile(css`
21+
${typeof p.widthOnMobile === 'number' &&
22+
css`
23+
width: ${p.widthOnMobile}px;
24+
`};
25+
26+
${typeof p.heightOnMobile === 'number' &&
27+
css`
28+
height: ${p.heightOnMobile}px;
29+
`};
30+
`)};
31+
32+
${p =>
33+
p.fillRow &&
34+
css`
35+
flex-grow: 1;
36+
margin-right: auto;
37+
margin-left: auto;
38+
`};
39+
40+
${p =>
41+
p.fillColumn &&
42+
css`
43+
flex-grow: 1;
44+
margin-top: auto;
45+
margin-bottom: auto;
46+
`};
47+
`;

0 commit comments

Comments
 (0)