@windstream/react-shared-components 0.0.17 → 0.0.20
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/contentful/index.d.ts +35 -5
- package/dist/contentful/index.esm.js +1 -1
- package/dist/contentful/index.esm.js.map +1 -1
- package/dist/contentful/index.js +1 -1
- package/dist/contentful/index.js.map +1 -1
- package/dist/core.d.ts +38 -10
- package/dist/index.d.ts +39 -11
- package/dist/index.esm.js +5 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utils/index.esm.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/accordion/Accordion.stories.tsx +16 -11
- package/src/components/accordion/index.tsx +19 -8
- package/src/components/accordion/types.ts +8 -9
- package/src/components/alert-card/AlertCard.stories.tsx +4 -5
- package/src/components/alert-card/index.tsx +6 -9
- package/src/components/alert-card/types.ts +9 -9
- package/src/components/brand-button/BrandButton.stories.tsx +8 -10
- package/src/components/brand-button/helpers.ts +8 -8
- package/src/components/brand-button/index.tsx +30 -27
- package/src/components/brand-button/types.ts +6 -8
- package/src/components/button/Button.stories.tsx +6 -6
- package/src/components/button/index.tsx +3 -1
- package/src/components/button/types.ts +14 -14
- package/src/components/call-button/CallButton.stories.tsx +1 -1
- package/src/components/call-button/index.tsx +3 -4
- package/src/components/call-button/types.ts +1 -0
- package/src/components/checkbox/Checkbox.stories.tsx +6 -7
- package/src/components/checkbox/index.tsx +17 -7
- package/src/components/checkbox/types.ts +19 -16
- package/src/components/checklist/Checklist.stories.tsx +1 -2
- package/src/components/checklist/index.tsx +12 -6
- package/src/components/checklist/types.ts +5 -5
- package/src/components/collapse/Collapse.stories.tsx +18 -19
- package/src/components/collapse/index.tsx +1 -1
- package/src/components/collapse/types.ts +4 -4
- package/src/components/divider/Divider.stories.tsx +16 -17
- package/src/components/divider/index.tsx +2 -3
- package/src/components/divider/type.ts +2 -2
- package/src/components/image/Image.stories.tsx +113 -0
- package/src/components/image/index.tsx +22 -0
- package/src/components/image/types.ts +28 -0
- package/src/components/input/Input.stories.tsx +13 -46
- package/src/components/input/index.tsx +18 -15
- package/src/components/input/types.ts +1 -1
- package/src/components/link/Link.stories.tsx +1 -1
- package/src/components/link/index.tsx +1 -2
- package/src/components/link/types.ts +25 -25
- package/src/components/list/List.stories.tsx +1 -1
- package/src/components/list/index.tsx +86 -86
- package/src/components/list/list-item/index.tsx +36 -36
- package/src/components/list/list-item/types.ts +13 -13
- package/src/components/list/types.ts +29 -29
- package/src/components/material-icon/MaterialIcon.stories.tsx +1 -1
- package/src/components/material-icon/constants.ts +1 -1
- package/src/components/material-icon/index.tsx +44 -44
- package/src/components/material-icon/types.ts +31 -31
- package/src/components/modal/Modal.stories.tsx +9 -9
- package/src/components/modal/index.tsx +8 -14
- package/src/components/modal/types.ts +1 -1
- package/src/components/radio-button/RadioButton.stories.tsx +7 -7
- package/src/components/radio-button/index.tsx +11 -9
- package/src/components/radio-button/types.ts +18 -19
- package/src/components/see-more/SeeMore.stories.tsx +14 -15
- package/src/components/see-more/index.tsx +33 -29
- package/src/components/see-more/types.ts +3 -3
- package/src/components/select/Select.stories.tsx +3 -2
- package/src/components/select/index.tsx +15 -17
- package/src/components/select/types.ts +2 -1
- package/src/components/select-plan-button/SelectPlanButton.stories.tsx +20 -12
- package/src/components/select-plan-button/index.tsx +28 -20
- package/src/components/select-plan-button/types.ts +1 -1
- package/src/components/skeleton/Skeleton.stories.tsx +9 -10
- package/src/components/skeleton/index.tsx +61 -61
- package/src/components/skeleton/types.ts +3 -3
- package/src/components/spinner/Spinner.stories.tsx +1 -1
- package/src/components/spinner/index.tsx +1 -1
- package/src/components/spinner/types.ts +4 -4
- package/src/components/text/Text.stories.tsx +35 -16
- package/src/components/text/index.tsx +2 -5
- package/src/components/text/types.ts +45 -45
- package/src/components/tooltip/Tooltip.stories.tsx +15 -16
- package/src/components/tooltip/index.tsx +1 -5
- package/src/components/tooltip/types.ts +4 -4
- package/src/components/view-cart-button/ViewCartButton.stories.tsx +23 -12
- package/src/components/view-cart-button/index.tsx +11 -6
- package/src/components/view-cart-button/types.ts +1 -1
- package/src/contentful/blocks/accordion/Accordion.stories.tsx +23 -0
- package/src/contentful/blocks/accordion/index.tsx +11 -1
- package/src/contentful/blocks/accordion/types.ts +1 -1
- package/src/contentful/blocks/button/Button.stories.tsx +40 -0
- package/src/contentful/blocks/button/index.tsx +15 -14
- package/src/contentful/blocks/button/types.ts +17 -17
- package/src/contentful/blocks/callout/Callout.stories.tsx +23 -0
- package/src/contentful/blocks/callout/index.tsx +9 -1
- package/src/contentful/blocks/callout/types.ts +1 -1
- package/src/contentful/blocks/cards/Cards.stories.tsx +23 -0
- package/src/contentful/blocks/cards/index.tsx +7 -1
- package/src/contentful/blocks/cards/types.ts +1 -1
- package/src/contentful/blocks/carousel/Carousel.stories.tsx +23 -0
- package/src/contentful/blocks/carousel/index.tsx +7 -1
- package/src/contentful/blocks/carousel/types.ts +1 -1
- package/src/contentful/blocks/cta-callout/CtaCallout.stories.tsx +46 -0
- package/src/contentful/blocks/cta-callout/index.tsx +5 -5
- package/src/contentful/blocks/cta-callout/types.ts +16 -16
- package/src/contentful/blocks/floating-banner/FloatingBanner.stories.tsx +23 -0
- package/src/contentful/blocks/floating-banner/index.tsx +6 -2
- package/src/contentful/blocks/floating-banner/types.ts +1 -1
- package/src/contentful/blocks/footer/Footer.stories.tsx +30 -0
- package/src/contentful/blocks/footer/index.tsx +8 -7
- package/src/contentful/blocks/footer/types.ts +7 -6
- package/src/contentful/blocks/image-promo-bar/ImagePromoBar.stories.tsx +23 -0
- package/src/contentful/blocks/image-promo-bar/index.tsx +84 -2
- package/src/contentful/blocks/image-promo-bar/types.ts +28 -1
- package/src/contentful/blocks/modal/Modal.stories.tsx +23 -0
- package/src/contentful/blocks/modal/index.tsx +8 -2
- package/src/contentful/blocks/modal/types.ts +1 -1
- package/src/contentful/blocks/navigation/Navigation.stories.tsx +23 -0
- package/src/contentful/blocks/navigation/index.tsx +6 -2
- package/src/contentful/blocks/navigation/types.ts +1 -1
- package/src/contentful/blocks/primary-hero/PrimaryHero.stories.tsx +23 -0
- package/src/contentful/blocks/primary-hero/index.tsx +4 -3
- package/src/contentful/blocks/primary-hero/types.ts +29 -25
- package/src/contentful/blocks/shape-background-wrapper/ShapeBackgroundWrapper.stories.tsx +26 -0
- package/src/contentful/blocks/shape-background-wrapper/index.tsx +107 -106
- package/src/contentful/blocks/shape-background-wrapper/types.ts +24 -23
- package/src/contentful/blocks/text/Text.stories.tsx +23 -0
- package/src/contentful/blocks/text/index.tsx +7 -1
- package/src/contentful/blocks/text/types.ts +1 -1
- package/src/contentful/index.ts +1 -1
- package/src/hooks/use-body-scroll-lock.ts +2 -1
- package/src/index.ts +14 -2
- package/src/setupTests.ts +46 -46
- package/src/stories/DocsTemplate.tsx +0 -2
- package/src/styles/globals.css +162 -162
- package/src/types/global.d.ts +9 -9
- package/src/utils/index.ts +34 -34
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
import { forwardRef } from "react";
|
|
2
|
-
import { cx } from "@shared/utils";
|
|
3
|
-
import { ButtonProps, ButtonVariantsT } from "@shared/components/brand-button/types";
|
|
4
|
-
import { MaterialIcon } from "@shared/components/material-icon";
|
|
5
4
|
import { getLabelSizeBasedOnButtonSize, sizeToClassNames } from "./helpers";
|
|
6
5
|
|
|
6
|
+
import {
|
|
7
|
+
ButtonProps,
|
|
8
|
+
ButtonVariantsT,
|
|
9
|
+
} from "@shared/components/brand-button/types";
|
|
10
|
+
import { MaterialIcon } from "@shared/components/material-icon";
|
|
11
|
+
import { cx } from "@shared/utils";
|
|
12
|
+
|
|
7
13
|
// BrandButton is intentionally limited to prevent over-configuration, restricting className and children props.
|
|
8
14
|
export const BrandButton = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
9
15
|
(
|
|
@@ -20,12 +26,11 @@ export const BrandButton = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
20
26
|
ref
|
|
21
27
|
) => {
|
|
22
28
|
const getVariantClasses = () => {
|
|
23
|
-
const baseClasses =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
29
|
+
const baseClasses = cx(
|
|
30
|
+
sizeToClassNames(size),
|
|
31
|
+
"rounded-2xl pl-15 pr-15 inline-flex gap-2 items-center justify-center outline-none focus:ring-2 focus:ring-offset-2 cursor-pointer transition-colors duration-200 align-top",
|
|
32
|
+
fullWidth && "w-full"
|
|
33
|
+
);
|
|
29
34
|
|
|
30
35
|
const variantClasses: Record<ButtonVariantsT, string> = {
|
|
31
36
|
primary_brand:
|
|
@@ -37,25 +42,20 @@ export const BrandButton = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
37
42
|
};
|
|
38
43
|
const stateClasses = cx(
|
|
39
44
|
(disabled || isLoading) && "cursor-not-allowed",
|
|
40
|
-
|
|
45
|
+
isLoading && "pl-7",
|
|
41
46
|
disabled && "bg-bg-fill-brand-disabled"
|
|
42
|
-
)
|
|
47
|
+
);
|
|
43
48
|
|
|
44
|
-
return cx(
|
|
45
|
-
baseClasses,
|
|
46
|
-
variantClasses[variant] || "",
|
|
47
|
-
stateClasses
|
|
48
|
-
)
|
|
49
|
+
return cx(baseClasses, variantClasses[variant] || "", stateClasses);
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
const variantClasses = getVariantClasses();
|
|
52
53
|
|
|
53
|
-
let infoClassNames = `button--${variant}
|
|
54
|
+
let infoClassNames = `button--${variant}`;
|
|
54
55
|
if (isLoading) infoClassNames += " button--loading";
|
|
55
56
|
if (disabled) infoClassNames += " button--disabled";
|
|
56
57
|
|
|
57
|
-
const combinedClassName =
|
|
58
|
-
`${infoClassNames} ${variantClasses}`;
|
|
58
|
+
const combinedClassName = `${infoClassNames} ${variantClasses}`;
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
61
|
<button
|
|
@@ -70,12 +70,12 @@ export const BrandButton = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
70
70
|
|
|
71
71
|
{label ? (
|
|
72
72
|
<span className="flex flex-col">
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
<span className={cx(getLabelSizeBasedOnButtonSize(size))}>
|
|
74
|
+
{label}
|
|
75
|
+
</span>
|
|
76
|
+
{text}
|
|
77
77
|
</span>
|
|
78
|
-
): (
|
|
78
|
+
) : (
|
|
79
79
|
text
|
|
80
80
|
)}
|
|
81
81
|
</button>
|
|
@@ -85,6 +85,9 @@ export const BrandButton = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
85
85
|
|
|
86
86
|
BrandButton.displayName = "BrandButton";
|
|
87
87
|
|
|
88
|
-
export type {
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
export type {
|
|
89
|
+
ButtonProps,
|
|
90
|
+
ButtonVariantsT,
|
|
91
|
+
ButtonSizeT,
|
|
92
|
+
ResponsiveSize,
|
|
93
|
+
} from "./types";
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ButtonHTMLAttributes,
|
|
3
|
-
} from "react";
|
|
1
|
+
import { type ButtonHTMLAttributes } from "react";
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
export type ButtonVariantsT = "primary_brand" | "primary_inverse" | "secondary"
|
|
3
|
+
export type ButtonVariantsT = "primary_brand" | "primary_inverse" | "secondary";
|
|
7
4
|
|
|
8
5
|
export type ButtonSizeT = "small" | "medium" | "large" | "x-large";
|
|
9
6
|
|
|
@@ -13,7 +10,7 @@ export type ResponsiveSize = {
|
|
|
13
10
|
lg?: ButtonSizeT;
|
|
14
11
|
};
|
|
15
12
|
|
|
16
|
-
export type ButtonCustomProps =
|
|
13
|
+
export type ButtonCustomProps = {
|
|
17
14
|
/** Button styling variant */
|
|
18
15
|
variant?: ButtonVariantsT;
|
|
19
16
|
/** Loading state - shows spinner and disables button */
|
|
@@ -22,6 +19,7 @@ export type ButtonCustomProps = {
|
|
|
22
19
|
text?: string;
|
|
23
20
|
fullWidth?: boolean;
|
|
24
21
|
size?: ResponsiveSize;
|
|
25
|
-
}
|
|
22
|
+
};
|
|
26
23
|
|
|
27
|
-
export type ButtonProps = ButtonCustomProps &
|
|
24
|
+
export type ButtonProps = ButtonCustomProps &
|
|
25
|
+
Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "className">;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Button } from "./index";
|
|
2
|
-
import { DocsPage } from "@shared/stories/DocsTemplate";
|
|
3
2
|
|
|
3
|
+
import { DocsPage } from "@shared/stories/DocsTemplate";
|
|
4
4
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
5
5
|
|
|
6
6
|
const meta: Meta<typeof Button> = {
|
|
@@ -78,19 +78,19 @@ export const StylingExamples: Story = {
|
|
|
78
78
|
Examples of how you can style the Button component using className:
|
|
79
79
|
</p>
|
|
80
80
|
<div className="flex flex-wrap gap-2">
|
|
81
|
-
<Button className="
|
|
81
|
+
<Button className="bg-fill-brand text-inverse btn-medium">
|
|
82
82
|
Brand Button
|
|
83
83
|
</Button>
|
|
84
|
-
<Button className="
|
|
84
|
+
<Button className="bg-surface-secondary text-default btn-medium">
|
|
85
85
|
Secondary Button
|
|
86
86
|
</Button>
|
|
87
|
-
<Button className="
|
|
87
|
+
<Button className="border-border-default text-default btn-medium border">
|
|
88
88
|
Outline Button
|
|
89
89
|
</Button>
|
|
90
|
-
<Button className="
|
|
90
|
+
<Button className="bg-fill-brand text-inverse btn-small">
|
|
91
91
|
Small Button
|
|
92
92
|
</Button>
|
|
93
|
-
<Button className="
|
|
93
|
+
<Button className="bg-fill-brand text-inverse btn-large">
|
|
94
94
|
Large Button
|
|
95
95
|
</Button>
|
|
96
96
|
</div>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { forwardRef } from "react";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { ButtonProps } from "@shared/components/button/types";
|
|
4
|
+
import { cx } from "@shared/utils";
|
|
5
|
+
|
|
4
6
|
// Minimal button: styling is entirely up to the consumer via className
|
|
5
7
|
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
6
8
|
({ children, className = "", style, disabled, ...props }, ref) => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ButtonHTMLAttributes,
|
|
3
|
-
type CSSProperties,
|
|
4
|
-
type ReactNode,
|
|
5
|
-
} from "react";
|
|
6
|
-
|
|
7
|
-
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
8
|
-
/** Content to render inside the button */
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
/** Custom className for the button */
|
|
11
|
-
className?: string;
|
|
12
|
-
/** Custom styles */
|
|
13
|
-
style?: CSSProperties;
|
|
14
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
type ButtonHTMLAttributes,
|
|
3
|
+
type CSSProperties,
|
|
4
|
+
type ReactNode,
|
|
5
|
+
} from "react";
|
|
6
|
+
|
|
7
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
8
|
+
/** Content to render inside the button */
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
/** Custom className for the button */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Custom styles */
|
|
13
|
+
style?: CSSProperties;
|
|
14
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { CallButtonProps } from "@shared/components/call-button/types";
|
|
1
2
|
import { Link } from "@shared/components/link";
|
|
2
3
|
import { MaterialIcon } from "@shared/components/material-icon";
|
|
3
4
|
import type { IconProps } from "@shared/components/material-icon/types";
|
|
4
|
-
import type { CallButtonProps } from "@shared/components/call-button/types";
|
|
5
5
|
|
|
6
6
|
export const CallButton = (props: CallButtonProps) => {
|
|
7
7
|
const {
|
|
@@ -22,8 +22,7 @@ export const CallButton = (props: CallButtonProps) => {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const styleClasses = {
|
|
25
|
-
primary:
|
|
26
|
-
"border-[0.727px] border-border text-text"
|
|
25
|
+
primary: "border-[0.727px] border-border text-text",
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
const iconSize: Record<string, IconProps["size"]> = {
|
|
@@ -57,7 +56,7 @@ export const CallButton = (props: CallButtonProps) => {
|
|
|
57
56
|
>
|
|
58
57
|
{showBlinkDot ? (
|
|
59
58
|
<span
|
|
60
|
-
className={`
|
|
59
|
+
className={`pointer-events-none absolute animate-blink ${dotPosition[size]} top-1/2 ${dotSize[size]} -translate-y-1/2 rounded-full bg-icon-brand`}
|
|
61
60
|
/>
|
|
62
61
|
) : null}
|
|
63
62
|
<span
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
1
2
|
import { Checkbox } from "./index";
|
|
2
|
-
import { DocsPage } from "@shared/stories/DocsTemplate";
|
|
3
3
|
|
|
4
|
+
import { DocsPage } from "@shared/stories/DocsTemplate";
|
|
4
5
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
5
|
-
import { useState } from "react";
|
|
6
6
|
|
|
7
7
|
const meta: Meta<typeof Checkbox> = {
|
|
8
8
|
title: "Components/Checkbox",
|
|
@@ -150,7 +150,7 @@ export const Interactive: Story = {
|
|
|
150
150
|
return (
|
|
151
151
|
<Checkbox
|
|
152
152
|
checked={checked}
|
|
153
|
-
onChange={
|
|
153
|
+
onChange={isChecked => setChecked(isChecked)}
|
|
154
154
|
label="Click to toggle"
|
|
155
155
|
/>
|
|
156
156
|
);
|
|
@@ -175,7 +175,7 @@ export const Multiple: Story = {
|
|
|
175
175
|
|
|
176
176
|
const handleChange = (id: number, isChecked: boolean) => {
|
|
177
177
|
setItems(
|
|
178
|
-
items.map(
|
|
178
|
+
items.map(item =>
|
|
179
179
|
item.id === id ? { ...item, checked: isChecked } : item
|
|
180
180
|
)
|
|
181
181
|
);
|
|
@@ -183,11 +183,11 @@ export const Multiple: Story = {
|
|
|
183
183
|
|
|
184
184
|
return (
|
|
185
185
|
<div className="space-y-3">
|
|
186
|
-
{items.map(
|
|
186
|
+
{items.map(item => (
|
|
187
187
|
<Checkbox
|
|
188
188
|
key={item.id}
|
|
189
189
|
checked={item.checked}
|
|
190
|
-
onChange={
|
|
190
|
+
onChange={isChecked => handleChange(item.id, isChecked)}
|
|
191
191
|
label={item.label}
|
|
192
192
|
/>
|
|
193
193
|
))}
|
|
@@ -245,4 +245,3 @@ export const AllVariants: Story = {
|
|
|
245
245
|
},
|
|
246
246
|
},
|
|
247
247
|
};
|
|
248
|
-
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
|
-
import { cx } from "@shared/utils";
|
|
3
2
|
import { CheckboxProps } from "./types";
|
|
3
|
+
|
|
4
4
|
import { Button } from "@shared/components/button";
|
|
5
|
+
import { cx } from "@shared/utils";
|
|
5
6
|
|
|
6
7
|
export const Checkbox: React.FC<CheckboxProps> = ({
|
|
7
8
|
state,
|
|
@@ -27,8 +28,7 @@ export const Checkbox: React.FC<CheckboxProps> = ({
|
|
|
27
28
|
|
|
28
29
|
const checkboxClasses = cx(
|
|
29
30
|
"flex items-center justify-center w-6 h-6 rounded-[4px] outline-offset-2",
|
|
30
|
-
isFocused &&
|
|
31
|
-
"outline",
|
|
31
|
+
isFocused && "outline",
|
|
32
32
|
className
|
|
33
33
|
);
|
|
34
34
|
|
|
@@ -63,7 +63,11 @@ export const Checkbox: React.FC<CheckboxProps> = ({
|
|
|
63
63
|
width="24"
|
|
64
64
|
height="24"
|
|
65
65
|
rx="4"
|
|
66
|
-
className={cx(
|
|
66
|
+
className={cx(
|
|
67
|
+
isDisabled
|
|
68
|
+
? "fill-checkbox-bg-surface-selected-disabled"
|
|
69
|
+
: "fill-bg-fill-brand"
|
|
70
|
+
)}
|
|
67
71
|
/>
|
|
68
72
|
<path
|
|
69
73
|
d="M8 11.9593L11.0316 15L17 9"
|
|
@@ -89,7 +93,9 @@ export const Checkbox: React.FC<CheckboxProps> = ({
|
|
|
89
93
|
width="23"
|
|
90
94
|
height="23"
|
|
91
95
|
rx="3.5"
|
|
92
|
-
className={cx(
|
|
96
|
+
className={cx(
|
|
97
|
+
isDisabled ? "fill-checkbox-bg-surface-disabled" : "fill-white"
|
|
98
|
+
)}
|
|
93
99
|
/>
|
|
94
100
|
<rect
|
|
95
101
|
x="0.5"
|
|
@@ -115,7 +121,7 @@ export const Checkbox: React.FC<CheckboxProps> = ({
|
|
|
115
121
|
onChange={handleInputChange}
|
|
116
122
|
disabled={isDisabled}
|
|
117
123
|
required={required}
|
|
118
|
-
className="sr-only
|
|
124
|
+
className="peer sr-only"
|
|
119
125
|
data-cy={dataCy}
|
|
120
126
|
{...rest}
|
|
121
127
|
/>
|
|
@@ -130,7 +136,11 @@ export const Checkbox: React.FC<CheckboxProps> = ({
|
|
|
130
136
|
{label && (
|
|
131
137
|
<label
|
|
132
138
|
htmlFor={inputId}
|
|
133
|
-
className={cx(
|
|
139
|
+
className={cx(
|
|
140
|
+
"cursor-pointer",
|
|
141
|
+
error && "text-text-critical",
|
|
142
|
+
labelClassName
|
|
143
|
+
)}
|
|
134
144
|
>
|
|
135
145
|
{label}
|
|
136
146
|
</label>
|
|
@@ -6,19 +6,22 @@ type InfoIconProps = {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export type CheckboxProps = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
onChange?: ((isChecked: boolean) => void) | (() => void);
|
|
11
|
+
state?: "default" | "focus" | "disabled";
|
|
12
|
+
className?: string;
|
|
13
|
+
containerClassName?: string;
|
|
14
|
+
label?: string | ReactNode;
|
|
15
|
+
labelClassName?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
value?: string | number | boolean;
|
|
18
|
+
id?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
error?: boolean;
|
|
22
|
+
"data-cy"?: string;
|
|
23
|
+
renderInfoIcon?: InfoIconProps;
|
|
24
|
+
} & Omit<
|
|
25
|
+
InputHTMLAttributes<HTMLInputElement>,
|
|
26
|
+
"type" | "checked" | "onChange"
|
|
27
|
+
>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Checklist } from "./index";
|
|
2
|
-
import { DocsPage } from "@shared/stories/DocsTemplate";
|
|
3
2
|
|
|
3
|
+
import { DocsPage } from "@shared/stories/DocsTemplate";
|
|
4
4
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
5
5
|
|
|
6
6
|
const meta: Meta<typeof Checklist> = {
|
|
@@ -148,4 +148,3 @@ export const AllVariants: Story = {
|
|
|
148
148
|
},
|
|
149
149
|
},
|
|
150
150
|
};
|
|
151
|
-
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
+
import { ChecklistProps } from "@shared/components/checklist/types";
|
|
3
4
|
import { List, ListItem } from "@shared/components/list";
|
|
4
5
|
import { MaterialIcon } from "@shared/components/material-icon";
|
|
5
6
|
import { Text } from "@shared/components/text";
|
|
6
|
-
import { ChecklistProps } from "@shared/components/checklist/types";
|
|
7
7
|
import { cx } from "@shared/utils";
|
|
8
8
|
|
|
9
|
-
export const Checklist:React.FC<ChecklistProps> =
|
|
10
|
-
const { items, listIconName=
|
|
9
|
+
export const Checklist: React.FC<ChecklistProps> = props => {
|
|
10
|
+
const { items, listIconName = "check", listItemClassName } = props;
|
|
11
11
|
|
|
12
12
|
if (!items?.length) return null;
|
|
13
13
|
|
|
14
14
|
return (
|
|
15
15
|
<List className="mt-2 space-y-1">
|
|
16
16
|
{items.map((text, idx) => (
|
|
17
|
-
<ListItem
|
|
18
|
-
|
|
17
|
+
<ListItem
|
|
18
|
+
key={idx}
|
|
19
|
+
className={cx(
|
|
20
|
+
"flex items-center gap-2 text-text-secondary",
|
|
21
|
+
listItemClassName
|
|
22
|
+
)}
|
|
23
|
+
>
|
|
24
|
+
<MaterialIcon
|
|
19
25
|
name={listIconName}
|
|
20
26
|
size={20}
|
|
21
27
|
weight="600"
|
|
@@ -26,7 +32,7 @@ export const Checklist:React.FC<ChecklistProps> = (props) => {
|
|
|
26
32
|
))}
|
|
27
33
|
</List>
|
|
28
34
|
);
|
|
29
|
-
}
|
|
35
|
+
};
|
|
30
36
|
|
|
31
37
|
Checklist.displayName = "Checklist";
|
|
32
38
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type ChecklistProps = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
2
|
+
items: string[];
|
|
3
|
+
// TODO: add icon names as needed
|
|
4
|
+
listIconName?: "check";
|
|
5
|
+
listItemClassName?: string;
|
|
6
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
1
2
|
import { Collapse } from "./index";
|
|
2
|
-
import { DocsPage } from "@shared/stories/DocsTemplate";
|
|
3
3
|
|
|
4
|
+
import { DocsPage } from "@shared/stories/DocsTemplate";
|
|
4
5
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
5
|
-
import { useState } from "react";
|
|
6
6
|
|
|
7
7
|
const meta: Meta<typeof Collapse> = {
|
|
8
8
|
title: "Components/Collapse",
|
|
@@ -42,7 +42,7 @@ export const Open: Story = {
|
|
|
42
42
|
args: {
|
|
43
43
|
open: true,
|
|
44
44
|
children: (
|
|
45
|
-
<div className="
|
|
45
|
+
<div className="bg-surface-secondary rounded p-4">
|
|
46
46
|
<p className="body2 text-text">
|
|
47
47
|
This content is visible because the collapse is open.
|
|
48
48
|
</p>
|
|
@@ -56,7 +56,7 @@ export const Closed: Story = {
|
|
|
56
56
|
args: {
|
|
57
57
|
open: false,
|
|
58
58
|
children: (
|
|
59
|
-
<div className="
|
|
59
|
+
<div className="bg-surface-secondary rounded p-4">
|
|
60
60
|
<p className="body2 text-text">
|
|
61
61
|
This content is hidden because the collapse is closed.
|
|
62
62
|
</p>
|
|
@@ -70,13 +70,13 @@ export const WithContent: Story = {
|
|
|
70
70
|
args: {
|
|
71
71
|
open: true,
|
|
72
72
|
children: (
|
|
73
|
-
<div className="space-y-2 p-4
|
|
73
|
+
<div className="bg-surface-secondary space-y-2 rounded p-4">
|
|
74
74
|
<h4 className="subheading2 text-text">Collapsible Section</h4>
|
|
75
75
|
<p className="body2 text-text">
|
|
76
76
|
This collapse contains multiple elements and demonstrates how it
|
|
77
77
|
handles different content types.
|
|
78
78
|
</p>
|
|
79
|
-
<ul className="list-disc
|
|
79
|
+
<ul className="list-disc space-y-1 pl-5">
|
|
80
80
|
<li className="body3 text-text-secondary">Item 1</li>
|
|
81
81
|
<li className="body3 text-text-secondary">Item 2</li>
|
|
82
82
|
<li className="body3 text-text-secondary">Item 3</li>
|
|
@@ -94,12 +94,12 @@ export const Interactive: Story = {
|
|
|
94
94
|
<div className="space-y-4">
|
|
95
95
|
<button
|
|
96
96
|
onClick={() => setOpen(!open)}
|
|
97
|
-
className="
|
|
97
|
+
className="bg-fill-brand text-inverse rounded px-4 py-2"
|
|
98
98
|
>
|
|
99
99
|
{open ? "Close" : "Open"} Collapse
|
|
100
100
|
</button>
|
|
101
101
|
<Collapse open={open}>
|
|
102
|
-
<div className="
|
|
102
|
+
<div className="bg-surface-secondary rounded p-4">
|
|
103
103
|
<p className="body2 text-text">
|
|
104
104
|
This content can be toggled by clicking the button above. The
|
|
105
105
|
collapse animates smoothly between open and closed states.
|
|
@@ -124,7 +124,7 @@ export const LongContent: Story = {
|
|
|
124
124
|
args: {
|
|
125
125
|
open: true,
|
|
126
126
|
children: (
|
|
127
|
-
<div className="space-y-4 p-4
|
|
127
|
+
<div className="bg-surface-secondary space-y-4 rounded p-4">
|
|
128
128
|
<h4 className="subheading2 text-text">Long Content Section</h4>
|
|
129
129
|
<p className="body2 text-text">
|
|
130
130
|
This collapse demonstrates how it handles longer content. The height
|
|
@@ -155,19 +155,19 @@ export const TransitionStates: Story = {
|
|
|
155
155
|
<div className="flex gap-2">
|
|
156
156
|
<button
|
|
157
157
|
onClick={() => setOpen(true)}
|
|
158
|
-
className="
|
|
158
|
+
className="bg-fill-brand text-inverse rounded px-4 py-2"
|
|
159
159
|
>
|
|
160
160
|
Open
|
|
161
161
|
</button>
|
|
162
162
|
<button
|
|
163
163
|
onClick={() => setOpen(false)}
|
|
164
|
-
className="px-4 py-2
|
|
164
|
+
className="bg-surface-secondary rounded px-4 py-2 text-text"
|
|
165
165
|
>
|
|
166
166
|
Close
|
|
167
167
|
</button>
|
|
168
168
|
</div>
|
|
169
169
|
<Collapse open={open}>
|
|
170
|
-
<div className="
|
|
170
|
+
<div className="bg-surface-secondary border-border-default rounded border p-4">
|
|
171
171
|
<p className="body2 text-text">
|
|
172
172
|
Watch the smooth transition as this content opens and closes. The
|
|
173
173
|
collapse uses both height and opacity animations for a polished
|
|
@@ -198,7 +198,7 @@ export const AllVariants: Story = {
|
|
|
198
198
|
<div>
|
|
199
199
|
<h3 className="mb-3 text-lg font-semibold">Open State</h3>
|
|
200
200
|
<Collapse open={true}>
|
|
201
|
-
<div className="
|
|
201
|
+
<div className="bg-surface-secondary rounded p-4">
|
|
202
202
|
<p className="body2 text-text">This collapse is open.</p>
|
|
203
203
|
</div>
|
|
204
204
|
</Collapse>
|
|
@@ -206,7 +206,7 @@ export const AllVariants: Story = {
|
|
|
206
206
|
<div>
|
|
207
207
|
<h3 className="mb-3 text-lg font-semibold">Closed State</h3>
|
|
208
208
|
<Collapse open={false}>
|
|
209
|
-
<div className="
|
|
209
|
+
<div className="bg-surface-secondary rounded p-4">
|
|
210
210
|
<p className="body2 text-text">This collapse is closed.</p>
|
|
211
211
|
</div>
|
|
212
212
|
</Collapse>
|
|
@@ -217,12 +217,12 @@ export const AllVariants: Story = {
|
|
|
217
217
|
<div>
|
|
218
218
|
<button
|
|
219
219
|
onClick={() => setOpen1(!open1)}
|
|
220
|
-
className="mb-2 px-4 py-2
|
|
220
|
+
className="bg-fill-brand text-inverse mb-2 rounded px-4 py-2 text-sm"
|
|
221
221
|
>
|
|
222
222
|
Toggle Collapse 1
|
|
223
223
|
</button>
|
|
224
224
|
<Collapse open={open1}>
|
|
225
|
-
<div className="
|
|
225
|
+
<div className="bg-surface-secondary rounded p-4">
|
|
226
226
|
<p className="body2 text-text">Interactive collapse 1</p>
|
|
227
227
|
</div>
|
|
228
228
|
</Collapse>
|
|
@@ -230,12 +230,12 @@ export const AllVariants: Story = {
|
|
|
230
230
|
<div>
|
|
231
231
|
<button
|
|
232
232
|
onClick={() => setOpen2(!open2)}
|
|
233
|
-
className="mb-2 px-4 py-2
|
|
233
|
+
className="bg-fill-brand text-inverse mb-2 rounded px-4 py-2 text-sm"
|
|
234
234
|
>
|
|
235
235
|
Toggle Collapse 2
|
|
236
236
|
</button>
|
|
237
237
|
<Collapse open={open2}>
|
|
238
|
-
<div className="
|
|
238
|
+
<div className="bg-surface-secondary rounded p-4">
|
|
239
239
|
<p className="body2 text-text">Interactive collapse 2</p>
|
|
240
240
|
</div>
|
|
241
241
|
</Collapse>
|
|
@@ -253,4 +253,3 @@ export const AllVariants: Story = {
|
|
|
253
253
|
},
|
|
254
254
|
},
|
|
255
255
|
};
|
|
256
|
-
|