@purpurds/radio-card-group 5.11.0 → 5.11.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"radio-card-item-image.d.ts","sourceRoot":"","sources":["../src/radio-card-item-image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,MAAM,mBAAmB,GAAG;IAChC,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAIF,eAAO,MAAM,yBAAyB,gBACvB,mBAAmB,GAAG,OAAO,sCAEiD,CAAC;AAE9F,eAAO,MAAM,cAAc,2EAMxB,mBAAmB,sBAyBrB,CAAC"}
1
+ {"version":3,"file":"radio-card-item-image.d.ts","sourceRoot":"","sources":["../src/radio-card-item-image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,MAAM,mBAAmB,GAAG;IAChC,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAIF,eAAO,MAAM,yBAAyB,gBACvB,mBAAmB,GAAG,OAAO,KACzC,UAAU,IAAI,mBAC4E,CAAC;AAE9F,eAAO,MAAM,cAAc,2EAMxB,mBAAmB,sBAyBrB,CAAC"}
@@ -9,16 +9,36 @@ type NonNullCustomElement = ((props: {
9
9
  }) => NonNullable<ReactNode>) | NonNullable<ReactNode>;
10
10
  export type RadioCardItemProps = {
11
11
  ["data-testid"]?: string;
12
+ /**
13
+ * `string | ReactNode | (props: { disabled?: boolean }) => ReactNode`
14
+ */
12
15
  body?: string | CustomElement;
13
16
  children?: ReactNode;
14
17
  disabled?: boolean;
15
18
  id: string;
19
+ /**
20
+ * The radio image.
21
+ *
22
+ union = {
23
+ "data-testid"?: string | undefined;
24
+ altText: string;
25
+ loading?: "lazy" | "eager" | undefined;
26
+ noPlaceholder?: boolean | undefined;
27
+ src: string;
28
+ } |
29
+ ((props: {
30
+ disabled?: boolean;
31
+ }) => ReactNode) | React.ReactNode
32
+ * */
16
33
  image?: RadioCardImageProps | CustomElement;
17
34
  required?: boolean;
18
- title: string | NonNullCustomElement;
19
35
  value: string;
36
+ /**
37
+ * `union = string | Omit<ReactNode, "undefined" | "null">`
38
+ */
39
+ title: string | NonNullCustomElement;
20
40
  };
21
41
  export declare const RadioCardItem: React.ForwardRefExoticComponent<RadioCardItemProps & React.RefAttributes<HTMLDivElement>>;
22
- export declare const isRadioCardItem: (child: ReactElement | Iterable<ReactNode> | ReactPortal | string | number | boolean | null | undefined) => child is React.ReactElement<RadioCardItemProps, string | React.JSXElementConstructor<any>>;
42
+ export declare const isRadioCardItem: (child: ReactElement | Iterable<ReactNode> | ReactPortal | string | number | boolean | null | undefined) => child is ReactElement<RadioCardItemProps>;
23
43
  export {};
24
44
  //# sourceMappingURL=radio-card-item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"radio-card-item.d.ts","sourceRoot":"","sources":["../src/radio-card-item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAIZ,YAAY,EACZ,SAAS,EACT,WAAW,EACZ,MAAM,OAAO,CAAC;AAKf,OAAO,EAGL,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AAIjC,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;AAChF,KAAK,oBAAoB,GACrB,CAAC,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,KAAK,WAAW,CAAC,SAAS,CAAC,CAAC,GAC3D,WAAW,CAAC,SAAS,CAAC,CAAC;AAE3B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,mBAAmB,GAAG,aAAa,CAAC;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA+EF,eAAO,MAAM,aAAa,2FAAqC,CAAC;AAGhE,eAAO,MAAM,eAAe,UAEtB,YAAY,GACZ,SAAS,SAAS,CAAC,GACnB,WAAW,GACX,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,+FAE6D,CAAC"}
1
+ {"version":3,"file":"radio-card-item.d.ts","sourceRoot":"","sources":["../src/radio-card-item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAIZ,YAAY,EACZ,SAAS,EACT,WAAW,EACZ,MAAM,OAAO,CAAC;AAKf,OAAO,EAGL,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AAIjC,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;AAChF,KAAK,oBAAoB,GACrB,CAAC,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,KAAK,WAAW,CAAC,SAAS,CAAC,CAAC,GAC3D,WAAW,CAAC,SAAS,CAAC,CAAC;AAE3B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX;;;;;;;;;;;;;SAaK;IACL,KAAK,CAAC,EAAE,mBAAmB,GAAG,aAAa,CAAC;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAAC;CACtC,CAAC;AAmFF,eAAO,MAAM,aAAa,2FAAqC,CAAC;AAGhE,eAAO,MAAM,eAAe,UAEtB,YAAY,GACZ,QAAQ,CAAC,SAAS,CAAC,GACnB,WAAW,GACX,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,KACZ,KAAK,IAAI,YAAY,CAAC,kBAAkB,CACiC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpurds/radio-card-group",
3
- "version": "5.11.0",
3
+ "version": "5.11.1",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "./dist/radio-card-group.cjs.js",
6
6
  "types": "./dist/radio-card-group.d.ts",
@@ -16,39 +16,39 @@
16
16
  "dependencies": {
17
17
  "@radix-ui/react-radio-group": "~1.1.3",
18
18
  "classnames": "~2.5.0",
19
- "@purpurds/heading": "5.11.0",
20
- "@purpurds/tokens": "5.11.0",
21
- "@purpurds/paragraph": "5.11.0",
22
- "@purpurds/skeleton": "5.11.0"
19
+ "@purpurds/heading": "5.11.1",
20
+ "@purpurds/skeleton": "5.11.1",
21
+ "@purpurds/paragraph": "5.11.1",
22
+ "@purpurds/tokens": "5.11.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@rushstack/eslint-patch": "~1.10.0",
26
- "@storybook/blocks": "~7.6.0",
27
- "@storybook/react": "~7.6.0",
26
+ "@storybook/preview-api": "^8.2.6",
27
+ "@storybook/react": "^8.2.6",
28
28
  "@telia/base-rig": "~8.2.0",
29
29
  "@telia/react-rig": "~3.2.0",
30
30
  "@testing-library/dom": "~9.3.3",
31
31
  "@testing-library/jest-dom": "~6.4.0",
32
32
  "@testing-library/react": "~14.3.0",
33
33
  "@types/node": "20.12.12",
34
- "@types/react-dom": "~18.3.0",
35
- "@types/react": "~18.3.0",
34
+ "@types/react-dom": "^18.3.0",
35
+ "@types/react": "^18.3.3",
36
36
  "eslint-plugin-testing-library": "~6.2.0",
37
- "eslint": "~8.57.0",
37
+ "eslint": "^8.57.0",
38
38
  "jsdom": "~22.1.0",
39
39
  "lint-staged": "~10.5.3",
40
40
  "prettier": "~2.8.8",
41
- "react-dom": "~18.3.0",
42
- "react": "~18.3.0",
43
- "typescript": "~5.4.2",
44
- "vite": "~5.2.2",
41
+ "react-dom": "^18.3.1",
42
+ "react": "^18.3.1",
43
+ "storybook": "^8.2.6",
44
+ "typescript": "^5.5.4",
45
+ "vite": "5.3.4",
45
46
  "vitest": "~1.5.0",
46
- "@storybook/client-api": "~7.6.0",
47
+ "@purpurds/badge": "5.11.1",
48
+ "@purpurds/button": "5.11.1",
47
49
  "@purpurds/component-rig": "1.0.0",
48
- "@purpurds/grid": "5.11.0",
49
- "@purpurds/button": "5.11.0",
50
- "@purpurds/text-field": "5.11.0",
51
- "@purpurds/badge": "5.11.0"
50
+ "@purpurds/grid": "5.11.1",
51
+ "@purpurds/text-field": "5.11.1"
52
52
  },
53
53
  "scripts": {
54
54
  "build:dev": "vite",
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { Badge } from "@purpurds/badge";
3
3
  import { Grid } from "@purpurds/grid";
4
4
  import { Paragraph } from "@purpurds/paragraph";
5
- import { useArgs } from "@storybook/client-api";
5
+ import { useArgs } from "@storybook/preview-api";
6
6
  import type { Meta, StoryObj } from "@storybook/react";
7
7
 
8
8
  import "@purpurds/badge/styles";
@@ -11,12 +11,55 @@ import "@purpurds/heading/styles";
11
11
  import "@purpurds/paragraph/styles";
12
12
  import "@purpurds/skeleton/styles";
13
13
  import imageFile from "../static/story-image.png";
14
- import { RadioCardGroup, RadioCardGroupItem, RadioCardItem } from "./radio-card-group";
14
+ import {
15
+ ORIENTATION,
16
+ RADIO_POSITION,
17
+ RadioCardGroup,
18
+ RadioCardGroupItem,
19
+ RadioCardItem,
20
+ } from "./radio-card-group";
15
21
 
16
- const meta: Meta<typeof RadioCardGroup> = {
22
+ const decorators: Story["decorators"] = [
23
+ (Story, { args }) => (
24
+ <Grid colsLg={args.orientation === "horizontal" ? 1 : 2}>
25
+ <Story />
26
+ </Grid>
27
+ ),
28
+ ];
29
+
30
+ const meta = {
17
31
  title: "Inputs/RadioCardGroup",
18
32
  component: RadioCardGroup,
19
- };
33
+ parameters: {
34
+ design: {
35
+ name: "RadioCardGroup",
36
+ type: "figma",
37
+ url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=36624-5815",
38
+ },
39
+ },
40
+ subcomponents: {
41
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
42
+ //@ts-ignore
43
+ RadioCardGroupItem: RadioCardItem,
44
+ },
45
+ decorators,
46
+ argTypes: {
47
+ orientation: {
48
+ table: {
49
+ type: {
50
+ summary: ORIENTATION.map((x) => `"${x}"`).join(" | "),
51
+ },
52
+ },
53
+ },
54
+ radioPosition: {
55
+ table: {
56
+ type: {
57
+ summary: RADIO_POSITION.map((x) => `"${x}"`).join(" | "),
58
+ },
59
+ },
60
+ },
61
+ },
62
+ } satisfies Meta<typeof RadioCardGroup>;
20
63
 
21
64
  export default meta;
22
65
  type Story = StoryObj<typeof RadioCardGroup>;
@@ -29,14 +72,6 @@ const items: RadioCardGroupItem[] = Array.from(Array(4).keys()).map((key) => ({
29
72
  value: `item-${key + 1}`,
30
73
  }));
31
74
 
32
- const decorators: Story["decorators"] = [
33
- (Story, { args }) => (
34
- <Grid colsLg={args.orientation === "horizontal" ? 1 : 2}>
35
- <Story />
36
- </Grid>
37
- ),
38
- ];
39
-
40
75
  export const Controlled: Story = {
41
76
  args: {
42
77
  items,
@@ -44,16 +79,6 @@ export const Controlled: Story = {
44
79
  id: "radio-card-story",
45
80
  value: items[0].value,
46
81
  },
47
- parameters: {
48
- design: [
49
- {
50
- name: "RadioCardGroup",
51
- type: "figma",
52
- url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=36624-5815",
53
- },
54
- ],
55
- },
56
- decorators,
57
82
  render: ({ ...args }) => {
58
83
  const [{ value }, updateArgs] = useArgs(); // eslint-disable-line react-hooks/rules-of-hooks
59
84
  const onValueChange = (value: string) => {
@@ -72,16 +97,6 @@ export const Uncontrolled: Story = {
72
97
  id: "radio-card-story",
73
98
  defaultValue: items[0].value,
74
99
  },
75
- parameters: {
76
- design: [
77
- {
78
- name: "RadioCardGroup",
79
- type: "figma",
80
- url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=36624-5815",
81
- },
82
- ],
83
- },
84
- decorators,
85
100
  };
86
101
 
87
102
  const itemsAsChildren: RadioCardGroupItem[] = [
@@ -138,16 +153,6 @@ export const ItemsAsChildren: Story = {
138
153
  id: "radio-card-story",
139
154
  defaultValue: items[0].value,
140
155
  },
141
- parameters: {
142
- design: [
143
- {
144
- name: "RadioCardGroup",
145
- type: "figma",
146
- url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=36624-5815",
147
- },
148
- ],
149
- },
150
- decorators,
151
156
  render: ({ ...args }) => {
152
157
  const [{ value }, updateArgs] = useArgs(); // eslint-disable-line react-hooks/rules-of-hooks
153
158
  const onValueChange = (value: string) => {
@@ -6,6 +6,8 @@ import { cx } from "./classnames";
6
6
  import { isRadioCardItem, RadioCardItem, RadioCardItemProps } from "./radio-card-item";
7
7
 
8
8
  export type RadioCardGroupItem = RadioCardItemProps & { ref?: Ref<HTMLDivElement> };
9
+ export const ORIENTATION = ["horizontal", "vertical"] as const;
10
+ export const RADIO_POSITION = ["right", "left"] as const;
9
11
 
10
12
  export type RadioCardGroupProps = {
11
13
  /**
@@ -53,11 +55,11 @@ export type RadioCardGroupProps = {
53
55
  /**
54
56
  * Set to stack cards horizontally or vertically. When `horizontal`, the min card width with is 100% when container is sm, and `--purpur-breakpoint-lg` / 4 when the container is md or larger.
55
57
  * */
56
- orientation?: "horizontal" | "vertical";
58
+ orientation?: (typeof ORIENTATION)[number];
57
59
  /**
58
60
  * The position if the radio in the card items.
59
61
  * */
60
- radioPosition?: "right" | "left";
62
+ radioPosition?: (typeof RADIO_POSITION)[number];
61
63
  /**
62
64
  * When true, indicates that the user must check a radio card item before the owning form can be submitted.
63
65
  * */
@@ -42,7 +42,7 @@ describe("RadioButtonGroup", () => {
42
42
  value="test-value"
43
43
  title={<div data-testid="custom-title">Custom title</div>}
44
44
  body={<div data-testid="custom-body">Custom body</div>}
45
- image={<img data-testid="custom-image" />}
45
+ image={<img alt="" data-testid="custom-image" />}
46
46
  />
47
47
  </RadixRadioGroup.RadioGroup>
48
48
  );
@@ -25,14 +25,35 @@ type NonNullCustomElement =
25
25
 
26
26
  export type RadioCardItemProps = {
27
27
  ["data-testid"]?: string;
28
+
29
+ /**
30
+ * `string | ReactNode | (props: { disabled?: boolean }) => ReactNode`
31
+ */
28
32
  body?: string | CustomElement;
29
33
  children?: ReactNode;
30
34
  disabled?: boolean;
31
35
  id: string;
36
+ /**
37
+ * The radio image.
38
+ *
39
+ union = {
40
+ "data-testid"?: string | undefined;
41
+ altText: string;
42
+ loading?: "lazy" | "eager" | undefined;
43
+ noPlaceholder?: boolean | undefined;
44
+ src: string;
45
+ } |
46
+ ((props: {
47
+ disabled?: boolean;
48
+ }) => ReactNode) | React.ReactNode
49
+ * */
32
50
  image?: RadioCardImageProps | CustomElement;
33
51
  required?: boolean;
34
- title: string | NonNullCustomElement;
35
52
  value: string;
53
+ /**
54
+ * `union = string | Omit<ReactNode, "undefined" | "null">`
55
+ */
56
+ title: string | NonNullCustomElement;
36
57
  };
37
58
 
38
59
  const renderCustomElement = (
@@ -40,7 +61,10 @@ const renderCustomElement = (
40
61
  { disabled }: Pick<RadioCardItemProps, "disabled">
41
62
  ) => (typeof element === "function" ? element({ disabled }) : element);
42
63
 
43
- const RadioCardItemComponent = (props: RadioCardItemProps, ref: ForwardedRef<HTMLDivElement>) => {
64
+ const RadioCardItemComponent = (
65
+ { title, ...propsx }: RadioCardItemProps,
66
+ ref: ForwardedRef<HTMLDivElement>
67
+ ) => {
44
68
  const {
45
69
  ["data-testid"]: dataTestid,
46
70
  body,
@@ -49,9 +73,10 @@ const RadioCardItemComponent = (props: RadioCardItemProps, ref: ForwardedRef<HTM
49
73
  id,
50
74
  image,
51
75
  required,
52
- title,
53
76
  value,
54
- } = props;
77
+ } = propsx;
78
+
79
+ const props = { title, ...propsx };
55
80
 
56
81
  return (
57
82
  <div className={cx(`${rootClassName}-container`)} ref={ref}>
package/readme.mdx DELETED
@@ -1,178 +0,0 @@
1
- import { Meta, ArgTypes, Primary, Subtitle } from "@storybook/blocks";
2
-
3
- import * as RadioCardGroupStories from "./src/radio-card-group.stories";
4
- import packageInfo from "./package.json";
5
-
6
- <Meta name="Docs" title="Components/RadioCardGroup" of={RadioCardGroupStories} />
7
-
8
- # RadioCardGroup
9
-
10
- <Subtitle>Version {packageInfo.version}</Subtitle>
11
-
12
- ### Showcase
13
-
14
- <Primary />
15
-
16
- ### Properties
17
-
18
- <ArgTypes />
19
-
20
- ### Installation
21
-
22
- #### Via NPM
23
-
24
- Add the dependency to your consumer app like `"@purpurds/purpur": "^x.y.z"`
25
-
26
- In MyApp.tsx
27
-
28
- or
29
-
30
- ```tsx
31
- import "@purpurds/purpur/styles";
32
- ```
33
-
34
- ### Examples
35
-
36
- In MyComponent.tsx
37
-
38
- #### Controlled
39
-
40
- ```tsx
41
- import { RadioCardGroup } from "@purpurds/purpur";
42
-
43
- export const MyComponent = ({ dataSet }: Props) => {
44
- const [selectedItem, setSelectedItem] = useState();
45
- const items = dataSet.map((itemData) => ({
46
- id: itemData.id,
47
- image: { src: itemData.imageSrc, altText: itemData.imageAltText },
48
- title: itemData.name,
49
- body: itemData.description,
50
- value: itemData.id,
51
- }));
52
-
53
- const onValueChange = (value?: string) => {
54
- const itemToSelect = items.find((item) => item.value === value);
55
- setSelectedItem(itemToSelect.value);
56
- };
57
-
58
- return (
59
- <div>
60
- <RadioCardGroup
61
- {...someProps}
62
- items={items}
63
- value={selectedItem}
64
- onValueChange={onValueChange}
65
- />
66
- </div>
67
- );
68
- };
69
- ```
70
-
71
- With items as children
72
-
73
- ```tsx
74
- import { RadioCardGroup } from "@purpurds/radio-card-group";
75
-
76
- export const MyComponent = ({ dataSet }: Props) => {
77
- const [selectedItem, setSelectedItem] = useState();
78
-
79
- const onValueChange = (value?: string) => {
80
- const itemToSelect = dataSet.find((itemData) => itemData.id === value);
81
- setSelectedItem(itemToSelect.id);
82
- };
83
-
84
- return (
85
- <RadioCardGroup
86
- id="example"
87
- lable="Items as children"
88
- value={selectedItem}
89
- onValueChange={onValueChange}
90
- >
91
- {dataSet.map((itemData) => (
92
- <RadioCardItem
93
- key={itemData.id}
94
- id={itemData.id}
95
- image={{ src: itemData.imageSrc, altText: itemData.imageAltText }}
96
- title={itemData.name}
97
- body={itemData.description}
98
- value={itemData.id}
99
- />
100
- ))}
101
- <div>This div will no be rendered since its no a RadioCardItem</div>
102
- </RadioCardGroup>
103
- );
104
- };
105
- ```
106
-
107
- #### Uncontrolled
108
-
109
- ```tsx
110
- import { RadioCardGroup } from "@purpurds/radio-card-group";
111
-
112
- export const MyComponent = ({ dataSet }: Props) => {
113
- const items = dataSet.map((itemData) => ({
114
- id: itemData.id,
115
- image: { src: itemData.imageSrc, altText: itemData.imageAltText },
116
- title: itemData.name,
117
- body: itemData.description,
118
- value: itemData.id,
119
- }));
120
-
121
- return (
122
- <div>
123
- <RadioCardGroup {...someProps} items={items} />
124
- </div>
125
- );
126
- };
127
- ```
128
-
129
- #### With custom title, body and image
130
-
131
- ```tsx
132
- import { RadioCardGroup } from "@purpurds/radio-card-group";
133
- import { Badge } from "@purpurds/badge";
134
- import { IconPebble } from "@purpurds/icon";
135
- import { Paragraph } from "@purpurds/paragraph";
136
-
137
- export const MyComponent = ({ dataSet }: Props) => {
138
- const items = dataSet.map((itemData) => ({
139
- id: itemData.id,
140
- image: (
141
- <div styles={{ display: "flex", justifyContent: "center", alignItems: "center" }}>
142
- <IconPebble />
143
- </div>
144
- ),
145
- title: ({ disabled }) => (
146
- <div style={{ display: "flex", gap: "var(--purpur-spacing-150)" }}>
147
- <Paragraph disabled={disabled} variant="paragraph-100">
148
- <b>Custom title</b>
149
- </Paragraph>
150
- <Badge variant="attention">Nice price!</Badge>
151
- </div>
152
- ),
153
- body: ({ disabled }) => (
154
- <Paragraph disabled={disabled} variant="paragraph-100">
155
- <span
156
- style={{
157
- textDecoration: "line-through",
158
- color: "var(--purpur-color-gray-400)",
159
- marginRight: "var(--purpur-spacing-50)",
160
- }}
161
- >
162
- {itemdata.ordinaryPrice} kr/mån
163
- </span>
164
- <span style={{ fontWeight: "var(--purpur-typography-weight-medium)" }}>
165
- {itemdata.price} kr/mån
166
- </span>
167
- </Paragraph>
168
- ),,
169
- value: itemData.id,
170
- }));
171
-
172
- return (
173
- <div>
174
- <RadioCardGroup {...someProps} items={items} />
175
- </div>
176
- );
177
- };
178
- ```