Skip to content

Commit a22899a

Browse files
committed
add ability to set custom gap for Grid.Layout
1 parent 10f2a86 commit a22899a

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed
1.33 KB
Loading

src/components/Grid/Grid.stories.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ export const withGap = () => (
138138
<Block />
139139
</Grid.Box>
140140
</Grid.Layout>
141+
<Grid.Layout inline gap="custom" customGap="64px" columns="auto auto auto">
142+
<Grid.Box>
143+
<Block>custom</Block>
144+
</Grid.Box>
145+
<Grid.Box>
146+
<Block />
147+
</Grid.Box>
148+
<Grid.Box>
149+
<Block />
150+
</Grid.Box>
151+
</Grid.Layout>
141152
</Column>
142153
);
143154

src/components/Grid/GridLayout.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ type GridLayoutProps = {
99
/** when true then stretch to full width */
1010
stretch?: boolean,
1111
/** possbile spaces between grid items */
12-
gap?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'none',
12+
gap?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'none' | 'custom',
13+
/** custom grid-gap value (it is required if the gap set to custom) */
14+
customGap?: string,
1315
/** when true then set inline-grid */
1416
inline?: boolean,
1517
/** possible paddings of the grid layout */
@@ -70,7 +72,7 @@ const [StyledTag, theme] = createThemeTag(name, {
7072

7173
return style;
7274
},
73-
modifiers: {
75+
modifiers: (props) => ({
7476
gap: {
7577
xs: {
7678
gridGap: '4px',
@@ -91,6 +93,9 @@ const [StyledTag, theme] = createThemeTag(name, {
9193
gridGap: '40px',
9294
},
9395
none: {},
96+
custom: {
97+
gridGap: props.customGap,
98+
},
9499
},
95100
padding: {
96101
none: {},
@@ -115,7 +120,7 @@ const [StyledTag, theme] = createThemeTag(name, {
115120
width: '100%',
116121
maxWidth: '100%',
117122
},
118-
},
123+
}),
119124
});
120125

121126
class GridLayout extends React.PureComponent<GridLayoutProps> {

0 commit comments

Comments
 (0)