@purpurds/promotion-card 5.24.1 → 5.24.3
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 +5 -5
- package/dist/promotion-card.cjs.js +15 -15
- package/dist/promotion-card.cjs.js.map +1 -1
- package/dist/promotion-card.d.ts +2 -4
- package/dist/promotion-card.d.ts.map +1 -1
- package/dist/promotion-card.es.js +221 -235
- package/dist/promotion-card.es.js.map +1 -1
- package/package.json +12 -12
- package/src/promotion-card.module.scss +1 -1
- package/src/promotion-card.tsx +22 -30
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpurds/promotion-card",
|
|
3
|
-
"version": "5.24.
|
|
3
|
+
"version": "5.24.3",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "./dist/promotion-card.cjs.js",
|
|
6
6
|
"types": "./dist/promotion-card.d.ts",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"source": "src/promotion-card.tsx",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"classnames": "~2.5.0",
|
|
19
|
-
"@purpurds/
|
|
20
|
-
"@purpurds/card": "5.24.
|
|
21
|
-
"@purpurds/
|
|
22
|
-
"@purpurds/
|
|
23
|
-
"@purpurds/
|
|
24
|
-
"@purpurds/
|
|
25
|
-
"@purpurds/
|
|
19
|
+
"@purpurds/button": "5.24.3",
|
|
20
|
+
"@purpurds/card": "5.24.3",
|
|
21
|
+
"@purpurds/heading": "5.24.3",
|
|
22
|
+
"@purpurds/badge": "5.24.3",
|
|
23
|
+
"@purpurds/cta-link": "5.24.3",
|
|
24
|
+
"@purpurds/tokens": "5.24.3",
|
|
25
|
+
"@purpurds/icon": "5.24.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@rushstack/eslint-patch": "~1.10.0",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"typescript": "^5.6.3",
|
|
47
47
|
"vite": "5.4.8",
|
|
48
48
|
"vitest": "^2.1.2",
|
|
49
|
-
"@purpurds/
|
|
50
|
-
"@purpurds/
|
|
51
|
-
"@purpurds/
|
|
52
|
-
"@purpurds/
|
|
49
|
+
"@purpurds/paragraph": "5.24.3",
|
|
50
|
+
"@purpurds/text-spacing": "5.24.3",
|
|
51
|
+
"@purpurds/grid": "5.24.3",
|
|
52
|
+
"@purpurds/component-rig": "1.0.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build:dev": "vite",
|
package/src/promotion-card.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import React, {
|
|
|
8
8
|
import { Badge } from "@purpurds/badge";
|
|
9
9
|
import { type ButtonProps, Button } from "@purpurds/button";
|
|
10
10
|
import { Card } from "@purpurds/card";
|
|
11
|
-
import {
|
|
11
|
+
import { CtaAnchorProps, CtaLink } from "@purpurds/cta-link";
|
|
12
12
|
import { Heading, HeadingTagType, TitleVariantType } from "@purpurds/heading";
|
|
13
13
|
import c from "classnames/bind";
|
|
14
14
|
|
|
@@ -41,9 +41,7 @@ const colors: StyleRecord = {
|
|
|
41
41
|
type DecorativeImage = { decorativeImage?: ReactNode; hasGradient?: boolean };
|
|
42
42
|
type ProductImage = { productImage?: ReactNode; hasGradient?: never };
|
|
43
43
|
|
|
44
|
-
type
|
|
45
|
-
type CtaLinkPropsWithoutChildren = Omit<CtaLinkProps, "children">;
|
|
46
|
-
type Action = { label: string } & (ButtonPropsWithoutChildren | CtaLinkPropsWithoutChildren);
|
|
44
|
+
type Action = { label: string } & Omit<ButtonProps | CtaAnchorProps, "children">;
|
|
47
45
|
|
|
48
46
|
export type PromotionCardProps = {
|
|
49
47
|
["data-testid"]?: string;
|
|
@@ -156,29 +154,22 @@ const PromotionCardComponent = (
|
|
|
156
154
|
<div className={cx(`${rootClassName}__child-content`)}>{children}</div>
|
|
157
155
|
{actions && actions.length > 0 && (
|
|
158
156
|
<div className={cx(`${rootClassName}__actions`)}>
|
|
159
|
-
{actions.map(({ label, variant
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
negative={variant === "primary"}
|
|
176
|
-
{...rest}
|
|
177
|
-
>
|
|
178
|
-
{label}
|
|
179
|
-
</Button>
|
|
180
|
-
)
|
|
181
|
-
)}
|
|
157
|
+
{actions.map(({ label, variant: variantOverride, ...rest }, index) => {
|
|
158
|
+
const actionVariant = variantOverride ?? index === 0 ? "primary" : "secondary";
|
|
159
|
+
const props = {
|
|
160
|
+
variant: actionVariant,
|
|
161
|
+
negative: variant === "primary",
|
|
162
|
+
...rest,
|
|
163
|
+
children: label,
|
|
164
|
+
};
|
|
165
|
+
if (isValidAnchor(props)) {
|
|
166
|
+
return <CtaLink key={label} {...props} />;
|
|
167
|
+
} else if (isValidButton(props)) {
|
|
168
|
+
return <Button key={label} {...props} />;
|
|
169
|
+
} else {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
})}
|
|
182
173
|
</div>
|
|
183
174
|
)}
|
|
184
175
|
</div>
|
|
@@ -209,11 +200,12 @@ const PromotionCardComponent = (
|
|
|
209
200
|
);
|
|
210
201
|
};
|
|
211
202
|
|
|
212
|
-
const
|
|
213
|
-
action: Omit<CtaLinkPropsWithoutChildren | ButtonPropsWithoutChildren, "variant">
|
|
214
|
-
): action is Omit<CtaLinkPropsWithoutChildren, "variant"> => {
|
|
203
|
+
const isValidAnchor = (action: object): action is CtaAnchorProps => {
|
|
215
204
|
return "href" in action;
|
|
216
205
|
};
|
|
206
|
+
const isValidButton = (action: object): action is ButtonProps => {
|
|
207
|
+
return "onClick" in action;
|
|
208
|
+
};
|
|
217
209
|
|
|
218
210
|
export const PromotionCard = forwardRef(PromotionCardComponent);
|
|
219
211
|
PromotionCard.displayName = "PromotionCard";
|