From 075244766704c8002efbbcc43faaf75563b14d23 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sun, 8 Jan 2023 14:19:30 -0800 Subject: [PATCH] feat(grid)!: replace `as` with `tag` prop --- COMPONENT_INDEX.md | 26 ++++++++++----------- docs/src/COMPONENT_API.json | 16 ++++--------- src/Grid/Grid.svelte | 46 +++++++++++++------------------------ types/Grid/Grid.svelte.d.ts | 9 ++++---- 4 files changed, 38 insertions(+), 59 deletions(-) diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index fc22e2fe..01a034c9 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -1542,22 +1542,22 @@ None. ### Props -| Prop name | Required | Kind | Reactive | Type | Default value | Description | -| :------------ | :------- | :--------------- | :------- | -------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| as | No | let | No | boolean | false | Set to `true` to render a custom HTML element
Props are destructured as `props` in the default slot (e.g., <Grid let:props><header {...props}>...</header></Grid>) | -| condensed | No | let | No | boolean | false | Set to `true` to use the condensed variant | -| narrow | No | let | No | boolean | false | Set to `true` to use the narrow variant | -| fullWidth | No | let | No | boolean | false | Set to `true` to use the fullWidth variant | -| noGutter | No | let | No | boolean | false | Set to `true` to remove the gutter | -| noGutterLeft | No | let | No | boolean | false | Set to `true` to remove the left gutter | -| noGutterRight | No | let | No | boolean | false | Set to `true` to remove the right gutter | -| padding | No | let | No | boolean | false | Set to `true` to add top and bottom padding to all columns | +| Prop name | Required | Kind | Reactive | Type | Default value | Description | +| :------------ | :------- | :--------------- | :------- | -------------------- | ------------------ | ---------------------------------------------------------- | +| tag | No | let | No | string | "div" | Specify the element tag | +| condensed | No | let | No | boolean | false | Set to `true` to use the condensed variant | +| narrow | No | let | No | boolean | false | Set to `true` to use the narrow variant | +| fullWidth | No | let | No | boolean | false | Set to `true` to use the fullWidth variant | +| noGutter | No | let | No | boolean | false | Set to `true` to remove the gutter | +| noGutterLeft | No | let | No | boolean | false | Set to `true` to remove the left gutter | +| noGutterRight | No | let | No | boolean | false | Set to `true` to remove the right gutter | +| padding | No | let | No | boolean | false | Set to `true` to add top and bottom padding to all columns | ### Slots -| Slot name | Default | Props | Fallback | -| :-------- | :------ | :-------------------------------------------------------------- | :------- | -| -- | Yes | { props: { class: string; [key: string]: any; } } | -- | +| Slot name | Default | Props | Fallback | +| :-------- | :------ | :---- | :------- | +| -- | Yes | -- | -- | ### Events diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index ce55e9ba..5b7a97fe 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -4584,11 +4584,11 @@ "filePath": "src/Grid/Grid.svelte", "props": [ { - "name": "as", + "name": "tag", "kind": "let", - "description": "Set to `true` to render a custom HTML element\nProps are destructured as `props` in the default slot (e.g.,
...
)", - "type": "boolean", - "value": "false", + "description": "Specify the element tag", + "type": "string", + "value": "\"div\"", "isFunction": false, "isFunctionDeclaration": false, "isRequired": false, @@ -4681,13 +4681,7 @@ } ], "moduleExports": [], - "slots": [ - { - "name": "__default__", - "default": true, - "slot_props": "{ props: { class: string; [key: string]: any; } }" - } - ], + "slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }], "events": [], "typedefs": [], "rest_props": { "type": "Element", "name": "div" } diff --git a/src/Grid/Grid.svelte b/src/Grid/Grid.svelte index 113f91f6..18b5e6bc 100644 --- a/src/Grid/Grid.svelte +++ b/src/Grid/Grid.svelte @@ -1,14 +1,10 @@ -{#if as} - -{:else} -
- -
-{/if} + + + diff --git a/types/Grid/Grid.svelte.d.ts b/types/Grid/Grid.svelte.d.ts index 106fa6fe..628db7f4 100644 --- a/types/Grid/Grid.svelte.d.ts +++ b/types/Grid/Grid.svelte.d.ts @@ -4,11 +4,10 @@ import type { SvelteComponentTyped } from "svelte"; export interface GridProps extends svelte.JSX.HTMLAttributes { /** - * Set to `true` to render a custom HTML element - * Props are destructured as `props` in the default slot (e.g.,
...
) - * @default false + * Specify the element tag + * @default "div" */ - as?: boolean; + tag?: string; /** * Set to `true` to use the condensed variant @@ -56,5 +55,5 @@ export interface GridProps export default class Grid extends SvelteComponentTyped< GridProps, {}, - { default: { props: { class: string; [key: string]: any } } } + { default: {} } > {}