@orangesk/orange-design-system 2.0.0-beta.19 → 2.0.0-beta.20
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/README.md +346 -19
- package/build/components/Accordion/style.css +1 -1
- package/build/components/Accordion/style.css.map +1 -1
- package/build/components/Alert/style.css +1 -1
- package/build/components/Alert/style.css.map +1 -1
- package/build/components/AnchorNavigation/style.css +1 -1
- package/build/components/AnchorNavigation/style.css.map +1 -1
- package/build/components/BlockAction/style.css +1 -1
- package/build/components/BlockAction/style.css.map +1 -1
- package/build/components/CarouselPromotions/style.css +1 -1
- package/build/components/CarouselPromotions/style.css.map +1 -1
- package/build/components/FeatureAccordion/style.css +1 -1
- package/build/components/FeatureAccordion/style.css.map +1 -1
- package/build/components/Footer/style.css +1 -1
- package/build/components/Footer/style.css.map +1 -1
- package/build/components/Hero/style.css +1 -1
- package/build/components/Hero/style.css.map +1 -1
- package/build/components/Megamenu/style.css +1 -1
- package/build/components/Megamenu/style.css.map +1 -1
- package/build/components/Modal/style.css +1 -1
- package/build/components/Modal/style.css.map +1 -1
- package/build/components/Progress/style.css +1 -1
- package/build/components/Progress/style.css.map +1 -1
- package/build/components/PromoBanner/style.css +1 -1
- package/build/components/PromoBanner/style.css.map +1 -1
- package/build/components/PromotionCard/style.css +1 -1
- package/build/components/PromotionCard/style.css.map +1 -1
- package/build/components/Tag/style.css +1 -1
- package/build/components/Tag/style.css.map +1 -1
- package/build/components/Tile/style.css +1 -1
- package/build/components/Tile/style.css.map +1 -1
- package/build/components/index.js +1 -1
- package/build/components/index.js.map +1 -1
- package/build/components/tsconfig.tsbuildinfo +1 -1
- package/build/components/types/index.d.ts +5 -40
- package/build/components/types/src/components/Alert/Alert.d.ts +0 -2
- package/build/components/types/src/components/AnchorNavigation/AnchorNavigation.d.ts +1 -2
- package/build/components/types/src/components/BlockAction/BlockAction.d.ts +2 -0
- package/build/components/types/src/components/BlockAction/Context.d.ts +2 -0
- package/build/components/types/src/components/Breadcrumbs/Breadcrumbs.d.ts +0 -2
- package/build/components/types/src/components/Button/Button.d.ts +0 -1
- package/build/components/types/src/components/Card/index.d.ts +1 -0
- package/build/components/types/src/components/Carousel/Carousel.d.ts +0 -2
- package/build/components/types/src/components/CarouselHero/CarouselHero.d.ts +0 -1
- package/build/components/types/src/components/CarouselPromotions/CarouselPromotions.d.ts +0 -1
- package/build/components/types/src/components/Controls/Controls.d.ts +0 -1
- package/build/components/types/src/components/Expander/Expander.d.ts +0 -3
- package/build/components/types/src/components/FeatureAccordion/FeatureAccordion.d.ts +0 -2
- package/build/components/types/src/components/Forms/InputStepper/InputStepper.d.ts +0 -1
- package/build/components/types/src/components/Hero/Hero.d.ts +0 -3
- package/build/components/types/src/components/Icon/iconSearchTags.d.ts +167 -166
- package/build/components/types/src/components/Link/Link.d.ts +0 -2
- package/build/components/types/src/components/Megamenu/static.d.ts +2 -3
- package/build/components/types/src/components/Modal/Modal.d.ts +0 -2
- package/build/components/types/src/components/Pagination/Pagination.d.ts +0 -2
- package/build/components/types/src/components/Pill/Pill.d.ts +0 -1
- package/build/components/types/src/components/Progress/Progress.d.ts +0 -1
- package/build/components/types/src/components/PromoBanner/PromoBanner.d.ts +1 -2
- package/build/components/types/src/components/PromotionCard/PromotionCard.d.ts +2 -2
- package/build/components/types/src/components/Stepbar/Stepbar.d.ts +0 -2
- package/build/components/types/src/components/Table/Table.d.ts +0 -2
- package/build/components/types/src/components/Tabs/Tabs.d.ts +0 -2
- package/build/components/types/src/components/Tooltip/Tooltip.d.ts +0 -1
- package/build/components/types/src/scripts/index.d.ts +2 -3
- package/build/components/types/src/styles/export/color.d.ts +102 -20
- package/build/lib/base.css +1 -1
- package/build/lib/base.css.map +1 -1
- package/build/lib/components.css +1 -1
- package/build/lib/components.css.map +1 -1
- package/build/lib/footer.css +1 -1
- package/build/lib/footer.css.map +1 -1
- package/build/lib/megamenu.css +1 -1
- package/build/lib/megamenu.css.map +1 -1
- package/build/lib/megamenu.js +1 -1
- package/build/lib/megamenu.js.map +1 -1
- package/build/lib/scripts.js +1 -1
- package/build/lib/scripts.js.map +1 -1
- package/build/lib/style.css +1 -1
- package/build/lib/style.css.map +1 -1
- package/build/lib/tsconfig.tsbuildinfo +1 -1
- package/build/lib/utilities.css +1 -1
- package/build/lib/utilities.css.map +1 -1
- package/build/sprite.svg +1 -1
- package/package.json +13 -13
- package/src/assets/icons/quote.svg +4 -0
- package/src/components/Accordion/styles/mixins.scss +2 -0
- package/src/components/Alert/Alert.tsx +0 -6
- package/src/components/Alert/styles/mixins.scss +3 -1
- package/src/components/Alert/tests/Alert.test.js +0 -14
- package/src/components/AnchorNavigation/AnchorNavigation.tsx +1 -10
- package/src/components/AnchorNavigation/tests/AnchorNavigation.conformance.test.js +0 -9
- package/src/components/BlockAction/BlockAction.tsx +10 -3
- package/src/components/BlockAction/Context.tsx +4 -0
- package/src/components/BlockAction/styles/mixins.scss +6 -0
- package/src/components/BlockAction/styles/style.scss +5 -0
- package/src/components/Breadcrumbs/BreadcrumbItem.tsx +16 -7
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +4 -12
- package/src/components/Breadcrumbs/tests/BreadcrumbItem.unit.test.js +14 -8
- package/src/components/Breadcrumbs/tests/Breadcrumbs.integration.test.js +14 -37
- package/src/components/Breadcrumbs/tests/Breadcrumbs.unit.test.js +19 -23
- package/src/components/Button/Button.tsx +0 -4
- package/src/components/Button/tests/Button.test.js +0 -10
- package/src/components/Card/index.ts +1 -0
- package/src/components/Carousel/Carousel.static.ts +5 -0
- package/src/components/Carousel/Carousel.tsx +0 -5
- package/src/components/Carousel/tests/Carousel.unit.test.js +0 -21
- package/src/components/CarouselHero/CarouselHero.tsx +1 -9
- package/src/components/CarouselHero/tests/CarouselHero.conformance.test.js +0 -1
- package/src/components/CarouselHero/tests/CarouselHero.unit.test.js +0 -14
- package/src/components/CarouselPromotions/CarouselPromotions.tsx +1 -6
- package/src/components/CarouselPromotions/styles/mixins.scss +6 -3
- package/src/components/CarouselPromotions/tests/CarouselPromotions.unit.test.js +0 -17
- package/src/components/Controls/Controls.tsx +2 -7
- package/src/components/Controls/tests/Controls.test.js +0 -23
- package/src/components/Expander/Expander.tsx +0 -6
- package/src/components/Expander/tests/Expander.conformance.test.js +8 -12
- package/src/components/Expander/tests/Expander.unit.test.js +37 -47
- package/src/components/FeatureAccordion/FeatureAccordion.tsx +2 -12
- package/src/components/FeatureAccordion/styles/mixins.scss +6 -14
- package/src/components/FeatureAccordion/styles/style.scss +2 -4
- package/src/components/FeatureAccordion/tests/FeatureAccordion.unit.test.js +0 -5
- package/src/components/Footer/styles/mixins.scss +1 -0
- package/src/components/Forms/InputStepper/InputStepper.tsx +0 -4
- package/src/components/Forms/Label/styles/config.scss +3 -0
- package/src/components/Hero/Hero.tsx +2 -16
- package/src/components/Hero/styles/style.scss +0 -14
- package/src/components/Hero/tests/Hero.unit.test.js +109 -119
- package/src/components/Icon/iconSearchTags.ts +167 -166
- package/src/components/Link/Link.tsx +0 -5
- package/src/components/Link/tests/Link.conformance.test.js +1 -7
- package/src/components/Link/tests/Link.unit.test.js +0 -20
- package/src/components/Megamenu/static.ts +5 -2
- package/src/components/Modal/Modal.tsx +0 -5
- package/src/components/Modal/styles/mixins.scss +7 -0
- package/src/components/Modal/styles/style.scss +1 -0
- package/src/components/Modal/tests/Modal.unit.test.js +0 -22
- package/src/components/Pagination/Pagination.tsx +1 -11
- package/src/components/Pill/Pill.tsx +0 -4
- package/src/components/Pill/tests/Pill.conformance.test.js +0 -4
- package/src/components/Pill/tests/Pill.unit.test.js +0 -18
- package/src/components/Progress/Progress.tsx +1 -13
- package/src/components/Progress/styles/mixins.scss +9 -7
- package/src/components/PromoBanner/PromoBanner.tsx +1 -10
- package/src/components/PromoBanner/styles/mixins.scss +0 -3
- package/src/components/PromoBanner/tests/PromoBanner.conformance.test.js +0 -30
- package/src/components/PromoBanner/tests/PromoBanner.unit.test.js +1 -33
- package/src/components/PromotionCard/PromotionCard.tsx +4 -6
- package/src/components/PromotionCard/styles/mixins.scss +1 -0
- package/src/components/PromotionCard/tests/PromotionCard.conformance.test.js +18 -19
- package/src/components/PromotionCard/tests/PromotionCard.unit.test.js +12 -74
- package/src/components/Stepbar/Stepbar.tsx +0 -5
- package/src/components/Table/Table.tsx +0 -5
- package/src/components/Table/tests/Table.unit.test.js +0 -31
- package/src/components/Tabs/Tabs.tsx +0 -5
- package/src/components/Tabs/tests/Tabs.unit.test.js +0 -8
- package/src/components/Tag/styles/config.scss +1 -1
- package/src/components/Tag/styles/style.scss +10 -9
- package/src/components/Tile/styles/mixins.scss +1 -0
- package/src/components/Tooltip/Tooltip.tsx +1 -10
- package/src/components/Tooltip/tests/Tooltip.unit.test.js +0 -29
- package/src/styles/base/globals.scss +9 -0
- package/src/styles/base/styleguide.scss +6 -2
- package/src/styles/export/color.js +102 -20
- package/src/styles/export/color.scss +10 -20
- package/src/styles/typography/config.scss +83 -37
- package/src/styles/typography/mixins.scss +3 -3
- package/src/styles/utilities/text.scss +26 -2
- package/src/components/Pagination/tests/utils.js +0 -12
|
@@ -69,16 +69,6 @@ describe("rendering", () => {
|
|
|
69
69
|
expect(getByText("Button")).toHaveClass("is-active");
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
it("has is-dark class when colorScheme is dark", () => {
|
|
73
|
-
const { getByText } = render(<Button colorScheme="dark">Button</Button>);
|
|
74
|
-
expect(getByText("Button")).toHaveClass("is-dark");
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("has is-light class when colorScheme is light", () => {
|
|
78
|
-
const { getByText } = render(<Button colorScheme="light">Button</Button>);
|
|
79
|
-
expect(getByText("Button")).toHaveClass("is-light");
|
|
80
|
-
});
|
|
81
|
-
|
|
82
72
|
it("has btn--square class when squared", () => {
|
|
83
73
|
const { getByText } = render(<Button isSquare>Button</Button>);
|
|
84
74
|
expect(getByText("Button")).toHaveClass("btn--square");
|
|
@@ -309,6 +309,11 @@ export default class Carousel {
|
|
|
309
309
|
viewportWrapper: HTMLElement,
|
|
310
310
|
bleedAmount: number,
|
|
311
311
|
): void {
|
|
312
|
+
// Safety check: ensure instance and params are initialized
|
|
313
|
+
if (!this.instance || !this.instance.params) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
312
317
|
const visibleWidth = viewportWrapper.clientWidth;
|
|
313
318
|
const totalWidth = this.track.scrollWidth;
|
|
314
319
|
const contentFitsWithoutScroll = totalWidth <= visibleWidth + 5;
|
|
@@ -23,8 +23,6 @@ import { useStatic } from "@/utils/hooks";
|
|
|
23
23
|
interface CarouselProps extends HTMLAttributes<HTMLDivElement> {
|
|
24
24
|
/** Swiper.js (https://swiperjs.com/) options object */
|
|
25
25
|
swiperOptions?: Record<string, any>;
|
|
26
|
-
/** Inverse colors */
|
|
27
|
-
colorScheme?: "light" | "dark";
|
|
28
26
|
/** Carousel items */
|
|
29
27
|
items: ReactNode[];
|
|
30
28
|
/** Always show scrollbar and hide dots */
|
|
@@ -38,7 +36,6 @@ const Carousel: React.FC<CarouselProps> = ({
|
|
|
38
36
|
className,
|
|
39
37
|
swiperOptions,
|
|
40
38
|
items,
|
|
41
|
-
colorScheme,
|
|
42
39
|
showScrollbar = false,
|
|
43
40
|
bleedRight = false,
|
|
44
41
|
...other
|
|
@@ -50,8 +47,6 @@ const Carousel: React.FC<CarouselProps> = ({
|
|
|
50
47
|
));
|
|
51
48
|
|
|
52
49
|
const classes = cx(CLASS_ROOT, className, {
|
|
53
|
-
"is-dark": colorScheme === "dark",
|
|
54
|
-
"is-light": colorScheme === "light",
|
|
55
50
|
[`${CLASS_ROOT}--scrollbar`]: showScrollbar,
|
|
56
51
|
[`${CLASS_ROOT}--bleed-right`]: bleedRight,
|
|
57
52
|
});
|
|
@@ -183,27 +183,6 @@ describe("rendering Carousel", () => {
|
|
|
183
183
|
).toBeInTheDocument();
|
|
184
184
|
});
|
|
185
185
|
});
|
|
186
|
-
describe("colorScheme prop", () => {
|
|
187
|
-
const items = [<p key="item1">item1</p>];
|
|
188
|
-
it("adds is-dark class when colorScheme is dark", () => {
|
|
189
|
-
const { container } = render(
|
|
190
|
-
<Carousel items={items} colorScheme="dark" />,
|
|
191
|
-
);
|
|
192
|
-
expect(container.querySelector(".carousel")).toHaveClass("is-dark");
|
|
193
|
-
});
|
|
194
|
-
it("adds is-light class when colorScheme is light", () => {
|
|
195
|
-
const { container } = render(
|
|
196
|
-
<Carousel items={items} colorScheme="light" />,
|
|
197
|
-
);
|
|
198
|
-
expect(container.querySelector(".carousel")).toHaveClass("is-light");
|
|
199
|
-
});
|
|
200
|
-
it("does not add color scheme classes when colorScheme is not provided", () => {
|
|
201
|
-
const { container } = render(<Carousel items={items} />);
|
|
202
|
-
const carousel = container.querySelector(".carousel");
|
|
203
|
-
expect(carousel).not.toHaveClass("is-dark");
|
|
204
|
-
expect(carousel).not.toHaveClass("is-light");
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
186
|
|
|
208
187
|
describe("external controls integration", () => {
|
|
209
188
|
const items = [
|
|
@@ -30,7 +30,6 @@ interface TabItem {
|
|
|
30
30
|
interface CarouselHeroProps {
|
|
31
31
|
className?: string;
|
|
32
32
|
swiperOptions?: Record<string, any>;
|
|
33
|
-
colorScheme?: "light" | "dark";
|
|
34
33
|
children?: ReactNode;
|
|
35
34
|
tabs?: TabItem[];
|
|
36
35
|
interval?: number;
|
|
@@ -40,7 +39,6 @@ interface CarouselHeroProps {
|
|
|
40
39
|
const CarouselHero: React.FC<CarouselHeroProps> = ({
|
|
41
40
|
className,
|
|
42
41
|
swiperOptions,
|
|
43
|
-
colorScheme,
|
|
44
42
|
children,
|
|
45
43
|
tabs = [],
|
|
46
44
|
interval,
|
|
@@ -48,10 +46,7 @@ const CarouselHero: React.FC<CarouselHeroProps> = ({
|
|
|
48
46
|
}) => {
|
|
49
47
|
const [carouselRef] = useStatic(CarouselHeroStatic);
|
|
50
48
|
|
|
51
|
-
const classes = cx(CLASS_ROOT, className
|
|
52
|
-
"is-light": colorScheme === "light",
|
|
53
|
-
"is-dark": colorScheme === "dark",
|
|
54
|
-
});
|
|
49
|
+
const classes = cx(CLASS_ROOT, className);
|
|
55
50
|
|
|
56
51
|
const elementClasses = {
|
|
57
52
|
prev: CLASS_PREV,
|
|
@@ -115,14 +110,12 @@ const CarouselHero: React.FC<CarouselHeroProps> = ({
|
|
|
115
110
|
<Controls
|
|
116
111
|
className={elementClasses.prev}
|
|
117
112
|
icon="chevron-left"
|
|
118
|
-
colorScheme={colorScheme}
|
|
119
113
|
aria-label="Predchádzajúci snímok"
|
|
120
114
|
/>
|
|
121
115
|
|
|
122
116
|
<Controls
|
|
123
117
|
className={elementClasses.next}
|
|
124
118
|
icon="chevron-right"
|
|
125
|
-
colorScheme={colorScheme}
|
|
126
119
|
aria-label="Nasledujúci snímok"
|
|
127
120
|
/>
|
|
128
121
|
|
|
@@ -131,7 +124,6 @@ const CarouselHero: React.FC<CarouselHeroProps> = ({
|
|
|
131
124
|
<Controls
|
|
132
125
|
className={elementClasses.playPause}
|
|
133
126
|
icon={playPauseIcon}
|
|
134
|
-
colorScheme={colorScheme}
|
|
135
127
|
aria-label="Pozastaviť/Spustiť automatické prehrávanie"
|
|
136
128
|
/>
|
|
137
129
|
)}
|
|
@@ -123,20 +123,6 @@ describe("rendering CarouselHero", () => {
|
|
|
123
123
|
expect(getByTestId("test-id")).toHaveClass("test-class");
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
it("has is-light class when colorScheme is light", () => {
|
|
127
|
-
const { getByTestId } = render(
|
|
128
|
-
<CarouselHero data-testid="test-id" colorScheme="light" />,
|
|
129
|
-
);
|
|
130
|
-
expect(getByTestId("test-id")).toHaveClass("is-light");
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("has is-dark class when colorScheme is dark", () => {
|
|
134
|
-
const { getByTestId } = render(
|
|
135
|
-
<CarouselHero data-testid="test-id" colorScheme="dark" />,
|
|
136
|
-
);
|
|
137
|
-
expect(getByTestId("test-id")).toHaveClass("is-dark");
|
|
138
|
-
});
|
|
139
|
-
|
|
140
126
|
it("does not have is-light or is-dark class by default", () => {
|
|
141
127
|
const { getByTestId } = render(<CarouselHero data-testid="test-id" />);
|
|
142
128
|
expect(getByTestId("test-id")).not.toHaveClass("is-light");
|
|
@@ -17,7 +17,6 @@ import { useStatic } from "@/utils/hooks";
|
|
|
17
17
|
interface CarouselPromotionsProps {
|
|
18
18
|
className?: string;
|
|
19
19
|
swiperOptions?: Record<string, any>;
|
|
20
|
-
colorScheme?: "light" | "dark";
|
|
21
20
|
children?: ReactNode;
|
|
22
21
|
[key: string]: any;
|
|
23
22
|
}
|
|
@@ -25,16 +24,12 @@ interface CarouselPromotionsProps {
|
|
|
25
24
|
const CarouselPromotions: React.FC<CarouselPromotionsProps> = ({
|
|
26
25
|
className,
|
|
27
26
|
swiperOptions,
|
|
28
|
-
colorScheme,
|
|
29
27
|
children,
|
|
30
28
|
...other
|
|
31
29
|
}) => {
|
|
32
30
|
const [carouselRef] = useStatic(CarouselPromotionsStatic);
|
|
33
31
|
|
|
34
|
-
const classes = cx(CLASS_ROOT, className
|
|
35
|
-
"is-light": colorScheme === "light",
|
|
36
|
-
"is-dark": colorScheme === "dark",
|
|
37
|
-
});
|
|
32
|
+
const classes = cx(CLASS_ROOT, className);
|
|
38
33
|
|
|
39
34
|
const elementClasses = {
|
|
40
35
|
next: cx(CLASS_NEXT, "hide-lg"),
|
|
@@ -186,6 +186,8 @@
|
|
|
186
186
|
{
|
|
187
187
|
#{$property}: $value;
|
|
188
188
|
}
|
|
189
|
+
|
|
190
|
+
margin-bottom: space.get();
|
|
189
191
|
}
|
|
190
192
|
@include breakpoint.get("lg") {
|
|
191
193
|
@each $property,
|
|
@@ -193,9 +195,8 @@
|
|
|
193
195
|
{
|
|
194
196
|
#{$property}: $value;
|
|
195
197
|
}
|
|
196
|
-
|
|
197
|
-
margin-bottom: space.get();
|
|
198
198
|
}
|
|
199
|
+
font-weight: 700;
|
|
199
200
|
}
|
|
200
201
|
|
|
201
202
|
@mixin slide-content {
|
|
@@ -217,7 +218,9 @@
|
|
|
217
218
|
}
|
|
218
219
|
|
|
219
220
|
@include breakpoint.get("md", "down") {
|
|
220
|
-
@include generate.css-map(
|
|
221
|
+
@include generate.responsive-css-map(
|
|
222
|
+
sass-map.get(typography-config.$body-text, "small")
|
|
223
|
+
);
|
|
221
224
|
}
|
|
222
225
|
}
|
|
223
226
|
|
|
@@ -88,23 +88,6 @@ describe("rendering CarouselPromotions", () => {
|
|
|
88
88
|
container.querySelector(".carousel-promotions__pagination"),
|
|
89
89
|
).toBeInTheDocument();
|
|
90
90
|
});
|
|
91
|
-
it("has class is-dark when colorScheme='dark' is passed", () => {
|
|
92
|
-
const { getByTestId } = render(
|
|
93
|
-
<CarouselPromotions data-testid="test-id" colorScheme="dark">
|
|
94
|
-
{items}
|
|
95
|
-
</CarouselPromotions>,
|
|
96
|
-
);
|
|
97
|
-
expect(getByTestId("test-id")).toHaveClass("is-dark");
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("has class is-light when colorScheme='light' is passed", () => {
|
|
101
|
-
const { getByTestId } = render(
|
|
102
|
-
<CarouselPromotions data-testid="test-id" colorScheme="light">
|
|
103
|
-
{items}
|
|
104
|
-
</CarouselPromotions>,
|
|
105
|
-
);
|
|
106
|
-
expect(getByTestId("test-id")).toHaveClass("is-light");
|
|
107
|
-
});
|
|
108
91
|
|
|
109
92
|
it("passes swiperOptions as data-swiper-options attribute", () => {
|
|
110
93
|
const swiperOptions = { slidesPerView: 2 };
|
|
@@ -6,7 +6,6 @@ interface IControlsProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
6
6
|
elemRef?: React.Ref<any>;
|
|
7
7
|
icon: string;
|
|
8
8
|
className?: string;
|
|
9
|
-
colorScheme?: "dark" | "light";
|
|
10
9
|
isDisabled?: boolean;
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -23,12 +22,8 @@ type NativeButtonProps = IControlsProps &
|
|
|
23
22
|
export type ControlsProps = NativeButtonProps;
|
|
24
23
|
|
|
25
24
|
const Controls = React.forwardRef<any, ControlsProps>((props, ref) => {
|
|
26
|
-
const { elemRef, className, icon,
|
|
27
|
-
const classes = cx(
|
|
28
|
-
CLASS_ROOT,
|
|
29
|
-
{ "is-dark": colorScheme === "dark", "is-light": colorScheme === "light" },
|
|
30
|
-
className,
|
|
31
|
-
);
|
|
25
|
+
const { elemRef, className, icon, isDisabled, ...rest } = props;
|
|
26
|
+
const classes = cx(CLASS_ROOT, className);
|
|
32
27
|
|
|
33
28
|
const buttonProps = rest as React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
34
29
|
return (
|
|
@@ -34,29 +34,6 @@ describe("Controls Component", () => {
|
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
// Test colorScheme prop
|
|
38
|
-
describe("ColorScheme Prop", () => {
|
|
39
|
-
it('should apply dark styling when colorScheme is "dark"', () => {
|
|
40
|
-
render(<Controls icon="close" colorScheme="dark" />);
|
|
41
|
-
const button = screen.getByRole("button");
|
|
42
|
-
expect(button).toHaveClass("controls");
|
|
43
|
-
expect(button).toHaveClass("is-dark");
|
|
44
|
-
});
|
|
45
|
-
it('should apply light styling when colorScheme is "light"', () => {
|
|
46
|
-
render(<Controls icon="menu" colorScheme="light" />);
|
|
47
|
-
const button = screen.getByRole("button");
|
|
48
|
-
expect(button).toHaveClass("controls");
|
|
49
|
-
expect(button).toHaveClass("is-light");
|
|
50
|
-
});
|
|
51
|
-
it("should not apply dark or light styling when colorScheme is undefined", () => {
|
|
52
|
-
render(<Controls icon="search" />);
|
|
53
|
-
const button = screen.getByRole("button");
|
|
54
|
-
expect(button).toHaveClass("controls");
|
|
55
|
-
expect(button).not.toHaveClass("is-dark");
|
|
56
|
-
expect(button).not.toHaveClass("is-light");
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
37
|
// Test different icon types
|
|
61
38
|
describe("Icon Types", () => {
|
|
62
39
|
it("should render with close icon", () => {
|
|
@@ -11,9 +11,6 @@ import ExpanderStatic from "./Expander.static";
|
|
|
11
11
|
const CLASS_ROOT = "expander";
|
|
12
12
|
|
|
13
13
|
interface ExpanderProps {
|
|
14
|
-
/** Inverse buttons for dark backgrounds */
|
|
15
|
-
/** Dark theme */
|
|
16
|
-
colorScheme?: "light" | "dark";
|
|
17
14
|
/** Custom summary text renderer. Passes props as function parameter. */
|
|
18
15
|
renderSummary?: (props: ExpanderProps) => React.ReactNode;
|
|
19
16
|
/** Custom summary text renderer when details are opened. Passes props as function parameter. */
|
|
@@ -38,7 +35,6 @@ export const Expander: React.FC<ExpanderProps> = (props) => {
|
|
|
38
35
|
summaryOpened,
|
|
39
36
|
renderSummary,
|
|
40
37
|
renderSummaryOpened,
|
|
41
|
-
colorScheme,
|
|
42
38
|
isFullWidth,
|
|
43
39
|
...other
|
|
44
40
|
} = props;
|
|
@@ -48,8 +44,6 @@ export const Expander: React.FC<ExpanderProps> = (props) => {
|
|
|
48
44
|
CLASS_ROOT,
|
|
49
45
|
{
|
|
50
46
|
[`${CLASS_ROOT}--fullwidth`]: isFullWidth,
|
|
51
|
-
"is-dark": colorScheme === "dark",
|
|
52
|
-
"is-light": colorScheme === "light",
|
|
53
47
|
},
|
|
54
48
|
className,
|
|
55
49
|
);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { render } from
|
|
3
|
-
import { axe } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
|
+
import { axe } from "jest-axe";
|
|
4
4
|
|
|
5
|
-
import { Expander } from
|
|
6
|
-
import { Icon } from
|
|
5
|
+
import { Expander } from "../Expander";
|
|
6
|
+
import { Icon } from "../../Icon";
|
|
7
7
|
|
|
8
8
|
const example = (
|
|
9
9
|
<>
|
|
@@ -13,10 +13,6 @@ const example = (
|
|
|
13
13
|
Content
|
|
14
14
|
</Expander>
|
|
15
15
|
|
|
16
|
-
<Expander summary="Show details" colorScheme="dark">
|
|
17
|
-
Content
|
|
18
|
-
</Expander>
|
|
19
|
-
|
|
20
16
|
<Expander
|
|
21
17
|
summary="Custom summary"
|
|
22
18
|
renderSummary={({ summary }) => (
|
|
@@ -44,16 +40,16 @@ const example = (
|
|
|
44
40
|
</>
|
|
45
41
|
);
|
|
46
42
|
|
|
47
|
-
it(
|
|
43
|
+
it("is valid html", () => {
|
|
48
44
|
const { container } = render(example);
|
|
49
45
|
expect(container).toHTMLValidate({
|
|
50
46
|
rules: {
|
|
51
|
-
|
|
47
|
+
"element-permitted-content": "off",
|
|
52
48
|
},
|
|
53
49
|
});
|
|
54
50
|
});
|
|
55
51
|
|
|
56
|
-
it(
|
|
52
|
+
it("is accessible", async () => {
|
|
57
53
|
const { container } = render(example);
|
|
58
54
|
expect(await axe(container)).toHaveNoViolations();
|
|
59
55
|
});
|
|
@@ -1,42 +1,32 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { render, screen, fireEvent } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen, fireEvent } from "@testing-library/react";
|
|
3
3
|
|
|
4
|
-
import { Expander } from
|
|
5
|
-
import { Icon } from
|
|
4
|
+
import { Expander } from "../Expander";
|
|
5
|
+
import { Icon } from "../../Icon";
|
|
6
6
|
|
|
7
|
-
describe(
|
|
8
|
-
it(
|
|
7
|
+
describe("Expander", () => {
|
|
8
|
+
it("renders basic expander with summary text", () => {
|
|
9
9
|
render(<Expander summary="Show details">Content</Expander>);
|
|
10
|
-
expect(screen.getByText(
|
|
11
|
-
expect(screen.getByText(
|
|
10
|
+
expect(screen.getByText("Show details")).toBeInTheDocument();
|
|
11
|
+
expect(screen.getByText("Content")).toBeInTheDocument();
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
it(
|
|
14
|
+
it("changes summary text when opened", () => {
|
|
15
15
|
render(
|
|
16
16
|
<Expander summary="Show details" summaryOpened="Hide details">
|
|
17
17
|
Content
|
|
18
|
-
</Expander
|
|
18
|
+
</Expander>,
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
-
expect(screen.getByText(
|
|
21
|
+
expect(screen.getByText("Show details")).toBeInTheDocument();
|
|
22
22
|
|
|
23
23
|
// Click to open the expander
|
|
24
|
-
fireEvent.click(screen.getByText(
|
|
24
|
+
fireEvent.click(screen.getByText("Show details"));
|
|
25
25
|
|
|
26
|
-
expect(screen.getByText(
|
|
26
|
+
expect(screen.getByText("Hide details")).toBeInTheDocument();
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
it(
|
|
30
|
-
const { container } = render(
|
|
31
|
-
<Expander summary="Show details" colorScheme="dark">
|
|
32
|
-
Content
|
|
33
|
-
</Expander>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
expect(container.querySelector('.expander.is-dark')).toBeInTheDocument();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('renders custom summary with renderSummary prop', () => {
|
|
29
|
+
it("renders custom summary with renderSummary prop", () => {
|
|
40
30
|
render(
|
|
41
31
|
<Expander
|
|
42
32
|
summary="Custom summary"
|
|
@@ -48,15 +38,15 @@ describe('Expander', () => {
|
|
|
48
38
|
)}
|
|
49
39
|
>
|
|
50
40
|
Content
|
|
51
|
-
</Expander
|
|
41
|
+
</Expander>,
|
|
52
42
|
);
|
|
53
43
|
|
|
54
|
-
expect(screen.getByTestId(
|
|
55
|
-
|
|
44
|
+
expect(screen.getByTestId("custom-summary")).toHaveTextContent(
|
|
45
|
+
"Custom summary",
|
|
56
46
|
);
|
|
57
47
|
});
|
|
58
48
|
|
|
59
|
-
it(
|
|
49
|
+
it("renders custom summary when opened with renderSummaryOpened prop", () => {
|
|
60
50
|
render(
|
|
61
51
|
<Expander
|
|
62
52
|
summary="Show details"
|
|
@@ -69,46 +59,46 @@ describe('Expander', () => {
|
|
|
69
59
|
)}
|
|
70
60
|
>
|
|
71
61
|
Content
|
|
72
|
-
</Expander
|
|
62
|
+
</Expander>,
|
|
73
63
|
);
|
|
74
64
|
|
|
75
65
|
// Click to open the expander
|
|
76
|
-
fireEvent.click(screen.getByText(
|
|
66
|
+
fireEvent.click(screen.getByText("Show details"));
|
|
77
67
|
|
|
78
|
-
expect(screen.getByTestId(
|
|
79
|
-
|
|
68
|
+
expect(screen.getByTestId("custom-summary-opened")).toHaveTextContent(
|
|
69
|
+
"Hide details",
|
|
80
70
|
);
|
|
81
71
|
});
|
|
82
72
|
|
|
83
|
-
it(
|
|
73
|
+
it("toggles content visibility when clicked", () => {
|
|
84
74
|
const { container } = render(
|
|
85
75
|
<Expander summary="Show details">
|
|
86
76
|
<p data-testid="content">Hidden content</p>
|
|
87
|
-
</Expander
|
|
77
|
+
</Expander>,
|
|
88
78
|
);
|
|
89
79
|
|
|
90
|
-
const details = container.querySelector(
|
|
91
|
-
expect(details).not.toHaveAttribute(
|
|
80
|
+
const details = container.querySelector("details");
|
|
81
|
+
expect(details).not.toHaveAttribute("open");
|
|
92
82
|
|
|
93
83
|
// Click to open
|
|
94
|
-
fireEvent.click(screen.getByText(
|
|
95
|
-
expect(details).toHaveAttribute(
|
|
84
|
+
fireEvent.click(screen.getByText("Show details"));
|
|
85
|
+
expect(details).toHaveAttribute("open");
|
|
96
86
|
|
|
97
87
|
// Click to close
|
|
98
|
-
fireEvent.click(screen.getByText(
|
|
99
|
-
expect(details).not.toHaveAttribute(
|
|
88
|
+
fireEvent.click(screen.getByText("Show details"));
|
|
89
|
+
expect(details).not.toHaveAttribute("open");
|
|
100
90
|
});
|
|
101
91
|
|
|
102
|
-
it(
|
|
92
|
+
it("has default class expander", () => {
|
|
103
93
|
const { getByTestId } = render(
|
|
104
94
|
<Expander data-testid="test-id" summary="Show details">
|
|
105
95
|
Content
|
|
106
|
-
</Expander
|
|
96
|
+
</Expander>,
|
|
107
97
|
);
|
|
108
|
-
expect(getByTestId(
|
|
98
|
+
expect(getByTestId("test-id")).toHaveClass("expander");
|
|
109
99
|
});
|
|
110
100
|
|
|
111
|
-
it(
|
|
101
|
+
it("has additional class when className is set", () => {
|
|
112
102
|
const { getByTestId } = render(
|
|
113
103
|
<Expander
|
|
114
104
|
data-testid="test-id"
|
|
@@ -116,9 +106,9 @@ describe('Expander', () => {
|
|
|
116
106
|
summary="Show details"
|
|
117
107
|
>
|
|
118
108
|
Content
|
|
119
|
-
</Expander
|
|
109
|
+
</Expander>,
|
|
120
110
|
);
|
|
121
|
-
expect(getByTestId(
|
|
122
|
-
expect(getByTestId(
|
|
111
|
+
expect(getByTestId("test-id")).toHaveClass("expander");
|
|
112
|
+
expect(getByTestId("test-id")).toHaveClass("test-class");
|
|
123
113
|
});
|
|
124
114
|
});
|
|
@@ -12,8 +12,6 @@ import FeatureAccordionStatic from "./FeatureAccordion.static";
|
|
|
12
12
|
const CLASS_ROOT = "feature-accordion";
|
|
13
13
|
|
|
14
14
|
interface AccordionProps {
|
|
15
|
-
/** Color scheme for whole FeatureAccordion */
|
|
16
|
-
colorScheme?: "light" | "dark" | "white";
|
|
17
15
|
/** Additional CSS classes */
|
|
18
16
|
className?: string;
|
|
19
17
|
}
|
|
@@ -21,18 +19,10 @@ interface AccordionProps {
|
|
|
21
19
|
const FeatureAccordion = (
|
|
22
20
|
props: AccordionProps & { children: React.ReactNode },
|
|
23
21
|
) => {
|
|
24
|
-
const { className, children,
|
|
22
|
+
const { className, children, ...other } = props;
|
|
25
23
|
const [featureAccordionRef] = useStatic(FeatureAccordionStatic);
|
|
26
24
|
|
|
27
|
-
const classes = cx(
|
|
28
|
-
CLASS_ROOT,
|
|
29
|
-
{
|
|
30
|
-
"is-dark": colorScheme === "dark",
|
|
31
|
-
"is-light": colorScheme === "light",
|
|
32
|
-
"is-white": colorScheme === "white",
|
|
33
|
-
},
|
|
34
|
-
className,
|
|
35
|
-
);
|
|
25
|
+
const classes = cx(CLASS_ROOT, className);
|
|
36
26
|
|
|
37
27
|
const childrenArray = useMemo(
|
|
38
28
|
() => React.Children.toArray(children) as React.ReactElement<any>[],
|
|
@@ -4,18 +4,14 @@
|
|
|
4
4
|
@use "../../../styles/tokens/space";
|
|
5
5
|
@use "../../../styles/tokens/breakpoint";
|
|
6
6
|
|
|
7
|
-
@mixin
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
7
|
+
@mixin base {
|
|
8
|
+
color: var(--color-text-default);
|
|
9
|
+
background-color: var(--color-fill-subtle);
|
|
10
|
+
border-color: var(--color-fill-disabled);
|
|
11
|
+
}
|
|
13
12
|
|
|
13
|
+
@mixin accordion {
|
|
14
14
|
.accordion {
|
|
15
|
-
color: var(--color-text-default);
|
|
16
|
-
background-color: var(--color-fill-subtle);
|
|
17
|
-
border-color: var(--color-fill-disabled);
|
|
18
|
-
|
|
19
15
|
margin: convert.to-rem(87px) space.get("xlarge");
|
|
20
16
|
|
|
21
17
|
@include breakpoint.get("md", "down") {
|
|
@@ -32,10 +28,6 @@
|
|
|
32
28
|
display: flex;
|
|
33
29
|
padding: 0px !important;
|
|
34
30
|
|
|
35
|
-
color: var(--color-text-default);
|
|
36
|
-
background-color: var(--color-fill-subtle);
|
|
37
|
-
border-color: var(--color-fill-disabled);
|
|
38
|
-
|
|
39
31
|
img {
|
|
40
32
|
width: 100%;
|
|
41
33
|
height: auto;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
@layer components {
|
|
4
4
|
.feature-accordion {
|
|
5
|
+
@include mixins.base();
|
|
6
|
+
|
|
5
7
|
&__accordion {
|
|
6
8
|
@include mixins.accordion();
|
|
7
9
|
}
|
|
@@ -13,9 +15,5 @@
|
|
|
13
15
|
&__item {
|
|
14
16
|
@include mixins.item();
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
&.is-white {
|
|
18
|
-
--color-fill-subtle: #fff;
|
|
19
|
-
}
|
|
20
18
|
}
|
|
21
19
|
}
|
|
@@ -93,9 +93,4 @@ describe("FeatureAccordion", () => {
|
|
|
93
93
|
const { container } = renderAccordion({ "data-testid": "fa" });
|
|
94
94
|
expect(container.firstChild).toHaveAttribute("data-testid", "fa");
|
|
95
95
|
});
|
|
96
|
-
|
|
97
|
-
it("applies is-white class when colorScheme='white'", () => {
|
|
98
|
-
const { container } = renderAccordion({ colorScheme: "white" });
|
|
99
|
-
expect(container.firstChild).toHaveClass("is-white");
|
|
100
|
-
});
|
|
101
96
|
});
|
|
@@ -22,7 +22,6 @@ export interface InputStepperProps {
|
|
|
22
22
|
id: string;
|
|
23
23
|
inputClassName?: string;
|
|
24
24
|
isDisabled?: boolean;
|
|
25
|
-
colorScheme?: "light" | "dark";
|
|
26
25
|
name?: string;
|
|
27
26
|
nonEditableInput?: boolean;
|
|
28
27
|
className?: string;
|
|
@@ -35,7 +34,6 @@ const InputStepper: React.FC<InputStepperProps> = ({
|
|
|
35
34
|
id,
|
|
36
35
|
config,
|
|
37
36
|
isDisabled,
|
|
38
|
-
colorScheme,
|
|
39
37
|
nonEditableInput = false,
|
|
40
38
|
...other
|
|
41
39
|
}) => {
|
|
@@ -50,8 +48,6 @@ const InputStepper: React.FC<InputStepperProps> = ({
|
|
|
50
48
|
return (
|
|
51
49
|
<div
|
|
52
50
|
className={cx(CLASS_ROOT, className, {
|
|
53
|
-
"is-dark": colorScheme === "dark",
|
|
54
|
-
"is-light": colorScheme === "light",
|
|
55
51
|
[`${CLASS_ROOT}--disabled`]: isDisabled,
|
|
56
52
|
})}
|
|
57
53
|
ref={elementRef}
|