@purpurds/promotion-card 5.27.3 → 5.27.4

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": "5.27.3",
3
+ "version": "5.27.4",
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/badge": "5.27.3",
20
- "@purpurds/button": "5.27.3",
21
- "@purpurds/cta-link": "5.27.3",
22
- "@purpurds/card": "5.27.3",
23
- "@purpurds/icon": "5.27.3",
24
- "@purpurds/heading": "5.27.3",
25
- "@purpurds/tokens": "5.27.3"
19
+ "@purpurds/badge": "5.27.4",
20
+ "@purpurds/button": "5.27.4",
21
+ "@purpurds/cta-link": "5.27.4",
22
+ "@purpurds/heading": "5.27.4",
23
+ "@purpurds/card": "5.27.4",
24
+ "@purpurds/icon": "5.27.4",
25
+ "@purpurds/tokens": "5.27.4"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@rushstack/eslint-patch": "~1.10.0",
@@ -47,9 +47,9 @@
47
47
  "vite": "5.4.8",
48
48
  "vitest": "^2.1.2",
49
49
  "@purpurds/component-rig": "1.0.0",
50
- "@purpurds/text-spacing": "5.27.3",
51
- "@purpurds/paragraph": "5.27.3",
52
- "@purpurds/grid": "5.27.3"
50
+ "@purpurds/paragraph": "5.27.4",
51
+ "@purpurds/text-spacing": "5.27.4",
52
+ "@purpurds/grid": "5.27.4"
53
53
  },
54
54
  "scripts": {
55
55
  "build:dev": "vite",
@@ -121,6 +121,7 @@ export const WithDecorativeImage: Story = {
121
121
  </PromotionCard>
122
122
  );
123
123
  },
124
+ tags: ["visual:check"],
124
125
  };
125
126
 
126
127
  export const WithProductImage: Story = {
@@ -149,6 +150,7 @@ export const WithProductImage: Story = {
149
150
  </PromotionCard>
150
151
  );
151
152
  },
153
+ tags: ["visual:check"],
152
154
  };
153
155
 
154
156
  export const CardGroup: Story = {
@@ -190,10 +192,12 @@ export const CardGroup: Story = {
190
192
  </Grid>
191
193
  );
192
194
  },
195
+ tags: ["visual:check"],
193
196
  };
194
197
 
195
198
  export const Showcase: Story = {
196
199
  args: { children: <Children /> },
200
+ tags: ["visual:check"],
197
201
  };
198
202
 
199
203
  export const ActionButtons: Story = {
@@ -213,4 +217,5 @@ export const ActionButtons: Story = {
213
217
  },
214
218
  ],
215
219
  },
220
+ tags: ["visual:check"],
216
221
  };
@@ -41,7 +41,10 @@ const colors: StyleRecord = {
41
41
  type DecorativeImage = { decorativeImage?: ReactNode; hasGradient?: boolean };
42
42
  type ProductImage = { productImage?: ReactNode; hasGradient?: never };
43
43
 
44
- type Action = { label: string } & Omit<ButtonProps | CtaAnchorProps, "children">;
44
+ type Action = { label: string } & (
45
+ | Omit<ButtonProps, "children" | "variant">
46
+ | Omit<CtaAnchorProps, "children" | "variant">
47
+ );
45
48
 
46
49
  export type PromotionCardProps = {
47
50
  ["data-testid"]?: string;
@@ -53,7 +56,7 @@ export type PromotionCardProps = {
53
56
  badgeText?: string;
54
57
  badgeIcon?: ReactNode;
55
58
  className?: string;
56
- actions?: Array<Action>;
59
+ actions?: Action[];
57
60
  children: ReactNode;
58
61
  } & (DecorativeImage | ProductImage);
59
62
 
@@ -154,21 +157,21 @@ const PromotionCardComponent = (
154
157
  <div className={cx(`${rootClassName}__child-content`)}>{children}</div>
155
158
  {actions && actions.length > 0 && (
156
159
  <div className={cx(`${rootClassName}__actions`)}>
157
- {actions.map(({ label, variant: variantOverride, ...rest }, index) => {
158
- const actionVariant = variantOverride ?? index === 0 ? "primary" : "secondary";
160
+ {actions.map(({ label, ...rest }, index) => {
161
+ const actionVariant = index === 0 ? "primary" : "secondary";
159
162
  const props = {
160
163
  variant: actionVariant,
161
164
  negative: variant === "primary",
162
165
  ...rest,
163
166
  children: label,
164
- };
167
+ } as const;
165
168
  if (isValidAnchor(props)) {
166
169
  return <CtaLink key={label} {...props} />;
167
- } else if (isValidButton(props)) {
170
+ }
171
+ if ("onClick" in props && !("href" in props)) {
168
172
  return <Button key={label} {...props} />;
169
- } else {
170
- return null;
171
173
  }
174
+ return null;
172
175
  })}
173
176
  </div>
174
177
  )}
@@ -203,9 +206,6 @@ const PromotionCardComponent = (
203
206
  const isValidAnchor = (action: object): action is CtaAnchorProps => {
204
207
  return "href" in action;
205
208
  };
206
- const isValidButton = (action: object): action is ButtonProps => {
207
- return "onClick" in action;
208
- };
209
209
 
210
210
  export const PromotionCard = forwardRef(PromotionCardComponent);
211
211
  PromotionCard.displayName = "PromotionCard";