From 621fea5f42fbf78597ad21225b65e802e3c81d01 Mon Sep 17 00:00:00 2001 From: Eric Y Liu Date: Fri, 5 Mar 2021 14:38:00 -0800 Subject: [PATCH] feat(radio-button): add legendText prop to RadioButtonGroup --- COMPONENT_INDEX.md | 8 +- docs/src/COMPONENT_API.json | 20 ++++- docs/src/pages/components/RadioButton.svx | 88 +++++++++++-------- .../ProgrammaticRadioButton.svelte | 17 ++-- src/RadioButtonGroup/RadioButtonGroup.svelte | 15 +++- tests/RadioButton.test.svelte | 63 +++++-------- types/RadioButtonGroup/RadioButtonGroup.d.ts | 8 +- 7 files changed, 123 insertions(+), 96 deletions(-) diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index a1cc6e75..12677ee2 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -2695,15 +2695,17 @@ None. | :------------ | :--------------- | :------- | :------------------------------------------ | ------------------------- | -------------------------------------------- | | selected | let | Yes | string | -- | Set the selected radio button value | | disabled | let | No | boolean | false | Set to `true` to disable the radio buttons | +| legendText | let | No | string | "" | Specify the legend text | | labelPosition | let | No | "right" | "left" | "right" | Specify the label position | | orientation | let | No | "horizontal" | "vertical" | "horizontal" | Specify the orientation of the radio buttons | | id | let | No | string | -- | Set an id for the container div element | ### Slots -| Slot name | Default | Props | Fallback | -| :-------- | :------ | :---- | :------- | -| -- | Yes | -- | -- | +| Slot name | Default | Props | Fallback | +| :--------- | :------ | :---- | :------------------------ | +| -- | Yes | -- | -- | +| legendText | No | -- | {legendText} | ### Events diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index d29c6124..2dc351c2 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -6960,6 +6960,16 @@ "constant": false, "reactive": false }, + { + "name": "legendText", + "kind": "let", + "description": "Specify the legend text", + "type": "string", + "value": "\"\"", + "isFunction": false, + "constant": false, + "reactive": false + }, { "name": "labelPosition", "kind": "let", @@ -6990,7 +7000,15 @@ "reactive": false } ], - "slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }], + "slots": [ + { "name": "__default__", "default": true, "slot_props": "{}" }, + { + "name": "legendText", + "default": false, + "fallback": "{legendText}", + "slot_props": "{}" + } + ], "events": [ { "type": "forwarded", "name": "click", "element": "div" }, { "type": "forwarded", "name": "mouseover", "element": "div" }, diff --git a/docs/src/pages/components/RadioButton.svx b/docs/src/pages/components/RadioButton.svx index b1aed1ce..54ec568d 100644 --- a/docs/src/pages/components/RadioButton.svx +++ b/docs/src/pages/components/RadioButton.svx @@ -3,19 +3,43 @@ components: ["RadioButtonGroup", "RadioButton", "RadioButtonSkeleton"] --- ### Default - - - - - - - + + + + + + +### With legend text + + + + + + + +### Legend text slot + +Use the named "legendText" slot to customize the legend text. + + +
+ Storage tier (disk) + +

+ Storage tiers may vary based on geolocation. +

+
+
+ + + +
### Programmatic usage @@ -25,40 +49,32 @@ Bind the selected value using the `selected` prop. ### Label text aligned left - - - - - - - + + + + + ### Vertical orientation - - - - - - - + + + + + ### Skeleton - - - - - - - + + + + + ### Skeleton (vertical orientation) - - - - - - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/docs/src/pages/framed/RadioButton/ProgrammaticRadioButton.svelte b/docs/src/pages/framed/RadioButton/ProgrammaticRadioButton.svelte index f0cffa46..ee361f5b 100644 --- a/docs/src/pages/framed/RadioButton/ProgrammaticRadioButton.svelte +++ b/docs/src/pages/framed/RadioButton/ProgrammaticRadioButton.svelte @@ -2,7 +2,6 @@ import { ButtonSet, Button, - FormGroup, RadioButtonGroup, RadioButton, } from "carbon-components-svelte"; @@ -10,17 +9,17 @@ let plan = "standard"; - - - - - - - + + + + + - + {#each ["free", "standard", "pro"] as value}