@thecb/components 9.0.3-beta.8 → 9.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "9.0.3-beta.8",
3
+ "version": "9.0.3",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -31,7 +31,7 @@ import { CHARADE_GREY } from "../../../constants/colors";
31
31
 
32
32
  */
33
33
 
34
- const computeSectionId = section =>
34
+ const idString = section =>
35
35
  typeof section.title === "string"
36
36
  ? createIdFromString(section.title)
37
37
  : section.id;
@@ -47,10 +47,7 @@ const RadioSection = ({
47
47
  initiallyOpen = true,
48
48
  openHeight = "auto",
49
49
  containerStyles = "",
50
- ariaDescribedBy,
51
- rightContentRole = null,
52
- ariaLabel = null,
53
- rightIconsLabel = null
50
+ ariaDescribedBy
54
51
  }) => {
55
52
  const handleKeyDown = (id, e) => {
56
53
  if (e?.keyCode === 13 || e?.keyCode === 32) {
@@ -126,6 +123,7 @@ const RadioSection = ({
126
123
  extraStyles={borderStyles}
127
124
  role="radio"
128
125
  aria-checked={openSection === section.id}
126
+ aria-disabled={section.disabled}
129
127
  >
130
128
  <Stack childGap="0">
131
129
  <Box
@@ -168,12 +166,9 @@ const RadioSection = ({
168
166
  {!section.hideRadioButton && (
169
167
  <Box padding="0">
170
168
  <RadioButton
171
- id={computeSectionId(section)}
172
- name={computeSectionId(section)}
169
+ id={`radio-input-${idString(section)}`}
170
+ name={idString(section)}
173
171
  ariaDescribedBy={ariaDescribedBy}
174
- ariaLabelledBy={`radio-input-${computeSectionId(
175
- section
176
- )}`}
177
172
  radioOn={openSection === section.id}
178
173
  radioFocused={focused === section.id}
179
174
  toggleRadio={
@@ -191,15 +186,19 @@ const RadioSection = ({
191
186
  <Box padding={section.titleIcon ? "0 0 0 8px" : "0"}>
192
187
  <Text
193
188
  as="label"
189
+ htmlFor={`radio-input-${idString(section)}`}
194
190
  color={CHARADE_GREY}
195
- htmlFor={`radio-input-${computeSectionId(section)}`}
196
191
  >
197
192
  {section.title}
198
193
  </Text>
199
194
  </Box>
200
195
  </Cluster>
201
196
  {section.rightIcons && (
202
- <Cluster childGap="0.5rem" aria-label={rightIconsLabel}>
197
+ <Cluster
198
+ childGap="0.5rem"
199
+ aria-label={section?.rightIconsLabel || null}
200
+ role={section?.rightIconsRole || null}
201
+ >
203
202
  {section.rightIcons.map(icon => (
204
203
  <RightIcon
205
204
  src={icon.img}
@@ -207,9 +206,7 @@ const RadioSection = ({
207
206
  fade={!icon.enabled}
208
207
  isMobile={isMobile}
209
208
  alt={icon.altText}
210
- {...(rightContentRole !== null
211
- ? { role: rightContentRole || "presentation" }
212
- : {})}
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
- { id: "foo", title: "Foo", content: <div>Content 0</div> },
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
  ];