@purpurds/promotion-card 8.2.5 → 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/dist/LICENSE.txt +4 -4
- package/dist/promotion-card.cjs.js +13 -13
- package/dist/promotion-card.cjs.js.map +1 -1
- package/dist/promotion-card.d.ts +16 -2
- package/dist/promotion-card.d.ts.map +1 -1
- package/dist/promotion-card.es.js +351 -346
- package/dist/promotion-card.es.js.map +1 -1
- package/package.json +13 -13
- package/src/promotion-card.stories.tsx +1 -2
- package/src/promotion-card.tsx +23 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpurds/promotion-card",
|
|
3
|
-
"version": "8.
|
|
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/badge": "8.
|
|
21
|
-
"@purpurds/
|
|
22
|
-
"@purpurds/
|
|
23
|
-
"@purpurds/common-types": "8.
|
|
24
|
-
"@purpurds/cta-link": "8.
|
|
25
|
-
"@purpurds/heading": "8.
|
|
26
|
-
"@purpurds/icon": "8.
|
|
27
|
-
"@purpurds/paragraph": "8.
|
|
28
|
-
"@purpurds/tokens": "8.
|
|
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/
|
|
50
|
-
"@purpurds/
|
|
51
|
-
"@purpurds/theme": "8.
|
|
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 },
|
|
@@ -137,7 +138,6 @@ export const Showcase: Story = {
|
|
|
137
138
|
|
|
138
139
|
export const WithDecorativeImage: Story = {
|
|
139
140
|
args: {
|
|
140
|
-
hasGradient: true,
|
|
141
141
|
decorativeImage: (
|
|
142
142
|
<img
|
|
143
143
|
src="https://www.telia.se/images/i15skfqwpurk/5YYelnwdIJGush05RYsE6A/04d4eeb571bca6d5c72b557f6da92c92/Telia_Company_Reinvention_69.jpg?fit=scale&w=536&fm=jpg&q=70"
|
|
@@ -186,7 +186,6 @@ export const WithProductImage: Story = {
|
|
|
186
186
|
|
|
187
187
|
export const CardGroup: Story = {
|
|
188
188
|
args: {
|
|
189
|
-
hasGradient: true,
|
|
190
189
|
decorativeImage: (
|
|
191
190
|
<img
|
|
192
191
|
src="https://www.telia.se/images/i15skfqwpurk/5YYelnwdIJGush05RYsE6A/04d4eeb571bca6d5c72b557f6da92c92/Telia_Company_Reinvention_69.jpg?fit=scale&w=536&fm=jpg&q=70"
|
package/src/promotion-card.tsx
CHANGED
|
@@ -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 {
|
|
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";
|
|
@@ -39,8 +39,8 @@ const colors: StyleRecord = {
|
|
|
39
39
|
quaternary: "var(--purpur-color-text-tone-on-tone-tertiary)",
|
|
40
40
|
} as const;
|
|
41
41
|
|
|
42
|
-
type DecorativeImage = { decorativeImage?: ReactNode
|
|
43
|
-
type ProductImage = { productImage?: ReactNode
|
|
42
|
+
type DecorativeImage = { decorativeImage?: ReactNode };
|
|
43
|
+
type ProductImage = { productImage?: ReactNode };
|
|
44
44
|
|
|
45
45
|
export type PromotionCardProps = Omit<BaseProps, "children"> & {
|
|
46
46
|
variant?: PromotionCardVariant;
|
|
@@ -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;
|
|
@@ -92,22 +105,24 @@ export const PromotionCard = forwardRef<HTMLDivElement, PromotionCardProps>(
|
|
|
92
105
|
const { productImage, ...spread } = props;
|
|
93
106
|
image = productImage;
|
|
94
107
|
rest = spread;
|
|
95
|
-
} else if ("hasGradient" in props) {
|
|
96
|
-
rest = props;
|
|
97
108
|
}
|
|
98
109
|
|
|
110
|
+
const effectiveColorScheme =
|
|
111
|
+
forceColorScheme ?? options?.promotionCardScheme ?? currentColorScheme;
|
|
112
|
+
|
|
99
113
|
const customProperties = {
|
|
100
114
|
"--promotion-card-background": backgrounds[variant],
|
|
101
115
|
"--promotion-card-color": colors[variant],
|
|
102
116
|
"--promotion-card-background-image": image
|
|
103
117
|
? "none"
|
|
104
|
-
:
|
|
118
|
+
: effectiveColorScheme === "dark"
|
|
105
119
|
? backgroundImagesDark[variant]
|
|
106
120
|
: backgroundImages[variant],
|
|
107
121
|
} as React.CSSProperties;
|
|
108
122
|
|
|
109
123
|
return (
|
|
110
124
|
<Card
|
|
125
|
+
data-id={id}
|
|
111
126
|
data-testid={dataTestid}
|
|
112
127
|
ref={ref}
|
|
113
128
|
fullHeight
|