-
Notifications
You must be signed in to change notification settings - Fork 24
Add grid system components #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f296999
test: add test that reproduces the bug
jonotrujillo 0918b8c
fix: add default theme declaration
jonotrujillo 4c25cbf
fix: avoid collision of `color` prop
jonotrujillo c525f49
chore: remove StyledComponentBase typing
jonotrujillo 0405c22
fix: update prop compatibility
jonotrujillo 244b393
feat: add grid system components
jonotrujillo 93ee938
refactor: use flexbox approach
jonotrujillo 584f53f
refactor: rework flex approach
jonotrujillo 02a5056
Merge remote-tracking branch 'origin/main' into grid
jonotrujillo 1130234
docs: add stacking card example
jonotrujillo d0b80ac
fix: remove unnused import
jonotrujillo 691cd01
test: add snapshot tests
jonotrujillo a939045
feat: avoid setting marging left when 0
jonotrujillo 846e08f
feat: only use 4 decimals
jonotrujillo bd5555a
test: remove old snapshot
jonotrujillo 66cbcd4
Feat/add missing icons (#200)
div-Leo 6a00b0b
1.17.2-canary.0
jonotrujillo 3aea87c
chore: expose grid components
jonotrujillo d85327c
Merge remote-tracking branch 'origin/main' into grid
jonotrujillo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,25 @@ | ||
import React, { FC } from 'react'; | ||
import { Box, BoxProps } from '../Box/Box'; | ||
|
||
type ColumnSpan = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; | ||
type ColumnOffset = 'auto' | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11; | ||
|
||
type RowProps = BoxProps; | ||
|
||
const Row: FC<RowProps> = (props: RowProps) => ( | ||
<Box display="grid" gridTemplateColumns="repeat(12, 1fr)" gridColumnGap={3} {...props} /> | ||
); | ||
|
||
interface ColumnProps extends BoxProps { | ||
span?: ColumnSpan; | ||
offset?: ColumnOffset; | ||
} | ||
|
||
const Column: FC<ColumnProps> = ({ span = 1, offset = 'auto', ...restProps }: ColumnProps) => { | ||
const gridColumnStart = offset === 'auto' ? 'auto' : offset + 1; | ||
const gridColumnEnd = `span ${span}`; | ||
|
||
return <Box gridColumn={`${gridColumnStart} / ${gridColumnEnd}`} {...restProps} />; | ||
}; | ||
|
||
export { Row, RowProps, Column, ColumnProps }; |
This file contains hidden or 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,189 @@ | ||
--- | ||
name: Grid System | ||
menu: Components | ||
route: /components/grid-system | ||
--- | ||
|
||
import { Playground } from 'docz'; | ||
import { Button } from '../../Button/Button.tsx'; | ||
import { Headline } from '../../Headline/Headline.tsx'; | ||
import { Input } from '../../Input/Input.tsx'; | ||
import { Row, Column } from '../Grid.tsx'; | ||
import { StyledSystemLinks } from '../../../docs/StyledSystemLinks' | ||
import { Text } from '../../Text/Text.tsx'; | ||
import { ColumnPropsTable } from './GridPropsTable'; | ||
|
||
# Grid System | ||
|
||
The grid system is a set of components that can be used to create different layouts, composed of 12 vertical tracks of equal width. | ||
|
||
## Properties | ||
|
||
### Row | ||
|
||
<StyledSystemLinks component="Row" supportedProps={ ['space', 'layout', 'position', 'color', 'flexbox', 'grid-layout', 'background'] }/> | ||
|
||
### Column | ||
|
||
<ColumnPropsTable /><br/> | ||
|
||
<StyledSystemLinks component="Column" supportedProps={ ['space', 'layout', 'position', 'color', 'flexbox', 'grid-layout', 'background'] }/> | ||
|
||
## Examples | ||
|
||
The grid system is composed of 12 vertical tracks of equal width. Content can be placed in these tracks by using the `Row` and `Column` component. | ||
|
||
<Playground> | ||
<Row> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
1 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
2 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
3 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
4 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
5 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
6 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
7 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
8 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
9 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
10 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
11 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1}> | ||
12 | ||
</Column> | ||
</Row> | ||
</Playground> | ||
|
||
`Column`s can occupy more than one vertical track, by changing the `span` prop to a number between 1 and 12. | ||
|
||
<Playground> | ||
<Row mb={3}> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={2}> | ||
1 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={2}> | ||
2 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={2}> | ||
3 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={2}> | ||
4 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={2}> | ||
5 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={2}> | ||
6 | ||
</Column> | ||
</Row> | ||
<Row mb={3}> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={3}> | ||
7 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={3}> | ||
8 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={3}> | ||
9 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={3}> | ||
10 | ||
</Column> | ||
</Row> | ||
<Row mb={3}> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={4}> | ||
11 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={4}> | ||
12 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={4}> | ||
13 | ||
</Column> | ||
</Row> | ||
<Row mb={3}> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={6}> | ||
14 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={6}> | ||
15 | ||
</Column> | ||
</Row> | ||
<Row> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={12}> | ||
16 | ||
</Column> | ||
</Row> | ||
</Playground> | ||
|
||
`Column`s can be given an offset, by changing the `offset` prop to a number between 0 and 11. | ||
|
||
<Playground> | ||
<Row> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={4}> | ||
1 | ||
</Column> | ||
<Column bg="#f1f2f4" textAlign="center" p={1} span={4} offset={8}> | ||
2 | ||
</Column> | ||
</Row> | ||
</Playground> | ||
|
||
The `Row` and `Column` components can be used to create different kinds of layouts, combining them with other components of the design system. | ||
|
||
<Playground> | ||
<Row mb={3}> | ||
<Column span={12}> | ||
<Headline as="h2">Create a free Business Account</Headline> | ||
<Text as="p"> | ||
Make managing employee and guest travel easier. It only takes a couple | ||
of minutes to get started! | ||
</Text> | ||
</Column> | ||
</Row> | ||
<Row mb={3}> | ||
<Column span={6}> | ||
<Input label="First Name" width="100%" /> | ||
</Column> | ||
<Column span={6}> | ||
<Input label="Last Name" width="100%" /> | ||
</Column> | ||
</Row> | ||
<Row mb={3}> | ||
<Column span={6}> | ||
<Input label="Email" width="100%" /> | ||
</Column> | ||
<Column span={2}> | ||
<Input label="Area Code" width="100%" /> | ||
</Column> | ||
<Column span={4}> | ||
<Input label="Phone Number" width="100%" /> | ||
</Column> | ||
</Row> | ||
<Row> | ||
<Column span={6} offset={6}> | ||
<Button width="100%">Sign up for FREE NOW for Business</Button> | ||
</Column> | ||
</Row> | ||
</Playground> |
This file contains hidden or 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,21 @@ | ||
import { FC } from 'react'; | ||
import * as React from 'react'; | ||
import { PropsTable } from '../../../docs/PropsTable'; | ||
|
||
export const ColumnPropsTable: FC = () => { | ||
const props = [ | ||
{ | ||
name: 'offset', | ||
type: '"auto" | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11', | ||
description: 'vertical track that the column starts at', | ||
defaultValue: 'auto' | ||
}, | ||
{ | ||
name: 'span', | ||
type: '1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12', | ||
description: 'amount of vertical tracks that the column should span', | ||
defaultValue: '1' | ||
} | ||
]; | ||
return <PropsTable props={props} />; | ||
}; |
This file contains hidden or 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 hidden or 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 hidden or 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,35 @@ | ||
import 'styled-components'; | ||
import { BreakpointsArray, MediaQueries } from './essentials/Breakpoints/Breakpoints'; | ||
import { Colors, SemanticColors } from './essentials/Colors/Colors'; | ||
import { Spaces } from './essentials'; | ||
|
||
declare module 'styled-components' { | ||
export interface DefaultTheme { | ||
colors: typeof Colors; | ||
semanticColors: typeof SemanticColors; | ||
breakpoints: BreakpointsArray; | ||
fontSizes: string[]; | ||
fontWeights: { | ||
normal: number; | ||
semibold: number; | ||
bold: number; | ||
}; | ||
fonts: { | ||
normal: string; | ||
monospace: string; | ||
}; | ||
mediaQueries: typeof MediaQueries; | ||
space: typeof Spaces; | ||
radii: string[]; | ||
iconSizes: { | ||
small: number; | ||
medium: number; | ||
large: number; | ||
}; | ||
shadows: { | ||
small: string; | ||
medium: string; | ||
large: string; | ||
}; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.