mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
feat(tag): support small size variant
This commit is contained in:
parent
6f7acd224f
commit
ce3a34ac9c
7 changed files with 56 additions and 5 deletions
|
@ -3629,6 +3629,7 @@ None.
|
||||||
| Prop name | Kind | Reactive | Type | Default value | Description |
|
| Prop name | Kind | Reactive | Type | Default value | Description |
|
||||||
| :-------- | :--------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------ |
|
| :-------- | :--------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------ |
|
||||||
| type | <code>let</code> | No | <code>"red" | "magenta" | "purple" | "blue" | "cyan" | "teal" | "green" | "gray" | "cool-gray" | "warm-gray" | "high-contrast"</code> | -- | Specify the type of tag |
|
| type | <code>let</code> | No | <code>"red" | "magenta" | "purple" | "blue" | "cyan" | "teal" | "green" | "gray" | "cool-gray" | "warm-gray" | "high-contrast"</code> | -- | Specify the type of tag |
|
||||||
|
| size | <code>let</code> | No | <code>"sm" | "default"</code> | <code>"default"</code> | -- |
|
||||||
| filter | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use filterable variant |
|
| filter | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use filterable variant |
|
||||||
| disabled | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable a filterable tag |
|
| disabled | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable a filterable tag |
|
||||||
| skeleton | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to display the skeleton state |
|
| skeleton | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to display the skeleton state |
|
||||||
|
@ -3656,7 +3657,9 @@ None.
|
||||||
|
|
||||||
### Props
|
### Props
|
||||||
|
|
||||||
None.
|
| Prop name | Kind | Reactive | Type | Default value | Description |
|
||||||
|
| :-------- | :--------------- | :------- | :--------------------------------- | ---------------------- | ----------- |
|
||||||
|
| size | <code>let</code> | No | <code>"sm" | "default"</code> | <code>"default"</code> | -- |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
|
|
@ -7803,7 +7803,17 @@
|
||||||
{
|
{
|
||||||
"moduleName": "TagSkeleton",
|
"moduleName": "TagSkeleton",
|
||||||
"filePath": "/src/Tag/TagSkeleton.svelte",
|
"filePath": "/src/Tag/TagSkeleton.svelte",
|
||||||
"props": [],
|
"props": [
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"kind": "let",
|
||||||
|
"type": "\"sm\" | \"default\"",
|
||||||
|
"value": "\"default\"",
|
||||||
|
"isFunction": false,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": false
|
||||||
|
}
|
||||||
|
],
|
||||||
"slots": [],
|
"slots": [],
|
||||||
"events": [
|
"events": [
|
||||||
{ "type": "forwarded", "name": "click", "element": "span" },
|
{ "type": "forwarded", "name": "click", "element": "span" },
|
||||||
|
@ -7827,6 +7837,15 @@
|
||||||
"constant": false,
|
"constant": false,
|
||||||
"reactive": false
|
"reactive": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"kind": "let",
|
||||||
|
"type": "\"sm\" | \"default\"",
|
||||||
|
"value": "\"default\"",
|
||||||
|
"isFunction": false,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "filter",
|
"name": "filter",
|
||||||
"kind": "let",
|
"kind": "let",
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
|
|
||||||
<Tag>IBM Cloud</Tag>
|
<Tag>IBM Cloud</Tag>
|
||||||
|
|
||||||
|
### Small size
|
||||||
|
|
||||||
|
<Tag size="sm">IBM Cloud</Tag>
|
||||||
|
|
||||||
### Tag types
|
### Tag types
|
||||||
|
|
||||||
<Tag type="red">red</Tag>
|
<Tag type="red">red</Tag>
|
||||||
|
@ -32,8 +36,11 @@
|
||||||
Note: rendering a custom icon cannnot be used with the filterable variant.
|
Note: rendering a custom icon cannnot be used with the filterable variant.
|
||||||
|
|
||||||
<Tag icon={IbmCloud16}>IBM Cloud</Tag>
|
<Tag icon={IbmCloud16}>IBM Cloud</Tag>
|
||||||
<Tag icon={Document16} type="blue">API documentation</Tag>
|
|
||||||
|
|
||||||
### Skeleton
|
### Skeleton
|
||||||
|
|
||||||
<Tag skeleton />
|
<Tag skeleton />
|
||||||
|
|
||||||
|
### Skeleton (small)
|
||||||
|
|
||||||
|
<Tag size="sm" skeleton />
|
|
@ -7,6 +7,9 @@
|
||||||
*/
|
*/
|
||||||
export let type = undefined;
|
export let type = undefined;
|
||||||
|
|
||||||
|
/** @type {"sm" | "default"} */
|
||||||
|
export let size = "default";
|
||||||
|
|
||||||
/** Set to `true` to use filterable variant */
|
/** Set to `true` to use filterable variant */
|
||||||
export let filter = false;
|
export let filter = false;
|
||||||
|
|
||||||
|
@ -38,6 +41,7 @@
|
||||||
|
|
||||||
{#if skeleton}
|
{#if skeleton}
|
||||||
<TagSkeleton
|
<TagSkeleton
|
||||||
|
size="{size}"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
on:mouseover
|
on:mouseover
|
||||||
|
@ -52,6 +56,7 @@
|
||||||
class:bx--tag="{true}"
|
class:bx--tag="{true}"
|
||||||
class:bx--tag--disabled="{disabled}"
|
class:bx--tag--disabled="{disabled}"
|
||||||
class:bx--tag--filter="{filter}"
|
class:bx--tag--filter="{filter}"
|
||||||
|
class:bx--tag--sm="{size === 'sm'}"
|
||||||
class:bx--tag--red="{type === 'red'}"
|
class:bx--tag--red="{type === 'red'}"
|
||||||
class:bx--tag--magenta="{type === 'magenta'}"
|
class:bx--tag--magenta="{type === 'magenta'}"
|
||||||
class:bx--tag--purple="{type === 'purple'}"
|
class:bx--tag--purple="{type === 'purple'}"
|
||||||
|
@ -89,6 +94,7 @@
|
||||||
id="{id}"
|
id="{id}"
|
||||||
class:bx--tag="{true}"
|
class:bx--tag="{true}"
|
||||||
class:bx--tag--disabled="{disabled}"
|
class:bx--tag--disabled="{disabled}"
|
||||||
|
class:bx--tag--sm="{size === 'sm'}"
|
||||||
class:bx--tag--red="{type === 'red'}"
|
class:bx--tag--red="{type === 'red'}"
|
||||||
class:bx--tag--magenta="{type === 'magenta'}"
|
class:bx--tag--magenta="{type === 'magenta'}"
|
||||||
class:bx--tag--purple="{type === 'purple'}"
|
class:bx--tag--purple="{type === 'purple'}"
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
|
<script>
|
||||||
|
/** @type {"sm" | "default"} */
|
||||||
|
export let size = "default";
|
||||||
|
</script>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
class:bx--tag="{true}"
|
class:bx--tag="{true}"
|
||||||
|
class:bx--tag--sm="{size === 'sm'}"
|
||||||
class:bx--skeleton="{true}"
|
class:bx--skeleton="{true}"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
|
|
5
types/Tag/Tag.d.ts
vendored
5
types/Tag/Tag.d.ts
vendored
|
@ -19,6 +19,11 @@ export interface TagProps
|
||||||
| "warm-gray"
|
| "warm-gray"
|
||||||
| "high-contrast";
|
| "high-contrast";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @default "default"
|
||||||
|
*/
|
||||||
|
size?: "sm" | "default";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to `true` to use filterable variant
|
* Set to `true` to use filterable variant
|
||||||
* @default false
|
* @default false
|
||||||
|
|
7
types/Tag/TagSkeleton.d.ts
vendored
7
types/Tag/TagSkeleton.d.ts
vendored
|
@ -1,6 +1,11 @@
|
||||||
/// <reference types="svelte" />
|
/// <reference types="svelte" />
|
||||||
|
|
||||||
export interface TagSkeletonProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["span"]> {}
|
export interface TagSkeletonProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["span"]> {
|
||||||
|
/**
|
||||||
|
* @default "default"
|
||||||
|
*/
|
||||||
|
size?: "sm" | "default";
|
||||||
|
}
|
||||||
|
|
||||||
export default class TagSkeleton {
|
export default class TagSkeleton {
|
||||||
$$prop_def: TagSkeletonProps;
|
$$prop_def: TagSkeletonProps;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue