@thecb/components 9.5.0-beta.4 → 9.5.0-beta.6
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 +31 -39
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +31 -39
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/radio-section/InnerRadioSection.js +10 -10
- package/src/components/molecules/radio-section/RadioSection.js +15 -5
- package/src/components/molecules/radio-section/RadioSection.stories.js +11 -4
- package/src/components/molecules/radio-section/RadioSection.theme.js +2 -2
- package/src/components/molecules/radio-section/InnerRadioSection.theme.js +0 -15
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React, { Fragment } from "react";
|
|
2
2
|
import styled from "styled-components";
|
|
3
|
-
import { themeComponent } from "../../../util/themeUtils";
|
|
4
|
-
import { fallbackValues } from "./InnerRadioSection.theme";
|
|
5
3
|
import { AnimatePresence } from "framer-motion";
|
|
6
4
|
import RadioButton from "./radio-button/RadioButton";
|
|
7
5
|
import { Box, Cluster, Stack, Motion } from "../../atoms/layouts";
|
|
8
6
|
import { createIdFromString, noop } from "../../../util/general";
|
|
9
7
|
import Text from "../../atoms/text";
|
|
10
8
|
import { CHARADE_GREY } from "../../../constants/colors";
|
|
9
|
+
import { MANATEE_GREY } from "../../../constants/colors";
|
|
11
10
|
|
|
12
11
|
const idString = section =>
|
|
13
12
|
typeof section.title === "string"
|
|
@@ -30,6 +29,7 @@ const InnerRadioSection = ({
|
|
|
30
29
|
setFocused,
|
|
31
30
|
sectionRefs,
|
|
32
31
|
ariaLabelledBy,
|
|
32
|
+
isLastGroupedItemInSection,
|
|
33
33
|
onKeyDown = noop
|
|
34
34
|
}) => {
|
|
35
35
|
const wrapper = {
|
|
@@ -56,7 +56,9 @@ const InnerRadioSection = ({
|
|
|
56
56
|
|
|
57
57
|
const borderStyles = `
|
|
58
58
|
border-width: 0 0 1px 0;
|
|
59
|
-
border-color: ${
|
|
59
|
+
border-color: ${
|
|
60
|
+
isLastGroupedItemInSection ? MANATEE_GREY : themeValues.borderColor
|
|
61
|
+
};
|
|
60
62
|
border-style: solid;
|
|
61
63
|
border-radius: 0px;
|
|
62
64
|
transform-origin: 100% 0;
|
|
@@ -120,7 +122,9 @@ const InnerRadioSection = ({
|
|
|
120
122
|
borderSize="0px"
|
|
121
123
|
borderColor={themeValues.borderColor}
|
|
122
124
|
borderWidthOverride={
|
|
123
|
-
openSection === section.id &&
|
|
125
|
+
openSection === section.id &&
|
|
126
|
+
!!section.content &&
|
|
127
|
+
section.id !== openSection
|
|
124
128
|
? `0px 0px 1px 0px`
|
|
125
129
|
: ``
|
|
126
130
|
}
|
|
@@ -194,7 +198,7 @@ const InnerRadioSection = ({
|
|
|
194
198
|
animate="open"
|
|
195
199
|
exit="closed"
|
|
196
200
|
variants={wrapper}
|
|
197
|
-
extraStyles={`transform-origin: 100% 0
|
|
201
|
+
extraStyles={`transform-origin: 100% 0; border-top: 1px solid ${themeValues.borderColor}`}
|
|
198
202
|
>
|
|
199
203
|
{section.content}
|
|
200
204
|
</Motion>
|
|
@@ -205,8 +209,4 @@ const InnerRadioSection = ({
|
|
|
205
209
|
);
|
|
206
210
|
};
|
|
207
211
|
|
|
208
|
-
export default
|
|
209
|
-
InnerRadioSection,
|
|
210
|
-
"InnerRadioSection",
|
|
211
|
-
fallbackValues
|
|
212
|
-
);
|
|
212
|
+
export default InnerRadioSection;
|
|
@@ -4,7 +4,6 @@ import { fallbackValues } from "./RadioSection.theme";
|
|
|
4
4
|
import SolidDivider from "../../atoms/solid-divider/SolidDivider";
|
|
5
5
|
import { Box, Stack } from "../../atoms/layouts";
|
|
6
6
|
import { createIdFromString, wrapIndex } from "../../../util/general";
|
|
7
|
-
import { MANATEE_GREY } from "../../../constants/colors";
|
|
8
7
|
import {
|
|
9
8
|
ARROW_DOWN,
|
|
10
9
|
ARROW_LEFT,
|
|
@@ -14,6 +13,8 @@ import {
|
|
|
14
13
|
SPACEBAR
|
|
15
14
|
} from "../../../constants/keyboard";
|
|
16
15
|
import InnerRadioSection from "./InnerRadioSection";
|
|
16
|
+
import { MANATEE_GREY } from "../../../constants/colors";
|
|
17
|
+
|
|
17
18
|
/**
|
|
18
19
|
- The RadioSection component takes either a flat array (via the 'sections'
|
|
19
20
|
prop) of section objects or a multidimensional array (via the 'groupedSections' prop) of section objects. Note that if using a multidimensional array, the nesting cannot exceed 2 levels deep.
|
|
@@ -111,6 +112,7 @@ const RadioSection = ({
|
|
|
111
112
|
.map((section, i) => (
|
|
112
113
|
<Fragment key={`radio-section-${sections.indexOf(section)}`}>
|
|
113
114
|
<InnerRadioSection
|
|
115
|
+
themeValues={themeValues}
|
|
114
116
|
sectionIndex={i}
|
|
115
117
|
section={section}
|
|
116
118
|
sectionRefs={sectionRefs}
|
|
@@ -124,17 +126,19 @@ const RadioSection = ({
|
|
|
124
126
|
}
|
|
125
127
|
ariaLabelledBy={section.id}
|
|
126
128
|
ariaDescribedBy={`right-icons-${idString(section)}`}
|
|
129
|
+
isLastGroupedItemInSection={false}
|
|
127
130
|
/>
|
|
128
131
|
</Fragment>
|
|
129
132
|
))}
|
|
130
133
|
{!!groupedSections &&
|
|
131
|
-
groupedSections.map((sectionGroup,
|
|
134
|
+
groupedSections.map((sectionGroup, sectionGroupIndex) =>
|
|
132
135
|
sectionGroup
|
|
133
136
|
.filter(unfilteredSection => !unfilteredSection.hidden)
|
|
134
137
|
.map((section, sectionIndex) => (
|
|
135
|
-
<Fragment key={`key-${
|
|
138
|
+
<Fragment key={`key-${sectionGroupIndex}-${sectionIndex}`}>
|
|
136
139
|
<InnerRadioSection
|
|
137
|
-
|
|
140
|
+
themeValues={themeValues}
|
|
141
|
+
sectionIndex={`${sectionGroupIndex}-${sectionIndex}`}
|
|
138
142
|
section={section}
|
|
139
143
|
sectionRefs={sectionRefs}
|
|
140
144
|
focused={focused}
|
|
@@ -144,11 +148,17 @@ const RadioSection = ({
|
|
|
144
148
|
ariaDescribedBy={`right-icons-${idString(section)}`}
|
|
145
149
|
openSection={openSection}
|
|
146
150
|
toggleOpenSection={toggleOpenSection}
|
|
151
|
+
isLastGroupedItemInSection={
|
|
152
|
+
sectionGroup.indexOf(section) === sectionGroup.length - 1
|
|
153
|
+
}
|
|
147
154
|
/>
|
|
148
155
|
{sectionGroup.indexOf(section) === sectionGroup.length - 1 &&
|
|
149
156
|
groupedSections.indexOf(sectionGroup) !==
|
|
150
157
|
groupedSections.length - 1 && (
|
|
151
|
-
<SolidDivider
|
|
158
|
+
<SolidDivider
|
|
159
|
+
borderSize="1px"
|
|
160
|
+
borderColor={MANATEE_GREY}
|
|
161
|
+
/>
|
|
152
162
|
)}
|
|
153
163
|
</Fragment>
|
|
154
164
|
))
|
|
@@ -52,13 +52,21 @@ const groupedSections = [
|
|
|
52
52
|
content: <p>The form to add a credit card would go here.</p>,
|
|
53
53
|
rightIconsLabel: cardIconsLabel,
|
|
54
54
|
rightIcons: cardIcons,
|
|
55
|
-
required: true
|
|
55
|
+
required: true,
|
|
56
|
+
dataQa: "New Card"
|
|
56
57
|
},
|
|
57
58
|
{
|
|
58
59
|
id: "new-bank-section",
|
|
59
60
|
title: "Group 1: New Bank Account",
|
|
60
61
|
content: <p>The form to add a credit card would go here.</p>,
|
|
61
62
|
required: true
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
id: "bar4",
|
|
67
|
+
title: "Group 1: Another One",
|
|
68
|
+
content: <div>Content for another section</div>,
|
|
69
|
+
required: true
|
|
62
70
|
}
|
|
63
71
|
],
|
|
64
72
|
[
|
|
@@ -109,7 +117,7 @@ export const radioSection = () => {
|
|
|
109
117
|
<>
|
|
110
118
|
<Box padding="0 1rem" extraStyles="text-align: center;">
|
|
111
119
|
<p>
|
|
112
|
-
Using <b>sections</b
|
|
120
|
+
Using <b>sections</b>
|
|
113
121
|
</p>
|
|
114
122
|
</Box>
|
|
115
123
|
<RadioSection
|
|
@@ -124,8 +132,7 @@ export const radioSection = () => {
|
|
|
124
132
|
<Box />
|
|
125
133
|
<Box padding="0 1rem" extraStyles="text-align: center;">
|
|
126
134
|
<p>
|
|
127
|
-
Using <b>groupedSections</b
|
|
128
|
-
instead of the <b>sections</b> prop.
|
|
135
|
+
Using <b>groupedSections</b>
|
|
129
136
|
</p>
|
|
130
137
|
</Box>
|
|
131
138
|
<RadioSection
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { WHITE,
|
|
1
|
+
import { WHITE, GHOST_GREY, ATHENS_GREY } from "../../../constants/colors";
|
|
2
2
|
|
|
3
3
|
const headingBackgroundColor = `${WHITE}`;
|
|
4
4
|
const headingDisabledColor = `${ATHENS_GREY}`;
|
|
5
5
|
const bodyBackgroundColor = "#eeeeee";
|
|
6
|
-
const borderColor = `${
|
|
6
|
+
const borderColor = `${GHOST_GREY}`;
|
|
7
7
|
const focusStyles = `outline: none;`;
|
|
8
8
|
|
|
9
9
|
export const fallbackValues = {
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { WHITE, GREY_CHATEAU, ATHENS_GREY } from "../../../constants/colors";
|
|
2
|
-
|
|
3
|
-
const headingBackgroundColor = `${WHITE}`;
|
|
4
|
-
const headingDisabledColor = `${ATHENS_GREY}`;
|
|
5
|
-
const bodyBackgroundColor = "#eeeeee";
|
|
6
|
-
const borderColor = `${GREY_CHATEAU}`;
|
|
7
|
-
const focusStyles = `outline: none;`;
|
|
8
|
-
|
|
9
|
-
export const fallbackValues = {
|
|
10
|
-
headingBackgroundColor,
|
|
11
|
-
headingDisabledColor,
|
|
12
|
-
bodyBackgroundColor,
|
|
13
|
-
borderColor,
|
|
14
|
-
focusStyles
|
|
15
|
-
};
|