From 5f3450839aa7fa9af49a700e5177357bfa120be6 Mon Sep 17 00:00:00 2001 From: Eric Y Liu Date: Fri, 5 Mar 2021 14:17:29 -0800 Subject: [PATCH] feat(button): add isSelected prop for icon-only, ghost buttons --- COMPONENT_INDEX.md | 1 + docs/src/COMPONENT_API.json | 10 ++++++++++ docs/src/pages/components/Button.svx | 13 +++++++++++++ src/Button/Button.svelte | 6 ++++++ types/Button/Button.d.ts | 6 ++++++ 5 files changed, 36 insertions(+) diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index 5c192d38..a1cc6e75 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -342,6 +342,7 @@ None. | hasIconOnly | let | Yes | boolean | false | Set to `true` for the icon-only variant | | kind | let | No | "primary" | "secondary" | "tertiary" | "ghost" | "danger" | "danger-tertiary" | "danger-ghost" | "primary" | Specify the kind of button | | size | let | No | "default" | "field" | "small" | "default" | Specify the size of button | +| isSelected | let | No | boolean | false | Set to `true` to enable the selected state for an icon-only, ghost button | | icon | let | No | typeof import("carbon-icons-svelte").CarbonIcon | -- | Specify the icon from `carbon-icons-svelte` to render | | iconDescription | let | No | string | -- | Specify the ARIA label for the button icon | | tooltipAlignment | let | No | "start" | "center" | "end" | "center" | Set the alignment of the tooltip relative to the icon
`hasIconOnly` must be set to `true` | diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index 238f4149..d29c6124 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -368,6 +368,16 @@ "constant": false, "reactive": false }, + { + "name": "isSelected", + "kind": "let", + "description": "Set to `true` to enable the selected state for an icon-only, ghost button", + "type": "boolean", + "value": "false", + "isFunction": false, + "constant": false, + "reactive": false + }, { "name": "hasIconOnly", "kind": "let", diff --git a/docs/src/pages/components/Button.svx b/docs/src/pages/components/Button.svx index 64c05e2d..bee4bcdc 100644 --- a/docs/src/pages/components/Button.svx +++ b/docs/src/pages/components/Button.svx @@ -2,7 +2,12 @@ import { Button } from "carbon-components-svelte"; import Add16 from "carbon-icons-svelte/lib/Add16"; import TrashCan16 from "carbon-icons-svelte/lib/TrashCan16"; + import TextBold16 from "carbon-icons-svelte/lib/TextBold16"; + import TextItalic16 from "carbon-icons-svelte/lib/TextItalic16"; + import TextUnderline16 from "carbon-icons-svelte/lib/TextUnderline16"; import Preview from "../../components/Preview.svelte"; + + let index = 1; ### Primary button @@ -55,6 +60,14 @@ The tooltip position and alignment can be controlled by `tooltipPosition` and `t