@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
|
@@ -53,28 +53,6 @@ describe("rendering Modal", () => {
|
|
|
53
53
|
expect(child[0]).toHaveClass("modal__header");
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
|
-
describe("colorScheme prop", () => {
|
|
57
|
-
it("should have is-dark class when colorScheme is 'dark'", () => {
|
|
58
|
-
const { getByTestId } = render(
|
|
59
|
-
<div id="root">
|
|
60
|
-
<Modal id="modal-dark" data-testid="modal-dark" colorScheme="dark" />
|
|
61
|
-
</div>,
|
|
62
|
-
);
|
|
63
|
-
expect(getByTestId("modal-dark")).toHaveClass("is-dark");
|
|
64
|
-
});
|
|
65
|
-
it("should have is-light class when colorScheme is 'light'", () => {
|
|
66
|
-
const { getByTestId } = render(
|
|
67
|
-
<div id="root">
|
|
68
|
-
<Modal
|
|
69
|
-
id="modal-light"
|
|
70
|
-
data-testid="modal-light"
|
|
71
|
-
colorScheme="light"
|
|
72
|
-
/>
|
|
73
|
-
</div>,
|
|
74
|
-
);
|
|
75
|
-
expect(getByTestId("modal-light")).toHaveClass("is-light");
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
56
|
describe("disableHeaderSpacing prop", () => {
|
|
79
57
|
it("should have modal__header--no-spacing class when disableHeaderSpacing is true", () => {
|
|
80
58
|
const { getByTestId } = render(
|
|
@@ -19,8 +19,6 @@ interface PaginationItemProps {
|
|
|
19
19
|
interface PaginationProps {
|
|
20
20
|
/** Collapsed version */
|
|
21
21
|
isCompact?: boolean;
|
|
22
|
-
/** Dark theme */
|
|
23
|
-
colorScheme?: "light" | "dark";
|
|
24
22
|
/** All pagination items - buttons & numbers */
|
|
25
23
|
items: PaginationItemProps[];
|
|
26
24
|
/** Accessibility label */
|
|
@@ -37,18 +35,10 @@ export const Pagination: React.FC<PaginationProps> = ({
|
|
|
37
35
|
className,
|
|
38
36
|
label,
|
|
39
37
|
isCompact,
|
|
40
|
-
colorScheme,
|
|
41
38
|
items,
|
|
42
39
|
...other
|
|
43
40
|
}) => {
|
|
44
|
-
const classes = cx(
|
|
45
|
-
CLASS_ROOT,
|
|
46
|
-
{
|
|
47
|
-
"is-dark": colorScheme === "dark",
|
|
48
|
-
"is-light": colorScheme === "light",
|
|
49
|
-
},
|
|
50
|
-
className,
|
|
51
|
-
);
|
|
41
|
+
const classes = cx(CLASS_ROOT, className);
|
|
52
42
|
|
|
53
43
|
const activeIndex = useMemo(
|
|
54
44
|
() => items.findIndex(({ isActive }) => isActive),
|
|
@@ -22,7 +22,6 @@ interface PillProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
22
22
|
children?: ReactNode;
|
|
23
23
|
color?: PillColor;
|
|
24
24
|
size?: "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
25
|
-
colorScheme?: "light" | "dark";
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
const Pill: React.FC<PillProps> = ({
|
|
@@ -30,15 +29,12 @@ const Pill: React.FC<PillProps> = ({
|
|
|
30
29
|
children,
|
|
31
30
|
size,
|
|
32
31
|
color,
|
|
33
|
-
colorScheme,
|
|
34
32
|
...other
|
|
35
33
|
}) => (
|
|
36
34
|
<span
|
|
37
35
|
className={cx(
|
|
38
36
|
CLASS_ROOT,
|
|
39
37
|
{
|
|
40
|
-
"is-light": colorScheme === "light",
|
|
41
|
-
"is-dark": colorScheme === "dark",
|
|
42
38
|
[CLASS_ROOT + "--" + size]: size,
|
|
43
39
|
},
|
|
44
40
|
color,
|
|
@@ -140,24 +140,6 @@ describe("rendering Pill", () => {
|
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
-
it("has is-light class when colorScheme is light", () => {
|
|
144
|
-
const { getByTestId } = render(
|
|
145
|
-
<Pill colorScheme="light" data-testid="test-id">
|
|
146
|
-
pill
|
|
147
|
-
</Pill>,
|
|
148
|
-
);
|
|
149
|
-
expect(getByTestId("test-id")).toHaveClass("is-light");
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it("has is-dark class when colorScheme is dark", () => {
|
|
153
|
-
const { getByTestId } = render(
|
|
154
|
-
<Pill colorScheme="dark" data-testid="test-id">
|
|
155
|
-
pill
|
|
156
|
-
</Pill>,
|
|
157
|
-
);
|
|
158
|
-
expect(getByTestId("test-id")).toHaveClass("is-dark");
|
|
159
|
-
});
|
|
160
|
-
|
|
161
143
|
it("passes other props", () => {
|
|
162
144
|
const { getByTestId } = render(<Pill data-testid="test">Pill</Pill>);
|
|
163
145
|
expect(getByTestId("test")).toBeInTheDocument();
|
|
@@ -12,7 +12,6 @@ export interface ProgressProps {
|
|
|
12
12
|
width?: number;
|
|
13
13
|
className?: string;
|
|
14
14
|
children?: React.ReactNode;
|
|
15
|
-
colorMode?: "light" | "dark";
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
const defaultProps = {
|
|
@@ -27,21 +26,10 @@ export const Progress: React.FC<ProgressProps> = ({
|
|
|
27
26
|
value,
|
|
28
27
|
width,
|
|
29
28
|
className,
|
|
30
|
-
colorMode,
|
|
31
29
|
...other
|
|
32
30
|
}) => {
|
|
33
31
|
return (
|
|
34
|
-
<div
|
|
35
|
-
className={cx(
|
|
36
|
-
CLASS_ROOT,
|
|
37
|
-
{
|
|
38
|
-
"is-dark": colorMode === "dark",
|
|
39
|
-
"is-light": colorMode === "light",
|
|
40
|
-
},
|
|
41
|
-
className,
|
|
42
|
-
)}
|
|
43
|
-
{...other}
|
|
44
|
-
>
|
|
32
|
+
<div className={cx(CLASS_ROOT, className)} {...other}>
|
|
45
33
|
<div className={`${CLASS_ROOT}__label`}>{label}</div>
|
|
46
34
|
<div className={`${CLASS_ROOT}__bar`}>
|
|
47
35
|
<div
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
@use "sass:map";
|
|
2
|
-
@use
|
|
3
|
-
@use
|
|
4
|
-
@use
|
|
5
|
-
@use
|
|
2
|
+
@use "../../../styles/tokens/space";
|
|
3
|
+
@use "../../../styles/tools/generate";
|
|
4
|
+
@use "../../../styles/typography/config" as typography;
|
|
5
|
+
@use "./config";
|
|
6
6
|
|
|
7
7
|
@mixin base {
|
|
8
8
|
@include generate.css-map(config.$layout);
|
|
@@ -10,20 +10,22 @@
|
|
|
10
10
|
|
|
11
11
|
@mixin bar {
|
|
12
12
|
position: relative;
|
|
13
|
-
margin-bottom: space.get(
|
|
13
|
+
margin-bottom: space.get("xsmall");
|
|
14
14
|
|
|
15
15
|
@include generate.css-map(config.$bar);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
@mixin label {
|
|
19
|
-
margin-bottom: space.get(
|
|
19
|
+
margin-bottom: space.get("xsmall");
|
|
20
20
|
font-weight: bold;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
@mixin value {
|
|
24
24
|
font-weight: bold;
|
|
25
25
|
|
|
26
|
-
@include generate.css-map(
|
|
26
|
+
@include generate.css-map(
|
|
27
|
+
map.get(map.get(typography.$body-text, "small"), "default")
|
|
28
|
+
);
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
@mixin indicator {
|
|
@@ -4,7 +4,6 @@ import { Grid, GridCol } from "../Grid";
|
|
|
4
4
|
import { Image } from "../Image";
|
|
5
5
|
|
|
6
6
|
interface PromoBannerProps {
|
|
7
|
-
colorScheme?: "light" | "dark";
|
|
8
7
|
className?: string;
|
|
9
8
|
image?: string;
|
|
10
9
|
alignImage?: "bottom" | "top";
|
|
@@ -20,7 +19,6 @@ interface PromoBannerProps {
|
|
|
20
19
|
const CLASS_ROOT = "promo-banner";
|
|
21
20
|
export const PromoBanner = ({
|
|
22
21
|
image,
|
|
23
|
-
colorScheme,
|
|
24
22
|
className,
|
|
25
23
|
alignImage,
|
|
26
24
|
bleedImage,
|
|
@@ -30,14 +28,7 @@ export const PromoBanner = ({
|
|
|
30
28
|
variant,
|
|
31
29
|
imageFullWidth,
|
|
32
30
|
}: PromoBannerProps) => {
|
|
33
|
-
const classes = cx(
|
|
34
|
-
CLASS_ROOT,
|
|
35
|
-
{
|
|
36
|
-
"is-light": colorScheme === "light",
|
|
37
|
-
"is-dark": colorScheme === "dark",
|
|
38
|
-
},
|
|
39
|
-
className,
|
|
40
|
-
);
|
|
31
|
+
const classes = cx(CLASS_ROOT, className);
|
|
41
32
|
return (
|
|
42
33
|
<Grid columnGapSize="large" className={classes}>
|
|
43
34
|
{variant === "reverse" && image && (
|
|
@@ -71,7 +71,6 @@ describe("PromoBanner Component Conformance Tests", () => {
|
|
|
71
71
|
it("is valid HTML with all props", () => {
|
|
72
72
|
const { container } = render(
|
|
73
73
|
<PromoBanner
|
|
74
|
-
colorScheme="dark"
|
|
75
74
|
className="test-class"
|
|
76
75
|
image="https://example.com/test.jpg"
|
|
77
76
|
alignImage="top"
|
|
@@ -204,7 +203,6 @@ describe("PromoBanner Component Conformance Tests", () => {
|
|
|
204
203
|
it("is accessible with all props", async () => {
|
|
205
204
|
const { container } = render(
|
|
206
205
|
<PromoBanner
|
|
207
|
-
colorScheme="dark"
|
|
208
206
|
image="https://example.com/test.jpg"
|
|
209
207
|
alignImage="top"
|
|
210
208
|
bleedImage
|
|
@@ -341,22 +339,6 @@ describe("PromoBanner Component Conformance Tests", () => {
|
|
|
341
339
|
expect(item).toHaveClass("promo-banner__item");
|
|
342
340
|
});
|
|
343
341
|
|
|
344
|
-
it("applies color scheme classes correctly", () => {
|
|
345
|
-
const { container: lightContainer } = render(
|
|
346
|
-
<PromoBanner colorScheme="light">Light Content</PromoBanner>,
|
|
347
|
-
);
|
|
348
|
-
const { container: darkContainer } = render(
|
|
349
|
-
<PromoBanner colorScheme="dark">Dark Content</PromoBanner>,
|
|
350
|
-
);
|
|
351
|
-
|
|
352
|
-
expect(lightContainer.querySelector(".promo-banner")).toHaveClass(
|
|
353
|
-
"is-light",
|
|
354
|
-
);
|
|
355
|
-
expect(darkContainer.querySelector(".promo-banner")).toHaveClass(
|
|
356
|
-
"is-dark",
|
|
357
|
-
);
|
|
358
|
-
});
|
|
359
|
-
|
|
360
342
|
it("applies variant classes correctly", () => {
|
|
361
343
|
const { container: horizontalContainer } = render(
|
|
362
344
|
<PromoBanner>Horizontal Content</PromoBanner>,
|
|
@@ -587,18 +569,6 @@ describe("PromoBanner Component Conformance Tests", () => {
|
|
|
587
569
|
expect(banner).toBeInTheDocument();
|
|
588
570
|
});
|
|
589
571
|
|
|
590
|
-
it("handles invalid colorScheme prop gracefully", () => {
|
|
591
|
-
const { container } = render(
|
|
592
|
-
<PromoBanner colorScheme="invalid-scheme" data-testid="test-banner">
|
|
593
|
-
Content
|
|
594
|
-
</PromoBanner>,
|
|
595
|
-
);
|
|
596
|
-
const banner = container.querySelector(".promo-banner");
|
|
597
|
-
expect(banner).toHaveClass("promo-banner");
|
|
598
|
-
expect(banner).not.toHaveClass("is-light");
|
|
599
|
-
expect(banner).not.toHaveClass("is-dark");
|
|
600
|
-
});
|
|
601
|
-
|
|
602
572
|
it("handles invalid alignImage prop gracefully", () => {
|
|
603
573
|
const { container } = render(
|
|
604
574
|
<PromoBanner image="test.jpg" alignImage="invalid">
|
|
@@ -99,27 +99,6 @@ describe("PromoBanner", () => {
|
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
describe("colorScheme", () => {
|
|
103
|
-
it("applies light color scheme", () => {
|
|
104
|
-
render(<PromoBanner colorScheme="light" />);
|
|
105
|
-
const banner = document.querySelector(".promo-banner");
|
|
106
|
-
expect(banner).toHaveClass("is-light");
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("applies dark color scheme", () => {
|
|
110
|
-
render(<PromoBanner colorScheme="dark" />);
|
|
111
|
-
const banner = document.querySelector(".promo-banner");
|
|
112
|
-
expect(banner).toHaveClass("is-dark");
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("does not apply color scheme class when not specified", () => {
|
|
116
|
-
render(<PromoBanner />);
|
|
117
|
-
const banner = document.querySelector(".promo-banner");
|
|
118
|
-
expect(banner).not.toHaveClass("is-light");
|
|
119
|
-
expect(banner).not.toHaveClass("is-dark");
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
102
|
describe("itemClassName", () => {
|
|
124
103
|
it("applies custom itemClassName to content column", () => {
|
|
125
104
|
render(
|
|
@@ -448,7 +427,6 @@ describe("PromoBanner", () => {
|
|
|
448
427
|
render(
|
|
449
428
|
<PromoBanner
|
|
450
429
|
variant="vertical"
|
|
451
|
-
colorScheme="dark"
|
|
452
430
|
className="custom-banner"
|
|
453
431
|
itemClassName="custom-item"
|
|
454
432
|
image="test.jpg"
|
|
@@ -462,7 +440,7 @@ describe("PromoBanner", () => {
|
|
|
462
440
|
const item = document.querySelector(".promo-banner__item");
|
|
463
441
|
const imageContainer = document.querySelector(".promo-banner__image");
|
|
464
442
|
|
|
465
|
-
expect(banner).toHaveClass("promo-banner", "
|
|
443
|
+
expect(banner).toHaveClass("promo-banner", "custom-banner");
|
|
466
444
|
expect(item).toHaveClass(
|
|
467
445
|
"promo-banner__item",
|
|
468
446
|
"align-items-center",
|
|
@@ -521,16 +499,6 @@ describe("PromoBanner", () => {
|
|
|
521
499
|
expect(screen.queryByRole("img")).not.toBeInTheDocument();
|
|
522
500
|
});
|
|
523
501
|
|
|
524
|
-
it("handles invalid colorScheme gracefully", () => {
|
|
525
|
-
const { container } = render(
|
|
526
|
-
<PromoBanner colorScheme="invalid">Content</PromoBanner>,
|
|
527
|
-
);
|
|
528
|
-
const banner = container.querySelector(".promo-banner");
|
|
529
|
-
expect(banner).toHaveClass("promo-banner");
|
|
530
|
-
expect(banner).not.toHaveClass("is-light");
|
|
531
|
-
expect(banner).not.toHaveClass("is-dark");
|
|
532
|
-
});
|
|
533
|
-
|
|
534
502
|
it("handles invalid alignImage gracefully", () => {
|
|
535
503
|
render(
|
|
536
504
|
<PromoBanner image="test.jpg" alignImage="invalid">
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
|
|
4
|
-
import { Card } from "../Card";
|
|
4
|
+
import { Card, CardColor } from "../Card";
|
|
5
5
|
|
|
6
6
|
import { CLASS_ROOT } from "./constants";
|
|
7
7
|
|
|
8
8
|
export interface PromotionCardProps {
|
|
9
|
-
/** Inverse colors */
|
|
10
|
-
colorScheme?: "light" | "dark";
|
|
11
9
|
className?: string;
|
|
12
10
|
children?: React.ReactNode;
|
|
11
|
+
color?: CardColor;
|
|
13
12
|
[key: string]: any;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
export const PromotionCard: React.FC<PromotionCardProps> = ({
|
|
17
|
-
colorScheme = "light",
|
|
18
16
|
className,
|
|
19
17
|
children,
|
|
18
|
+
color = "background-primary",
|
|
20
19
|
...other
|
|
21
20
|
}) => {
|
|
22
21
|
const classes = cx(CLASS_ROOT, className);
|
|
23
|
-
|
|
24
|
-
colorScheme === "dark" ? "background-contrast" : "background-primary";
|
|
22
|
+
|
|
25
23
|
return (
|
|
26
24
|
<Card className={classes} color={color} {...other}>
|
|
27
25
|
{children}
|
|
@@ -63,7 +63,7 @@ describe("PromotionCard Component Conformance Tests", () => {
|
|
|
63
63
|
it("is valid HTML with all props", () => {
|
|
64
64
|
const { container } = render(
|
|
65
65
|
<PromotionCard
|
|
66
|
-
|
|
66
|
+
color="background-contrast"
|
|
67
67
|
className="test-class"
|
|
68
68
|
data-testid="test-promotion-card"
|
|
69
69
|
>
|
|
@@ -110,7 +110,7 @@ describe("PromotionCard Component Conformance Tests", () => {
|
|
|
110
110
|
|
|
111
111
|
it("is accessible with light color scheme", async () => {
|
|
112
112
|
const { container } = render(
|
|
113
|
-
<PromotionCard
|
|
113
|
+
<PromotionCard color="background-primary">
|
|
114
114
|
<h1>Light Theme Promotion</h1>
|
|
115
115
|
<p>This is a light themed promotion card.</p>
|
|
116
116
|
</PromotionCard>,
|
|
@@ -120,7 +120,7 @@ describe("PromotionCard Component Conformance Tests", () => {
|
|
|
120
120
|
|
|
121
121
|
it("is accessible with dark color scheme", async () => {
|
|
122
122
|
const { container } = render(
|
|
123
|
-
<PromotionCard
|
|
123
|
+
<PromotionCard color="background-contrast">
|
|
124
124
|
<h1>Dark Theme Promotion</h1>
|
|
125
125
|
<p>This is a dark themed promotion card with proper contrast.</p>
|
|
126
126
|
</PromotionCard>,
|
|
@@ -130,7 +130,7 @@ describe("PromotionCard Component Conformance Tests", () => {
|
|
|
130
130
|
|
|
131
131
|
it("is accessible with complex content", async () => {
|
|
132
132
|
const { container } = render(
|
|
133
|
-
<PromotionCard
|
|
133
|
+
<PromotionCard color="background-primary">
|
|
134
134
|
<header>
|
|
135
135
|
<h1>Promotion Title</h1>
|
|
136
136
|
<nav aria-label="Promotion navigation">
|
|
@@ -220,13 +220,10 @@ describe("PromotionCard Component Conformance Tests", () => {
|
|
|
220
220
|
});
|
|
221
221
|
|
|
222
222
|
it("applies color scheme classes correctly", () => {
|
|
223
|
-
const
|
|
224
|
-
|
|
223
|
+
const colors = ["background-primary", "background-contrast"];
|
|
224
|
+
colors.forEach((color) => {
|
|
225
225
|
const { container } = render(
|
|
226
|
-
<PromotionCard
|
|
227
|
-
colorScheme={colorScheme}
|
|
228
|
-
data-testid="test-promotion-card"
|
|
229
|
-
/>,
|
|
226
|
+
<PromotionCard color={color} data-testid="test-promotion-card" />,
|
|
230
227
|
);
|
|
231
228
|
const card = container.querySelector(
|
|
232
229
|
'[data-testid="test-promotion-card"]',
|
|
@@ -234,7 +231,7 @@ describe("PromotionCard Component Conformance Tests", () => {
|
|
|
234
231
|
|
|
235
232
|
expect(card).toHaveClass("promotion-card");
|
|
236
233
|
|
|
237
|
-
if (
|
|
234
|
+
if (color === "background-primary") {
|
|
238
235
|
expect(card).not.toHaveClass("background-primary");
|
|
239
236
|
expect(card).not.toHaveClass("background-contrast");
|
|
240
237
|
expect(card).not.toHaveClass("text-inverse");
|
|
@@ -247,7 +244,10 @@ describe("PromotionCard Component Conformance Tests", () => {
|
|
|
247
244
|
|
|
248
245
|
it("applies dark color scheme with text-inverse correctly", () => {
|
|
249
246
|
const { container } = render(
|
|
250
|
-
<PromotionCard
|
|
247
|
+
<PromotionCard
|
|
248
|
+
color="background-contrast"
|
|
249
|
+
data-testid="test-promotion-card"
|
|
250
|
+
/>,
|
|
251
251
|
);
|
|
252
252
|
const card = container.querySelector(
|
|
253
253
|
'[data-testid="test-promotion-card"]',
|
|
@@ -260,7 +260,7 @@ describe("PromotionCard Component Conformance Tests", () => {
|
|
|
260
260
|
it("combines multiple props correctly", () => {
|
|
261
261
|
const { container } = render(
|
|
262
262
|
<PromotionCard
|
|
263
|
-
|
|
263
|
+
color="background-contrast"
|
|
264
264
|
className="custom-class"
|
|
265
265
|
data-testid="test-promotion-card"
|
|
266
266
|
/>,
|
|
@@ -436,10 +436,10 @@ describe("PromotionCard Component Conformance Tests", () => {
|
|
|
436
436
|
expect(screen.getByText(/Promo 3/)).toBeInTheDocument();
|
|
437
437
|
});
|
|
438
438
|
|
|
439
|
-
it("handles invalid
|
|
439
|
+
it("handles invalid color prop gracefully", () => {
|
|
440
440
|
const { container } = render(
|
|
441
441
|
<PromotionCard
|
|
442
|
-
|
|
442
|
+
color="invalid-color"
|
|
443
443
|
data-testid="test-promotion-card"
|
|
444
444
|
/>,
|
|
445
445
|
);
|
|
@@ -447,9 +447,8 @@ describe("PromotionCard Component Conformance Tests", () => {
|
|
|
447
447
|
'[data-testid="test-promotion-card"]',
|
|
448
448
|
);
|
|
449
449
|
expect(card).toHaveClass("promotion-card");
|
|
450
|
-
// Should
|
|
451
|
-
expect(card).
|
|
452
|
-
expect(card).not.toHaveClass("background-contrast");
|
|
450
|
+
// Should render with custom color if provided
|
|
451
|
+
expect(card).toHaveClass("invalid-color");
|
|
453
452
|
});
|
|
454
453
|
});
|
|
455
454
|
|
|
@@ -522,7 +521,7 @@ describe("PromotionCard Component Conformance Tests", () => {
|
|
|
522
521
|
const handleSubmit = jest.fn((e) => e.preventDefault());
|
|
523
522
|
|
|
524
523
|
render(
|
|
525
|
-
<PromotionCard
|
|
524
|
+
<PromotionCard color="background-contrast">
|
|
526
525
|
<form onSubmit={handleSubmit}>
|
|
527
526
|
<h2>Special Promotion</h2>
|
|
528
527
|
<label htmlFor="email">Email</label>
|
|
@@ -90,7 +90,6 @@ describe("PromotionCard Component Unit Tests", () => {
|
|
|
90
90
|
const { getByTestId } = render(
|
|
91
91
|
<PromotionCard
|
|
92
92
|
data-testid="test-promotion-card"
|
|
93
|
-
colorScheme="dark"
|
|
94
93
|
className="custom-class"
|
|
95
94
|
/>,
|
|
96
95
|
);
|
|
@@ -151,69 +150,6 @@ describe("PromotionCard Component Unit Tests", () => {
|
|
|
151
150
|
});
|
|
152
151
|
});
|
|
153
152
|
|
|
154
|
-
describe("Color Scheme Prop Behavior", () => {
|
|
155
|
-
it("applies background-primary color for light colorScheme (default)", () => {
|
|
156
|
-
const { getByTestId } = render(
|
|
157
|
-
<PromotionCard data-testid="test-promotion-card" colorScheme="light" />,
|
|
158
|
-
);
|
|
159
|
-
const card = getByTestId("test-promotion-card");
|
|
160
|
-
|
|
161
|
-
expect(card).toHaveClass("promotion-card");
|
|
162
|
-
// background-primary is the default and should not add a color class
|
|
163
|
-
expect(card).not.toHaveClass("background-primary");
|
|
164
|
-
expect(card).not.toHaveClass("background-contrast");
|
|
165
|
-
expect(card).not.toHaveClass("text-inverse");
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("applies background-contrast color and text-inverse for dark colorScheme", () => {
|
|
169
|
-
const { getByTestId } = render(
|
|
170
|
-
<PromotionCard data-testid="test-promotion-card" colorScheme="dark" />,
|
|
171
|
-
);
|
|
172
|
-
const card = getByTestId("test-promotion-card");
|
|
173
|
-
|
|
174
|
-
expect(card).toHaveClass("promotion-card");
|
|
175
|
-
expect(card).toHaveClass("background-contrast");
|
|
176
|
-
expect(card).toHaveClass("text-inverse");
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("uses light colorScheme by default when no colorScheme is provided", () => {
|
|
180
|
-
const { getByTestId } = render(
|
|
181
|
-
<PromotionCard data-testid="test-promotion-card" />,
|
|
182
|
-
);
|
|
183
|
-
const card = getByTestId("test-promotion-card");
|
|
184
|
-
|
|
185
|
-
expect(card).toHaveClass("promotion-card");
|
|
186
|
-
expect(card).not.toHaveClass("background-primary");
|
|
187
|
-
expect(card).not.toHaveClass("background-contrast");
|
|
188
|
-
expect(card).not.toHaveClass("text-inverse");
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it("handles all colorScheme variants correctly", () => {
|
|
192
|
-
const colorSchemes = ["light", "dark"];
|
|
193
|
-
|
|
194
|
-
colorSchemes.forEach((colorScheme, index) => {
|
|
195
|
-
const { getByTestId } = render(
|
|
196
|
-
<PromotionCard
|
|
197
|
-
data-testid={`test-promotion-card-${index}`}
|
|
198
|
-
colorScheme={colorScheme}
|
|
199
|
-
/>,
|
|
200
|
-
);
|
|
201
|
-
const card = getByTestId(`test-promotion-card-${index}`);
|
|
202
|
-
|
|
203
|
-
expect(card).toHaveClass("promotion-card");
|
|
204
|
-
|
|
205
|
-
if (colorScheme === "light") {
|
|
206
|
-
expect(card).not.toHaveClass("background-primary");
|
|
207
|
-
expect(card).not.toHaveClass("background-contrast");
|
|
208
|
-
expect(card).not.toHaveClass("text-inverse");
|
|
209
|
-
} else {
|
|
210
|
-
expect(card).toHaveClass("background-contrast");
|
|
211
|
-
expect(card).toHaveClass("text-inverse");
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
|
|
217
153
|
describe("Content Rendering", () => {
|
|
218
154
|
it("renders text children correctly through Card", () => {
|
|
219
155
|
render(
|
|
@@ -318,11 +254,11 @@ describe("PromotionCard Component Unit Tests", () => {
|
|
|
318
254
|
});
|
|
319
255
|
|
|
320
256
|
describe("Props Combinations", () => {
|
|
321
|
-
it("combines
|
|
257
|
+
it("combines color and className correctly", () => {
|
|
322
258
|
const { getByTestId } = render(
|
|
323
259
|
<PromotionCard
|
|
324
260
|
data-testid="test-promotion-card"
|
|
325
|
-
|
|
261
|
+
color="background-contrast"
|
|
326
262
|
className="custom-class"
|
|
327
263
|
/>,
|
|
328
264
|
);
|
|
@@ -338,7 +274,7 @@ describe("PromotionCard Component Unit Tests", () => {
|
|
|
338
274
|
const { getByTestId } = render(
|
|
339
275
|
<PromotionCard
|
|
340
276
|
data-testid="test-promotion-card"
|
|
341
|
-
|
|
277
|
+
color="background-primary"
|
|
342
278
|
className="custom-class"
|
|
343
279
|
id="promotion-id"
|
|
344
280
|
>
|
|
@@ -417,19 +353,18 @@ describe("PromotionCard Component Unit Tests", () => {
|
|
|
417
353
|
});
|
|
418
354
|
|
|
419
355
|
describe("Edge Cases & Error Handling", () => {
|
|
420
|
-
it("handles invalid
|
|
356
|
+
it("handles invalid color prop gracefully", () => {
|
|
421
357
|
const { getByTestId } = render(
|
|
422
358
|
<PromotionCard
|
|
423
359
|
data-testid="test-promotion-card"
|
|
424
|
-
|
|
360
|
+
color="invalid-color"
|
|
425
361
|
/>,
|
|
426
362
|
);
|
|
427
363
|
const card = getByTestId("test-promotion-card");
|
|
428
364
|
|
|
429
365
|
expect(card).toHaveClass("promotion-card");
|
|
430
|
-
// Should
|
|
431
|
-
expect(card).
|
|
432
|
-
expect(card).not.toHaveClass("background-contrast");
|
|
366
|
+
// Should still render with the color class provided
|
|
367
|
+
expect(card).toHaveClass("invalid-color");
|
|
433
368
|
});
|
|
434
369
|
|
|
435
370
|
it("handles boolean children", () => {
|
|
@@ -465,7 +400,10 @@ describe("PromotionCard Component Unit Tests", () => {
|
|
|
465
400
|
describe("Card Integration", () => {
|
|
466
401
|
it("properly integrates with Card component", () => {
|
|
467
402
|
const { getByTestId } = render(
|
|
468
|
-
<PromotionCard
|
|
403
|
+
<PromotionCard
|
|
404
|
+
data-testid="test-promotion-card"
|
|
405
|
+
color="background-contrast"
|
|
406
|
+
>
|
|
469
407
|
<div>Card content</div>
|
|
470
408
|
</PromotionCard>,
|
|
471
409
|
);
|
|
@@ -484,7 +422,7 @@ describe("PromotionCard Component Unit Tests", () => {
|
|
|
484
422
|
const { getByTestId } = render(
|
|
485
423
|
<PromotionCard
|
|
486
424
|
data-testid="test-promotion-card"
|
|
487
|
-
|
|
425
|
+
color="background-primary"
|
|
488
426
|
noBorder={true}
|
|
489
427
|
>
|
|
490
428
|
<div>Card content</div>
|