Skip to content

Commit

Permalink
Add padding prop to Grid component (carbon-design-system#420)
Browse files Browse the repository at this point in the history
* Add padding prop to Grid component

* Fix file name

* Build lib

* Typo

Co-authored-by: Richard O'flynn <[email protected]>
  • Loading branch information
ispyinternet and ispyinternet authored Nov 27, 2020
1 parent f4c940d commit b597a64
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 0 deletions.
3 changes: 3 additions & 0 deletions COMPONENT_INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ export type ColumnBreakpoint = ColumnSize | ColumnSizeDescriptor;
| noGutter | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to remove the gutter |
| noGutterLeft | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to remove the left gutter |
| noGutterRight | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to remove the right gutter |
| padding | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to add top and bottom padding to the column |
| aspectRatio | <code>let</code> | No | <code>"2x1" &#124; "16x9" &#124; "9x16" &#124; "1x2" &#124; "4x3" &#124; "3x4" &#124; "1x1"</code> | -- | Specify the aspect ratio of the column |
| sm | <code>let</code> | No | <code>ColumnBreakpoint</code> | -- | Set the small breakpoint |
| md | <code>let</code> | No | <code>ColumnBreakpoint</code> | -- | Set the medium breakpoint |
Expand Down Expand Up @@ -1355,6 +1356,7 @@ None.
| noGutter | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to remove the gutter |
| noGutterLeft | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to remove the left gutter |
| noGutterRight | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to remove the right gutter |
| padding | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to add top and bottom padding to all columns |

### Slots

Expand Down Expand Up @@ -2747,6 +2749,7 @@ None.
| noGutter | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to remove the gutter |
| noGutterLeft | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to remove the left gutter |
| noGutterRight | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to remove the right gutter |
| padding | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to add top and bottom padding to all columns |

### Slots

Expand Down
30 changes: 30 additions & 0 deletions docs/src/COMPONENT_API.json
Original file line number Diff line number Diff line change
Expand Up @@ -4661,6 +4661,16 @@
"isFunction": false,
"constant": false,
"reactive": false
},
{
"name": "padding",
"kind": "let",
"description": "Set to `true` to add top and bottom padding to all columns",
"type": "boolean",
"value": "false",
"isFunction": false,
"constant": false,
"reactive": false
}
],
"slots": [
Expand Down Expand Up @@ -4737,6 +4747,16 @@
"isFunction": false,
"constant": false,
"reactive": false
},
{
"name": "padding",
"kind": "let",
"description": "Set to `true` to add top and bottom padding to all columns",
"type": "boolean",
"value": "false",
"isFunction": false,
"constant": false,
"reactive": false
}
],
"slots": [
Expand Down Expand Up @@ -4794,6 +4814,16 @@
"constant": false,
"reactive": false
},
{
"name": "padding",
"kind": "let",
"description": "Set to `true` to add top and bottom padding to the column",
"type": "boolean",
"value": "false",
"isFunction": false,
"constant": false,
"reactive": false
},
{
"name": "aspectRatio",
"kind": "let",
Expand Down
4 changes: 4 additions & 0 deletions docs/src/pages/components/Grid.svx
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ components: ["Grid", "Row", "Column"]
### Aspect ratio columns

<FileSource src="/framed/Grid/AspectRatioColumns" />

### Padded columns

<FileSource src="/framed/Grid/PaddedGrid" />
29 changes: 29 additions & 0 deletions docs/src/pages/framed/Grid/PaddedGrid.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script>
import { Grid, Row, Column } from "carbon-components-svelte";
</script>

<Grid narrow padding>
<Row>
<Column style="outline: 1px solid var(--cds-interactive-04)">Column</Column>
<Column style="outline: 1px solid var(--cds-interactive-04)">Column</Column>
<Column style="outline: 1px solid var(--cds-interactive-04)">Column</Column>
<Column style="outline: 1px solid var(--cds-interactive-04)">Column</Column>
</Row>
</Grid>

<Grid narrow>
<Row padding>
<Column style="outline: 1px solid var(--cds-interactive-04)">Column</Column>
<Column style="outline: 1px solid var(--cds-interactive-04)">Column</Column>
<Column style="outline: 1px solid var(--cds-interactive-04)">Column</Column>
<Column style="outline: 1px solid var(--cds-interactive-04)">Column</Column>
</Row>
<Row>
<Column padding style="outline: 1px solid var(--cds-interactive-04)">
Column
</Column>
<Column style="outline: 1px solid var(--cds-interactive-04)">Column</Column>
<Column style="outline: 1px solid var(--cds-interactive-04)">Column</Column>
<Column style="outline: 1px solid var(--cds-interactive-04)">Column</Column>
</Row>
</Grid>
4 changes: 4 additions & 0 deletions src/Grid/Column.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
/** Set to `true` to remove the right gutter */
export let noGutterRight = false;
/** Set to `true` to add top and bottom padding to the column */
export let padding = false;
/**
* Specify the aspect ratio of the column
* @type {"2x1" | "16x9" | "9x16" | "1x2" | "4x3" | "3x4" | "1x1"}
Expand Down Expand Up @@ -100,6 +103,7 @@
noGutterLeft && "bx--no-gutter--left",
noGutterRight && "bx--no-gutter--right",
aspectRatio && `bx--aspect-ratio bx--aspect-ratio--${aspectRatio}`,
padding && "bx--col-padding",
]
.filter(Boolean)
.join(" "),
Expand Down
4 changes: 4 additions & 0 deletions src/Grid/Grid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
/** Set to `true` to remove the right gutter */
export let noGutterRight = false;
/** Set to `true` to add top and bottom padding to all columns */
export let padding = false;
$: props = {
...$$restProps,
class: [
Expand All @@ -39,6 +42,7 @@
noGutter && "bx--no-gutter",
noGutterLeft && "bx--no-gutter--left",
noGutterRight && "bx--no-gutter--right",
padding && "bx--row-padding",
]
.filter(Boolean)
.join(" "),
Expand Down
4 changes: 4 additions & 0 deletions src/Grid/Row.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
/** Set to `true` to remove the right gutter */
export let noGutterRight = false;
/** Set to `true` to add top and bottom padding to all columns */
export let padding = false;
$: props = {
...$$restProps,
class: [
Expand All @@ -35,6 +38,7 @@
noGutter && "bx--no-gutter",
noGutterLeft && "bx--no-gutter--left",
noGutterRight && "bx--no-gutter--right",
padding && "bx--row-padding",
]
.filter(Boolean)
.join(" "),
Expand Down
20 changes: 20 additions & 0 deletions tests/PaddedGrid.test.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script lang="ts">
import { Grid, Row, Column } from "../types";
</script>

<Grid padding>
<Row padding>
<Column padding style="outline: 1px solid var(--cds-interactive-04)">
Column
</Column>
<Column padding style="outline: 1px solid var(--cds-interactive-04)">
Column
</Column>
<Column padding style="outline: 1px solid var(--cds-interactive-04)">
Column
</Column>
<Column padding style="outline: 1px solid var(--cds-interactive-04)">
Column
</Column>
</Row>
</Grid>
6 changes: 6 additions & 0 deletions types/Grid/Column.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export interface ColumnProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNam
*/
noGutterRight?: boolean;

/**
* Set to `true` to add top and bottom padding to the column
* @default false
*/
padding?: boolean;

/**
* Specify the aspect ratio of the column
*/
Expand Down
6 changes: 6 additions & 0 deletions types/Grid/Grid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export interface GridProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameM
* @default false
*/
noGutterRight?: boolean;

/**
* Set to `true` to add top and bottom padding to all columns
* @default false
*/
padding?: boolean;
}

export default class Grid {
Expand Down
6 changes: 6 additions & 0 deletions types/Grid/Row.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export interface RowProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMa
* @default false
*/
noGutterRight?: boolean;

/**
* Set to `true` to add top and bottom padding to all columns
* @default false
*/
padding?: boolean;
}

export default class Row {
Expand Down

0 comments on commit b597a64

Please sign in to comment.