@purpurds/promotion-card 8.2.6 → 8.3.0

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": "@purpurds/promotion-card",
3
- "version": "8.2.6",
3
+ "version": "8.3.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "./dist/promotion-card.cjs.js",
6
6
  "types": "./dist/promotion-card.d.ts",
@@ -17,15 +17,15 @@
17
17
  "source": "src/promotion-card.tsx",
18
18
  "dependencies": {
19
19
  "classnames": "~2.5.0",
20
- "@purpurds/button": "8.2.6",
21
- "@purpurds/cta-link": "8.2.6",
22
- "@purpurds/card": "8.2.6",
23
- "@purpurds/heading": "8.2.6",
24
- "@purpurds/paragraph": "8.2.6",
25
- "@purpurds/icon": "8.2.6",
26
- "@purpurds/tokens": "8.2.6",
27
- "@purpurds/common-types": "8.2.6",
28
- "@purpurds/badge": "8.2.6"
20
+ "@purpurds/badge": "8.3.0",
21
+ "@purpurds/button": "8.3.0",
22
+ "@purpurds/card": "8.3.0",
23
+ "@purpurds/common-types": "8.3.0",
24
+ "@purpurds/cta-link": "8.3.0",
25
+ "@purpurds/heading": "8.3.0",
26
+ "@purpurds/icon": "8.3.0",
27
+ "@purpurds/paragraph": "8.3.0",
28
+ "@purpurds/tokens": "8.3.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@storybook/react-vite": "^9.0.18",
@@ -46,9 +46,9 @@
46
46
  "vite": "^6.2.1",
47
47
  "vitest": "^3.1.2",
48
48
  "@purpurds/component-rig": "1.0.0",
49
- "@purpurds/grid": "8.2.6",
50
- "@purpurds/theme": "8.2.6",
51
- "@purpurds/text-spacing": "8.2.6"
49
+ "@purpurds/grid": "8.3.0",
50
+ "@purpurds/text-spacing": "8.3.0",
51
+ "@purpurds/theme": "8.3.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@types/react": "^18 || ^19",
@@ -76,6 +76,7 @@ const meta = {
76
76
  },
77
77
  },
78
78
  },
79
+ forceColorScheme: { control: "radio", options: ["light", "dark"] },
79
80
  actions: { control: false },
80
81
  badgeIcon: { control: false },
81
82
  decorativeImage: { control: false },
@@ -1,10 +1,10 @@
1
- import React, { forwardRef, type ReactNode } from "react";
1
+ import React, { forwardRef, type ReactNode, useId } from "react";
2
2
  import { Badge } from "@purpurds/badge";
3
3
  import { Card } from "@purpurds/card";
4
4
  import type { BaseProps } from "@purpurds/common-types";
5
5
  import { Heading, type HeadingTagType, type HeadingVariant } from "@purpurds/heading";
6
6
  import { Paragraph } from "@purpurds/paragraph";
7
- import { useColorScheme } from "@purpurds/theme";
7
+ import { type ColorScheme, useApplyTheme, useTheme } from "@purpurds/theme";
8
8
  import c from "classnames/bind";
9
9
 
10
10
  import styles from "./promotion-card.module.scss";
@@ -54,6 +54,11 @@ export type PromotionCardProps = Omit<BaseProps, "children"> & {
54
54
  children: ReactNode;
55
55
  alignment?: "space-between" | "flex-end";
56
56
  additionalText?: ReactNode;
57
+ forceColorScheme?: ColorScheme;
58
+ /**
59
+ * @deprecated Gradient has been removed from both design and implementation. This prop will be removed in the next major release.
60
+ */
61
+ hasGradient?: boolean;
57
62
  } & (DecorativeImage | ProductImage);
58
63
 
59
64
  const cx = c.bind(styles);
@@ -76,14 +81,22 @@ export const PromotionCard = forwardRef<HTMLDivElement, PromotionCardProps>(
76
81
  style,
77
82
  alignment = "space-between",
78
83
  additionalText,
84
+ forceColorScheme,
79
85
  ...props
80
86
  },
81
87
  ref
82
88
  ) => {
83
- const [colorScheme] = useColorScheme();
84
89
  let rest = props;
85
90
  let image;
86
91
 
92
+ const id = useId();
93
+ const { options, currentColorScheme } = useTheme();
94
+
95
+ useApplyTheme({
96
+ cssVariablesSelector: `[data-id="${id}"]`,
97
+ currentColorScheme: forceColorScheme ?? options?.promotionCardScheme,
98
+ });
99
+
87
100
  if ("decorativeImage" in props) {
88
101
  const { decorativeImage, ...spread } = props;
89
102
  image = decorativeImage;
@@ -94,18 +107,22 @@ export const PromotionCard = forwardRef<HTMLDivElement, PromotionCardProps>(
94
107
  rest = spread;
95
108
  }
96
109
 
110
+ const effectiveColorScheme =
111
+ forceColorScheme ?? options?.promotionCardScheme ?? currentColorScheme;
112
+
97
113
  const customProperties = {
98
114
  "--promotion-card-background": backgrounds[variant],
99
115
  "--promotion-card-color": colors[variant],
100
116
  "--promotion-card-background-image": image
101
117
  ? "none"
102
- : colorScheme === "dark"
118
+ : effectiveColorScheme === "dark"
103
119
  ? backgroundImagesDark[variant]
104
120
  : backgroundImages[variant],
105
121
  } as React.CSSProperties;
106
122
 
107
123
  return (
108
124
  <Card
125
+ data-id={id}
109
126
  data-testid={dataTestid}
110
127
  ref={ref}
111
128
  fullHeight