@coopdigital/react 0.4.1 → 0.5.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/components/Pill/Pill.d.ts +9 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +4 -4
- package/src/components/Pill/Pill.tsx +9 -0
- package/src/index.ts +0 -1
- package/src/styles/Colours.mdx +153 -26
- package/src/styles/Text.mdx +69 -14
- package/src/styles/Typography.mdx +43 -0
- package/dist/components/Button/Button.d.ts +0 -2
- package/dist/components/Button/Button.js +0 -8
- package/dist/components/Button/index.d.ts +0 -4
- package/src/components/Button/Button.tsx +0 -10
- package/src/components/Button/index.ts +0 -5
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import React, { AnchorHTMLAttributes, ForwardRefExoticComponent } from "react";
|
|
2
2
|
export interface PillProps {
|
|
3
|
+
/** Specifies the custom element to override default `a` or `span` */
|
|
3
4
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string;
|
|
5
|
+
/** Specifies a custom aria-label */
|
|
4
6
|
ariaLabel?: string;
|
|
7
|
+
/** Specifies what text Pill should display on the badge. */
|
|
5
8
|
badge?: string;
|
|
9
|
+
/** Specifies the badge background color from the available options. */
|
|
6
10
|
badgeColor?: "green" | "orange" | "red" | "pink";
|
|
11
|
+
/** Represents the content inside the Pill component. It can be any valid JSX or string. */
|
|
7
12
|
children?: React.ReactNode;
|
|
13
|
+
/** Receives any optional className to be applied to Pill component. */
|
|
8
14
|
className?: string;
|
|
15
|
+
/** Specifies the URL that the Pill component will link to when clicked. */
|
|
9
16
|
href?: string;
|
|
17
|
+
/** Specifies the Pill background color from the available options. */
|
|
10
18
|
pillColor?: "blue" | "pink";
|
|
19
|
+
/** Specifies what should be the Pill size. */
|
|
11
20
|
size?: "sm" | "md" | "lg" | "xl";
|
|
12
21
|
}
|
|
13
22
|
export declare const Pill: ({ ariaLabel, as, badge, badgeColor, children, className, href, pillColor, size, }: PillProps) => React.ReactElement<React.AnchorHTMLAttributes<HTMLElement>, string | React.JSXElementConstructor<any>>;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coopdigital/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"private": false,
|
|
7
7
|
"publishConfig": {
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"description": "",
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@axe-core/playwright": "^4.10.1",
|
|
41
|
-
"@
|
|
42
|
-
"@coopdigital/styles": "^0.5.2",
|
|
41
|
+
"@coopdigital/styles": "^0.5.3",
|
|
43
42
|
"@playwright/test": "^1.50.1",
|
|
44
43
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
45
44
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
45
|
+
"@storybook/addon-a11y": "^8.6.4",
|
|
46
46
|
"@storybook/addon-essentials": "^8.6.3",
|
|
47
47
|
"@storybook/addon-interactions": "^8.6.3",
|
|
48
48
|
"@storybook/addon-mdx-gfm": "^8.6.3",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"react": "^19.0.0",
|
|
65
65
|
"react-dom": "^19.0.0"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "fdc3cd6c04f66f5b1240f615951d337ac0669eac"
|
|
68
68
|
}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import React, { AnchorHTMLAttributes, ForwardRefExoticComponent } from "react"
|
|
2
2
|
|
|
3
3
|
export interface PillProps {
|
|
4
|
+
/** Specifies the custom element to override default `a` or `span` */
|
|
4
5
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
6
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string
|
|
7
|
+
/** Specifies a custom aria-label */
|
|
6
8
|
ariaLabel?: string
|
|
9
|
+
/** Specifies what text Pill should display on the badge. */
|
|
7
10
|
badge?: string
|
|
11
|
+
/** Specifies the badge background color from the available options. */
|
|
8
12
|
badgeColor?: "green" | "orange" | "red" | "pink"
|
|
13
|
+
/** Represents the content inside the Pill component. It can be any valid JSX or string. */
|
|
9
14
|
children?: React.ReactNode
|
|
15
|
+
/** Receives any optional className to be applied to Pill component. */
|
|
10
16
|
className?: string
|
|
17
|
+
/** Specifies the URL that the Pill component will link to when clicked. */
|
|
11
18
|
href?: string
|
|
19
|
+
/** Specifies the Pill background color from the available options. */
|
|
12
20
|
pillColor?: "blue" | "pink"
|
|
21
|
+
/** Specifies what should be the Pill size. */
|
|
13
22
|
size?: "sm" | "md" | "lg" | "xl"
|
|
14
23
|
}
|
|
15
24
|
|
package/src/index.ts
CHANGED
package/src/styles/Colours.mdx
CHANGED
|
@@ -1,33 +1,160 @@
|
|
|
1
|
-
import { ColorPalette, ColorItem } from "@storybook/blocks"
|
|
1
|
+
import { Meta, ColorPalette, ColorItem } from "@storybook/blocks"
|
|
2
|
+
|
|
3
|
+
export const compStyle = getComputedStyle(document.documentElement)
|
|
4
|
+
|
|
5
|
+
<Meta title="Styles / Colours" />
|
|
6
|
+
|
|
7
|
+
# Colours
|
|
8
|
+
|
|
9
|
+
<br />
|
|
10
|
+
|
|
11
|
+
## Brand colours
|
|
12
|
+
|
|
13
|
+
<br />
|
|
14
|
+
<br />
|
|
2
15
|
|
|
3
16
|
<ColorPalette>
|
|
4
17
|
<ColorItem
|
|
5
|
-
title="
|
|
6
|
-
subtitle="
|
|
7
|
-
colors={{
|
|
8
|
-
/>
|
|
9
|
-
<ColorItem title="theme.color.primary" subtitle="Coral" colors={{ WildWatermelon: "#FF4785" }} />
|
|
10
|
-
<ColorItem title="theme.color.secondary" subtitle="Ocean" colors={{ DodgerBlue: "#1EA7FD" }} />
|
|
11
|
-
<ColorItem
|
|
12
|
-
title="theme.color.positive"
|
|
13
|
-
subtitle="Green"
|
|
14
|
-
colors={{
|
|
15
|
-
Apple: "rgba(102,191,60,1)",
|
|
16
|
-
Apple80: "rgba(102,191,60,.8)",
|
|
17
|
-
Apple60: "rgba(102,191,60,.6)",
|
|
18
|
-
Apple30: "rgba(102,191,60,.3)",
|
|
19
|
-
}}
|
|
20
|
-
/>
|
|
21
|
-
<ColorItem
|
|
22
|
-
title="gradient"
|
|
23
|
-
subtitle="Grayscale"
|
|
24
|
-
colors={{
|
|
25
|
-
Gradient: "linear-gradient(to right,white,black)",
|
|
26
|
-
}}
|
|
18
|
+
title="Co-op blue"
|
|
19
|
+
subtitle="Co-op blue"
|
|
20
|
+
colors={{ "--color-brand-coop": compStyle.getPropertyValue("--color-brand-coop") }}
|
|
27
21
|
/>
|
|
28
22
|
<ColorItem
|
|
29
|
-
title="
|
|
30
|
-
subtitle="
|
|
31
|
-
colors={
|
|
23
|
+
title="Co-op deal red"
|
|
24
|
+
subtitle="Co-op brand deals"
|
|
25
|
+
colors={{ "--color-brand-deals": compStyle.getPropertyValue("--color-brand-deals") }}
|
|
32
26
|
/>
|
|
27
|
+
|
|
28
|
+
<ColorItem
|
|
29
|
+
title="Text colours"
|
|
30
|
+
colors={{
|
|
31
|
+
"--color-white": compStyle.getPropertyValue("--color-white"),
|
|
32
|
+
"--color-text-alt": compStyle.getPropertyValue("--color-text-alt"),
|
|
33
|
+
"--color-text": compStyle.getPropertyValue("--color-text"),
|
|
34
|
+
"--color-black": compStyle.getPropertyValue("--color-black"),
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
<ColorItem
|
|
39
|
+
title="Tint colours"
|
|
40
|
+
colors={{
|
|
41
|
+
"--color-tint-purple": compStyle.getPropertyValue("--color-tint-purple"),
|
|
42
|
+
"--color-tint-pink": compStyle.getPropertyValue("--color-tint-pink"),
|
|
43
|
+
"--color-tint-green": compStyle.getPropertyValue("--color-tint-green"),
|
|
44
|
+
"--color-tint-orange": compStyle.getPropertyValue("--color-tint-orange"),
|
|
45
|
+
"--color-tint-red": compStyle.getPropertyValue("--color-tint-red"),
|
|
46
|
+
"--color-tint-yellow": compStyle.getPropertyValue("--color-tint-yellow"),
|
|
47
|
+
"--color-tint-lilac": compStyle.getPropertyValue("--color-tint-lilac"),
|
|
48
|
+
"--color-tint-blue": compStyle.getPropertyValue("--color-tint-blue"),
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
<ColorItem
|
|
53
|
+
title="Light colours"
|
|
54
|
+
colors={{
|
|
55
|
+
"--color-light-purple": compStyle.getPropertyValue("--color-light-purple"),
|
|
56
|
+
"--color-light-pink": compStyle.getPropertyValue("--color-light-pink"),
|
|
57
|
+
"--color-light-green": compStyle.getPropertyValue("--color-light-green"),
|
|
58
|
+
"--color-light-orange": compStyle.getPropertyValue("--color-light-orange"),
|
|
59
|
+
"--color-light-red": compStyle.getPropertyValue("--color-light-red"),
|
|
60
|
+
"--color-light-yellow": compStyle.getPropertyValue("--color-light-yellow"),
|
|
61
|
+
"--color-light-lilac": compStyle.getPropertyValue("--color-light-lilac"),
|
|
62
|
+
"--color-light-blue": compStyle.getPropertyValue("--color-light-blue"),
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
<ColorItem
|
|
67
|
+
title="Dark colours"
|
|
68
|
+
colors={{
|
|
69
|
+
"--color-dark-purple": compStyle.getPropertyValue("--color-dark-purple"),
|
|
70
|
+
"--color-dark-pink": compStyle.getPropertyValue("--color-dark-pink"),
|
|
71
|
+
"--color-dark-green": compStyle.getPropertyValue("--color-dark-green"),
|
|
72
|
+
"--color-dark-orange": compStyle.getPropertyValue("--color-dark-orange"),
|
|
73
|
+
"--color-dark-red": compStyle.getPropertyValue("--color-dark-red"),
|
|
74
|
+
"--color-dark-yellow": compStyle.getPropertyValue("--color-dark-yellow"),
|
|
75
|
+
"--color-dark-lilac": compStyle.getPropertyValue("--color-dark-lilac"),
|
|
76
|
+
"--color-navy": compStyle.getPropertyValue("--color-navy"),
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
79
|
+
|
|
80
|
+
<ColorItem
|
|
81
|
+
title="Grey backgrounds"
|
|
82
|
+
colors={{
|
|
83
|
+
"--color-grey-neutral-light": compStyle.getPropertyValue("--color-grey-neutral-light"),
|
|
84
|
+
"--color-grey-neutral-warm": compStyle.getPropertyValue("--color-grey-neutral-warm"),
|
|
85
|
+
"--color-grey-neutral-cool": compStyle.getPropertyValue("--color-grey-neutral-cool"),
|
|
86
|
+
"--color-grey-neutral-cool-light": compStyle.getPropertyValue(
|
|
87
|
+
"--color-grey-neutral-cool-light"
|
|
88
|
+
),
|
|
89
|
+
"--color-grey-mid-light": compStyle.getPropertyValue("--color-grey-mid-light"),
|
|
90
|
+
"--color-grey-mid": compStyle.getPropertyValue("--color-grey-mid"),
|
|
91
|
+
"--color-grey-dark": compStyle.getPropertyValue("--color-grey-dark"),
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
|
|
95
|
+
<br />
|
|
96
|
+
<br />
|
|
97
|
+
<br />
|
|
98
|
+
<br />
|
|
99
|
+
## UI colors
|
|
100
|
+
|
|
101
|
+
<br />
|
|
102
|
+
### Link
|
|
103
|
+
<br />
|
|
104
|
+
<ColorItem
|
|
105
|
+
title="Link colours"
|
|
106
|
+
colors={{
|
|
107
|
+
"--color-link": compStyle.getPropertyValue("--color-link"),
|
|
108
|
+
"--color-link-hover": compStyle.getPropertyValue("--color-link-hover"),
|
|
109
|
+
"--color-link-active": compStyle.getPropertyValue("--color-link-active"),
|
|
110
|
+
"--color-link-visited": compStyle.getPropertyValue("--color-link-visited"),
|
|
111
|
+
"--color-link-focus": compStyle.getPropertyValue("--color-link-focus"),
|
|
112
|
+
"--color-focus-ring": compStyle.getPropertyValue("--color-focus-ring"),
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
|
|
116
|
+
<br />
|
|
117
|
+
### Button
|
|
118
|
+
<br />
|
|
119
|
+
<ColorItem
|
|
120
|
+
title="Primary green button"
|
|
121
|
+
colors={{
|
|
122
|
+
"--color-button-green-primary": compStyle.getPropertyValue("--color-button-green-primary"),
|
|
123
|
+
"--color-button-green-primary-hover": compStyle.getPropertyValue(
|
|
124
|
+
"--color-button-green-primary-hover"
|
|
125
|
+
),
|
|
126
|
+
"--color-button-green-primary-active": compStyle.getPropertyValue(
|
|
127
|
+
"--color-button-green-primary-active"
|
|
128
|
+
),
|
|
129
|
+
}}
|
|
130
|
+
/>
|
|
131
|
+
<ColorItem
|
|
132
|
+
title="Blue button (default)"
|
|
133
|
+
colors={{
|
|
134
|
+
"--color-button / --color-button-blue": compStyle.getPropertyValue("--color-button-blue"),
|
|
135
|
+
"--color-button-hover / --color-button-blue-hover": compStyle.getPropertyValue(
|
|
136
|
+
"--color-button-blue-hover"
|
|
137
|
+
),
|
|
138
|
+
"--color-button-active / --color-button-blue-active": compStyle.getPropertyValue(
|
|
139
|
+
"--color-button-blue-active"
|
|
140
|
+
),
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
<ColorItem
|
|
144
|
+
title="Grey button"
|
|
145
|
+
colors={{
|
|
146
|
+
"--color-button-grey": compStyle.getPropertyValue("--color-button-grey"),
|
|
147
|
+
"--color-button-grey-hover": compStyle.getPropertyValue("--color-button-grey-hover"),
|
|
148
|
+
"--color-button-grey-active": compStyle.getPropertyValue("--color-button-grey-active"),
|
|
149
|
+
}}
|
|
150
|
+
/>
|
|
151
|
+
<ColorItem
|
|
152
|
+
title="White button"
|
|
153
|
+
colors={{
|
|
154
|
+
"--color-button-white": compStyle.getPropertyValue("--color-button-white"),
|
|
155
|
+
"--color-button-white-hover": compStyle.getPropertyValue("--color-button-white-hover"),
|
|
156
|
+
"--color-button-white-active": compStyle.getPropertyValue("--color-button-white-active"),
|
|
157
|
+
}}
|
|
158
|
+
/>
|
|
159
|
+
|
|
33
160
|
</ColorPalette>
|
package/src/styles/Text.mdx
CHANGED
|
@@ -1,17 +1,72 @@
|
|
|
1
|
-
import { Unstyled } from "@storybook/blocks"
|
|
1
|
+
import { Meta, Unstyled } from "@storybook/blocks"
|
|
2
|
+
|
|
3
|
+
<Meta title="Styles / Text" />
|
|
4
|
+
|
|
5
|
+
export const SampleText = "Lorem ipsum dolor..."
|
|
6
|
+
|
|
7
|
+
# Text
|
|
8
|
+
|
|
9
|
+
<br />
|
|
2
10
|
|
|
3
11
|
<Unstyled>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
|
|
13
|
+
## Using Co-op Headline font
|
|
14
|
+
|
|
15
|
+
<br />
|
|
16
|
+
|
|
17
|
+
> <h1 className="coop-t-headline coop-t-headline-upper">h1: {SampleText}</h1>
|
|
18
|
+
> <h2 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h2: {SampleText}</h2>
|
|
19
|
+
> <h3 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h3: {SampleText}</h3>
|
|
20
|
+
> <h4 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h4: {SampleText}</h4>
|
|
21
|
+
> <h5 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h5: {SampleText}</h5>
|
|
22
|
+
> <h6 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h6: {SampleText}</h6>
|
|
23
|
+
|
|
24
|
+
<br />
|
|
25
|
+
|
|
26
|
+
> <h1 className="coop-t-headline coop-t-headline-blue">h1: {SampleText}</h1>
|
|
27
|
+
> <h2 className="coop-t-headline coop-t-headline-blue">h2: {SampleText}</h2>
|
|
28
|
+
> <h3 className="coop-t-headline coop-t-headline-blue">h3: {SampleText}</h3>
|
|
29
|
+
> <h4 className="coop-t-headline coop-t-headline-blue">h4: {SampleText}</h4>
|
|
30
|
+
> <h5 className="coop-t-headline coop-t-headline-blue">h5: {SampleText}</h5>
|
|
31
|
+
> <h6 className="coop-t-headline coop-t-headline-blue">h6: {SampleText}</h6>
|
|
32
|
+
|
|
33
|
+
<br />
|
|
34
|
+
<br />
|
|
35
|
+
<br />
|
|
36
|
+
## Using Primary font (Avenir Next)
|
|
37
|
+
<br />
|
|
38
|
+
|
|
39
|
+
> <h1>h1: {SampleText}</h1>
|
|
40
|
+
> <h2>h2: {SampleText}</h2>
|
|
41
|
+
> <h3>h3: {SampleText}</h3>
|
|
42
|
+
> <h4>h4: {SampleText}</h4>
|
|
43
|
+
> <h5>h5: {SampleText}</h5>
|
|
44
|
+
> <h6>h6: {SampleText}</h6>
|
|
45
|
+
>
|
|
46
|
+
> <hr />
|
|
47
|
+
>
|
|
48
|
+
> <p class="coop-t-lead-p">Lead paragraph</p>
|
|
49
|
+
>
|
|
50
|
+
> <p>Paragraph text: {SampleText}</p>
|
|
51
|
+
> <a href="">Link</a>
|
|
52
|
+
> <br />
|
|
53
|
+
> <br />
|
|
54
|
+
> <p>Lists:</p>
|
|
55
|
+
> <ul>
|
|
56
|
+
> <li>Option 1</li>
|
|
57
|
+
> <li>Option 1</li>
|
|
58
|
+
> </ul>
|
|
59
|
+
> <ol>
|
|
60
|
+
> <li>Option 1</li>
|
|
61
|
+
> <li>Option 1</li>
|
|
62
|
+
> </ol>
|
|
63
|
+
|
|
17
64
|
</Unstyled>
|
|
65
|
+
|
|
66
|
+
<style>
|
|
67
|
+
{`
|
|
68
|
+
.toc-wrapper {
|
|
69
|
+
display: none;
|
|
70
|
+
}
|
|
71
|
+
`}
|
|
72
|
+
</style>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Meta, Typeset } from "@storybook/blocks"
|
|
2
|
+
|
|
3
|
+
<Meta title="Styles / Typography" />
|
|
4
|
+
|
|
5
|
+
export const compStyle = getComputedStyle(document.documentElement)
|
|
6
|
+
|
|
7
|
+
export const typography = {
|
|
8
|
+
type: {
|
|
9
|
+
primary: compStyle.getPropertyValue("--font-family"),
|
|
10
|
+
headline: compStyle.getPropertyValue("--font-family-headline"),
|
|
11
|
+
},
|
|
12
|
+
weight: {
|
|
13
|
+
regular: "400",
|
|
14
|
+
medium: "500",
|
|
15
|
+
demi: "600",
|
|
16
|
+
bold: "700",
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const SampleText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
|
|
21
|
+
export const SampleTextUppercase = SampleText.toUpperCase()
|
|
22
|
+
|
|
23
|
+
# Typography
|
|
24
|
+
|
|
25
|
+
**Font:** Avenir Next<br />
|
|
26
|
+
**Weights:** 400 (regular), 500 (medium), 600 (demi)
|
|
27
|
+
|
|
28
|
+
<Typeset
|
|
29
|
+
fontSizes={[10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 40, 46, 48, 56, 64, 82]}
|
|
30
|
+
fontWeight={typography.weight.regular}
|
|
31
|
+
sampleText={SampleText}
|
|
32
|
+
fontFamily={typography.type.primary}
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
**Font:** Co-op Headline <br />
|
|
36
|
+
**Weights:** 700 (bold)
|
|
37
|
+
|
|
38
|
+
<Typeset
|
|
39
|
+
fontSizes={[18, 20, 22, 24, 26, 28, 30, 32, 40, 46, 48, 56, 64, 82]}
|
|
40
|
+
fontWeight={typography.weight.bold}
|
|
41
|
+
sampleText={SampleTextUppercase}
|
|
42
|
+
fontFamily={typography.type.headline}
|
|
43
|
+
/>
|