@thecb/components 9.0.3-beta.11 → 9.0.3-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +15 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +15 -16
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/radio-section/RadioSection.js +9 -12
- package/src/components/molecules/radio-section/RadioSection.stories.js +40 -1
package/package.json
CHANGED
|
@@ -31,7 +31,7 @@ import { CHARADE_GREY } from "../../../constants/colors";
|
|
|
31
31
|
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const idString = section =>
|
|
35
35
|
typeof section.title === "string"
|
|
36
36
|
? createIdFromString(section.title)
|
|
37
37
|
: section.id;
|
|
@@ -47,8 +47,7 @@ const RadioSection = ({
|
|
|
47
47
|
initiallyOpen = true,
|
|
48
48
|
openHeight = "auto",
|
|
49
49
|
containerStyles = "",
|
|
50
|
-
ariaDescribedBy
|
|
51
|
-
rightIconsLabel = null
|
|
50
|
+
ariaDescribedBy
|
|
52
51
|
}) => {
|
|
53
52
|
const handleKeyDown = (id, e) => {
|
|
54
53
|
if (e?.keyCode === 13 || e?.keyCode === 32) {
|
|
@@ -124,6 +123,7 @@ const RadioSection = ({
|
|
|
124
123
|
extraStyles={borderStyles}
|
|
125
124
|
role="radio"
|
|
126
125
|
aria-checked={openSection === section.id}
|
|
126
|
+
aria-disabled={section.disabled}
|
|
127
127
|
>
|
|
128
128
|
<Stack childGap="0">
|
|
129
129
|
<Box
|
|
@@ -166,12 +166,9 @@ const RadioSection = ({
|
|
|
166
166
|
{!section.hideRadioButton && (
|
|
167
167
|
<Box padding="0">
|
|
168
168
|
<RadioButton
|
|
169
|
-
id={
|
|
170
|
-
name={
|
|
169
|
+
id={`radio-input-${idString(section)}`}
|
|
170
|
+
name={idString(section)}
|
|
171
171
|
ariaDescribedBy={ariaDescribedBy}
|
|
172
|
-
ariaLabelledBy={`radio-input-${computeSectionId(
|
|
173
|
-
section
|
|
174
|
-
)}`}
|
|
175
172
|
radioOn={openSection === section.id}
|
|
176
173
|
radioFocused={focused === section.id}
|
|
177
174
|
toggleRadio={
|
|
@@ -189,8 +186,8 @@ const RadioSection = ({
|
|
|
189
186
|
<Box padding={section.titleIcon ? "0 0 0 8px" : "0"}>
|
|
190
187
|
<Text
|
|
191
188
|
as="label"
|
|
189
|
+
htmlFor={`radio-input-${idString(section)}`}
|
|
192
190
|
color={CHARADE_GREY}
|
|
193
|
-
htmlFor={`radio-input-${computeSectionId(section)}`}
|
|
194
191
|
>
|
|
195
192
|
{section.title}
|
|
196
193
|
</Text>
|
|
@@ -199,9 +196,8 @@ const RadioSection = ({
|
|
|
199
196
|
{section.rightIcons && (
|
|
200
197
|
<Cluster
|
|
201
198
|
childGap="0.5rem"
|
|
202
|
-
{
|
|
203
|
-
|
|
204
|
-
: {})}
|
|
199
|
+
aria-label={section?.rightIconsLabel || null}
|
|
200
|
+
role={section?.rightIconsRole || null}
|
|
205
201
|
>
|
|
206
202
|
{section.rightIcons.map(icon => (
|
|
207
203
|
<RightIcon
|
|
@@ -210,6 +206,7 @@ const RadioSection = ({
|
|
|
210
206
|
fade={!icon.enabled}
|
|
211
207
|
isMobile={isMobile}
|
|
212
208
|
alt={icon.altText}
|
|
209
|
+
aria-disabled={!icon.enabled}
|
|
213
210
|
/>
|
|
214
211
|
))}
|
|
215
212
|
</Cluster>
|
|
@@ -10,8 +10,47 @@ const story = page({
|
|
|
10
10
|
});
|
|
11
11
|
export default story;
|
|
12
12
|
|
|
13
|
+
const cardIcons = [
|
|
14
|
+
{
|
|
15
|
+
img: "https://cityville-demos.uat.cityba.se/Visa.svg",
|
|
16
|
+
enabled: true,
|
|
17
|
+
altText: "visa",
|
|
18
|
+
name: "VISA"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
img: "https://cityville-demos.uat.cityba.se/MasterCardDark.svg",
|
|
22
|
+
enabled: false,
|
|
23
|
+
altText: "master card",
|
|
24
|
+
name: "MASTERCARD"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
img: "https://cityville-demos.uat.cityba.se/DiscoverDark.svg",
|
|
28
|
+
enabled: true,
|
|
29
|
+
altText: "discover",
|
|
30
|
+
name: "DISCOVER"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
img: "https://cityville-demos.uat.cityba.se/AmEx.svg",
|
|
34
|
+
enabled: true,
|
|
35
|
+
altText: "american express",
|
|
36
|
+
name: "AMEX"
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
const cardIconsLabel = `Accepting ${cardIcons
|
|
40
|
+
.filter(ci => ci.enabled)
|
|
41
|
+
?.map((cardIcon, index) =>
|
|
42
|
+
index === cardIcons.length - 1
|
|
43
|
+
? ` and ${cardIcon.altText}.`
|
|
44
|
+
: ` ` + cardIcon.altText
|
|
45
|
+
)}`;
|
|
13
46
|
const sections = [
|
|
14
|
-
{
|
|
47
|
+
{
|
|
48
|
+
id: "new-card-section",
|
|
49
|
+
title: "New Card",
|
|
50
|
+
content: <p>The form to add a credit card would go here.</p>,
|
|
51
|
+
rightIconsLabel: cardIconsLabel,
|
|
52
|
+
rightIcons: cardIcons
|
|
53
|
+
},
|
|
15
54
|
{ id: "bar", title: "Bar", content: <div>Content 1</div> },
|
|
16
55
|
{ id: "baz", title: "Baz", content: <div>Content 2</div> }
|
|
17
56
|
];
|