mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
Add padding prop to Grid component (#420)
* Add padding prop to Grid component * Fix file name * Build lib * Typo Co-authored-by: Richard O'flynn <richard.oflynn@brighter-software.co.uk>
This commit is contained in:
parent
f4c940d5ee
commit
b597a64131
11 changed files with 116 additions and 0 deletions
|
@ -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" | "16x9" | "9x16" | "1x2" | "4x3" | "3x4" | "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 |
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -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": [
|
||||
|
@ -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": [
|
||||
|
@ -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",
|
||||
|
|
|
@ -33,3 +33,7 @@ components: ["Grid", "Row", "Column"]
|
|||
### Aspect ratio columns
|
||||
|
||||
<FileSource src="/framed/Grid/AspectRatioColumns" />
|
||||
|
||||
### Padded columns
|
||||
|
||||
<FileSource src="/framed/Grid/PaddedGrid" />
|
||||
|
|
29
docs/src/pages/framed/Grid/PaddedGrid.svelte
Normal file
29
docs/src/pages/framed/Grid/PaddedGrid.svelte
Normal file
|
@ -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>
|
|
@ -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"}
|
||||
|
@ -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(" "),
|
||||
|
|
|
@ -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: [
|
||||
|
@ -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(" "),
|
||||
|
|
|
@ -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: [
|
||||
|
@ -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(" "),
|
||||
|
|
20
tests/PaddedGrid.test.svelte
Normal file
20
tests/PaddedGrid.test.svelte
Normal file
|
@ -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
types/Grid/Column.d.ts
vendored
6
types/Grid/Column.d.ts
vendored
|
@ -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
|
||||
*/
|
||||
|
|
6
types/Grid/Grid.d.ts
vendored
6
types/Grid/Grid.d.ts
vendored
|
@ -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 {
|
||||
|
|
6
types/Grid/Row.d.ts
vendored
6
types/Grid/Row.d.ts
vendored
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue