mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
feat(row)!: replace as
with tag
prop
This commit is contained in:
parent
0752447667
commit
1e31e71bcf
4 changed files with 36 additions and 57 deletions
|
@ -3058,8 +3058,8 @@ None.
|
|||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------ | :------- | :--------------- | :------- | -------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| as | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to render a custom HTML element<br />Props are destructured as `props` in the default slot (e.g., <Row let:props><section {...props}>...</section></Row>) |
|
||||
| :------------ | :------- | :--------------- | :------- | -------------------- | ------------------ | ---------------------------------------------------------- |
|
||||
| tag | No | <code>let</code> | No | <code>string</code> | <code>"div"</code> | Specify the element tag |
|
||||
| condensed | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the condensed variant |
|
||||
| narrow | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the narrow variant |
|
||||
| noGutter | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to remove the gutter |
|
||||
|
@ -3070,8 +3070,8 @@ None.
|
|||
### Slots
|
||||
|
||||
| Slot name | Default | Props | Fallback |
|
||||
| :-------- | :------ | :-------------------------------------------------------------- | :------- |
|
||||
| -- | Yes | <code>{ props: { class: string; [key: string]: any; } } </code> | -- |
|
||||
| :-------- | :------ | :---- | :------- |
|
||||
| -- | Yes | -- | -- |
|
||||
|
||||
### Events
|
||||
|
||||
|
|
|
@ -9686,11 +9686,11 @@
|
|||
"filePath": "src/Grid/Row.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., <Row let:props><section {...props}>...</section></Row>)",
|
||||
"type": "boolean",
|
||||
"value": "false",
|
||||
"description": "Specify the element tag",
|
||||
"type": "string",
|
||||
"value": "\"div\"",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"isRequired": false,
|
||||
|
@ -9771,13 +9771,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" }
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
<script>
|
||||
/**
|
||||
* @restProps {div}
|
||||
* @slot {{ props: { class: string; [key: string]: any; } }}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set to `true` to render a custom HTML element
|
||||
* Props are destructured as `props` in the default slot (e.g., <Row let:props><section {...props}>...</section></Row>)
|
||||
*/
|
||||
export let as = false;
|
||||
/** Specify the element tag */
|
||||
export let tag = "div";
|
||||
|
||||
/** Set to `true` to use the condensed variant */
|
||||
export let condensed = false;
|
||||
|
@ -27,28 +23,18 @@
|
|||
|
||||
/** Set to `true` to add top and bottom padding to all columns */
|
||||
export let padding = false;
|
||||
|
||||
$: props = {
|
||||
...$$restProps,
|
||||
class: [
|
||||
$$restProps.class,
|
||||
"bx--row",
|
||||
condensed && "bx--row--condensed",
|
||||
narrow && "bx--row--narrow",
|
||||
noGutter && "bx--no-gutter",
|
||||
noGutterLeft && "bx--no-gutter--left",
|
||||
noGutterRight && "bx--no-gutter--right",
|
||||
padding && "bx--row-padding",
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" "),
|
||||
};
|
||||
</script>
|
||||
|
||||
{#if as}
|
||||
<slot props="{props}" />
|
||||
{:else}
|
||||
<div {...props}>
|
||||
<svelte:element
|
||||
this="{tag}"
|
||||
class:bx--row="{true}"
|
||||
class:bx--row--condensed="{condensed}"
|
||||
class:bx--row--narrow="{narrow}"
|
||||
class:bx--no-gutter="{noGutter}"
|
||||
class:bx--no-gutter--left="{noGutterLeft}"
|
||||
class:bx--no-gutter--right="{noGutterRight}"
|
||||
class:bx--row-padding="{padding}"
|
||||
{...$$restProps}
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
{/if}
|
||||
</svelte:element>
|
||||
|
|
9
types/Grid/Row.svelte.d.ts
vendored
9
types/Grid/Row.svelte.d.ts
vendored
|
@ -4,11 +4,10 @@ import type { SvelteComponentTyped } from "svelte";
|
|||
export interface RowProps
|
||||
extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["div"]> {
|
||||
/**
|
||||
* Set to `true` to render a custom HTML element
|
||||
* Props are destructured as `props` in the default slot (e.g., <Row let:props><section {...props}>...</section></Row>)
|
||||
* @default false
|
||||
* Specify the element tag
|
||||
* @default "div"
|
||||
*/
|
||||
as?: boolean;
|
||||
tag?: string;
|
||||
|
||||
/**
|
||||
* Set to `true` to use the condensed variant
|
||||
|
@ -50,5 +49,5 @@ export interface RowProps
|
|||
export default class Row extends SvelteComponentTyped<
|
||||
RowProps,
|
||||
{},
|
||||
{ default: { props: { class: string; [key: string]: any } } }
|
||||
{ default: {} }
|
||||
> {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue