@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,6 +1,6 @@
|
|
|
1
1
|
import { Divider } 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 Divider> = {
|
|
@@ -37,7 +37,7 @@ export const Default: Story = {
|
|
|
37
37
|
// Horizontal divider
|
|
38
38
|
export const Horizontal: Story = {
|
|
39
39
|
render: () => (
|
|
40
|
-
<div className="
|
|
40
|
+
<div className="max-w-md w-full space-y-4">
|
|
41
41
|
<p className="body2 text-text">Content above the divider</p>
|
|
42
42
|
<Divider />
|
|
43
43
|
<p className="body2 text-text">Content below the divider</p>
|
|
@@ -57,8 +57,8 @@ export const CustomStyling: Story = {
|
|
|
57
57
|
args: {
|
|
58
58
|
className: "h-0.5 bg-border-brand",
|
|
59
59
|
},
|
|
60
|
-
render:
|
|
61
|
-
<div className="
|
|
60
|
+
render: args => (
|
|
61
|
+
<div className="max-w-md w-full space-y-4">
|
|
62
62
|
<p className="body2 text-text">Content above</p>
|
|
63
63
|
<Divider {...args} />
|
|
64
64
|
<p className="body2 text-text">Content below</p>
|
|
@@ -69,19 +69,19 @@ export const CustomStyling: Story = {
|
|
|
69
69
|
// Multiple dividers
|
|
70
70
|
export const Multiple: Story = {
|
|
71
71
|
render: () => (
|
|
72
|
-
<div className="
|
|
72
|
+
<div className="max-w-md w-full space-y-4">
|
|
73
73
|
<div>
|
|
74
|
-
<h3 className="subheading1 text-text
|
|
74
|
+
<h3 className="subheading1 mb-2 text-text">Section 1</h3>
|
|
75
75
|
<p className="body2 text-text">Content for section 1</p>
|
|
76
76
|
</div>
|
|
77
77
|
<Divider />
|
|
78
78
|
<div>
|
|
79
|
-
<h3 className="subheading1 text-text
|
|
79
|
+
<h3 className="subheading1 mb-2 text-text">Section 2</h3>
|
|
80
80
|
<p className="body2 text-text">Content for section 2</p>
|
|
81
81
|
</div>
|
|
82
82
|
<Divider />
|
|
83
83
|
<div>
|
|
84
|
-
<h3 className="subheading1 text-text
|
|
84
|
+
<h3 className="subheading1 mb-2 text-text">Section 3</h3>
|
|
85
85
|
<p className="body2 text-text">Content for section 3</p>
|
|
86
86
|
</div>
|
|
87
87
|
</div>
|
|
@@ -98,7 +98,7 @@ export const Multiple: Story = {
|
|
|
98
98
|
// In list
|
|
99
99
|
export const InList: Story = {
|
|
100
100
|
render: () => (
|
|
101
|
-
<div className="w-
|
|
101
|
+
<div className="max-w-md border-border-default w-full space-y-0 rounded border">
|
|
102
102
|
<div className="p-4">
|
|
103
103
|
<p className="body2 text-text">List item 1</p>
|
|
104
104
|
</div>
|
|
@@ -126,8 +126,8 @@ export const Thick: Story = {
|
|
|
126
126
|
args: {
|
|
127
127
|
className: "h-1 bg-border-default",
|
|
128
128
|
},
|
|
129
|
-
render:
|
|
130
|
-
<div className="
|
|
129
|
+
render: args => (
|
|
130
|
+
<div className="max-w-md w-full space-y-4">
|
|
131
131
|
<p className="body2 text-text">Content above</p>
|
|
132
132
|
<Divider {...args} />
|
|
133
133
|
<p className="body2 text-text">Content below</p>
|
|
@@ -140,8 +140,8 @@ export const Colored: Story = {
|
|
|
140
140
|
args: {
|
|
141
141
|
className: "h-0.5 bg-border-brand",
|
|
142
142
|
},
|
|
143
|
-
render:
|
|
144
|
-
<div className="
|
|
143
|
+
render: args => (
|
|
144
|
+
<div className="max-w-md w-full space-y-4">
|
|
145
145
|
<p className="body2 text-text">Content above</p>
|
|
146
146
|
<Divider {...args} />
|
|
147
147
|
<p className="body2 text-text">Content below</p>
|
|
@@ -152,7 +152,7 @@ export const Colored: Story = {
|
|
|
152
152
|
// All variants showcase
|
|
153
153
|
export const AllVariants: Story = {
|
|
154
154
|
render: () => (
|
|
155
|
-
<div className="
|
|
155
|
+
<div className="max-w-2xl w-full space-y-8">
|
|
156
156
|
<div>
|
|
157
157
|
<h3 className="mb-3 text-lg font-semibold">Default Divider</h3>
|
|
158
158
|
<div className="space-y-4">
|
|
@@ -173,13 +173,13 @@ export const AllVariants: Story = {
|
|
|
173
173
|
<h3 className="mb-3 text-lg font-semibold">Thick Divider</h3>
|
|
174
174
|
<div className="space-y-4">
|
|
175
175
|
<p className="body2 text-text">Content above</p>
|
|
176
|
-
<Divider className="
|
|
176
|
+
<Divider className="bg-border-default h-1" />
|
|
177
177
|
<p className="body2 text-text">Content below</p>
|
|
178
178
|
</div>
|
|
179
179
|
</div>
|
|
180
180
|
<div>
|
|
181
181
|
<h3 className="mb-3 text-lg font-semibold">In List</h3>
|
|
182
|
-
<div className="border
|
|
182
|
+
<div className="border-border-default rounded border">
|
|
183
183
|
<div className="p-4">
|
|
184
184
|
<p className="body2 text-text">Item 1</p>
|
|
185
185
|
</div>
|
|
@@ -203,4 +203,3 @@ export const AllVariants: Story = {
|
|
|
203
203
|
},
|
|
204
204
|
},
|
|
205
205
|
};
|
|
206
|
-
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { DividerProps } from "./type";
|
|
2
3
|
|
|
3
4
|
import { cx } from "@shared/utils";
|
|
4
5
|
|
|
5
|
-
import { DividerProps } from "./type";
|
|
6
|
-
|
|
7
6
|
export const Divider: React.FC<DividerProps> = (props: DividerProps) => {
|
|
8
7
|
const { className, ...rest } = props;
|
|
9
8
|
|
|
10
9
|
return (
|
|
11
10
|
<div
|
|
12
11
|
className={cx(
|
|
13
|
-
"
|
|
12
|
+
"h-[1px] border-t-0 bg-bg-surface-tertiary-active opacity-100",
|
|
14
13
|
className
|
|
15
14
|
)}
|
|
16
15
|
{...rest}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type DividerProps = {
|
|
2
|
-
|
|
3
|
-
} & React.HTMLAttributes<HTMLDivElement>;
|
|
2
|
+
className?: string;
|
|
3
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { Image } from "./index";
|
|
3
|
+
import type { ImageComponentProps } from "./types";
|
|
4
|
+
|
|
5
|
+
import { DocsPage } from "@shared/stories/DocsTemplate";
|
|
6
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof Image> = {
|
|
9
|
+
title: "Components/Image",
|
|
10
|
+
component: Image,
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
parameters: {
|
|
13
|
+
layout: "centered",
|
|
14
|
+
docs: {
|
|
15
|
+
page: DocsPage,
|
|
16
|
+
description: {
|
|
17
|
+
component:
|
|
18
|
+
"A reusable image component that renders a native img by default. Pass the `as` prop with a custom component (e.g. next/image) to use Next.js Image or another image component.",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
argTypes: {
|
|
23
|
+
src: {
|
|
24
|
+
control: { type: "text" },
|
|
25
|
+
description: "Image source URL",
|
|
26
|
+
},
|
|
27
|
+
alt: {
|
|
28
|
+
control: { type: "text" },
|
|
29
|
+
description:
|
|
30
|
+
"Alt text (required for accessibility; use empty string for decorative images)",
|
|
31
|
+
},
|
|
32
|
+
width: {
|
|
33
|
+
control: { type: "number" },
|
|
34
|
+
description: "Image width",
|
|
35
|
+
},
|
|
36
|
+
height: {
|
|
37
|
+
control: { type: "number" },
|
|
38
|
+
description: "Image height",
|
|
39
|
+
},
|
|
40
|
+
className: {
|
|
41
|
+
control: { type: "text" },
|
|
42
|
+
description: "Custom CSS classes",
|
|
43
|
+
},
|
|
44
|
+
loading: {
|
|
45
|
+
control: { type: "select" },
|
|
46
|
+
options: ["lazy", "eager"],
|
|
47
|
+
description: "Loading behavior",
|
|
48
|
+
},
|
|
49
|
+
as: {
|
|
50
|
+
description:
|
|
51
|
+
"Custom component to render (e.g. next/image). In a Next.js app: import Image from 'next/image' then use <Image as={Image} src={...} alt={...} width={...} height={...} />",
|
|
52
|
+
control: false,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
args: {
|
|
56
|
+
src: "https://placehold.co/400x300",
|
|
57
|
+
alt: "Placeholder image",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default meta;
|
|
62
|
+
type Story = StoryObj<typeof meta>;
|
|
63
|
+
|
|
64
|
+
export const Default: Story = {
|
|
65
|
+
args: {},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const WithDimensions: Story = {
|
|
69
|
+
args: {
|
|
70
|
+
src: "https://placehold.co/300x200",
|
|
71
|
+
alt: "Image with explicit dimensions",
|
|
72
|
+
width: 300,
|
|
73
|
+
height: 200,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const WithClassName: Story = {
|
|
78
|
+
args: {
|
|
79
|
+
src: "https://placehold.co/400x300",
|
|
80
|
+
alt: "Styled image",
|
|
81
|
+
className: "rounded-lg object-cover shadow-md",
|
|
82
|
+
width: 400,
|
|
83
|
+
height: 300,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** Mock component to demonstrate the `as` prop. In a Next.js app, pass next/image: <Image as={NextImage} ... /> */
|
|
88
|
+
const MockImageComponent = forwardRef<HTMLImageElement, ImageComponentProps>(
|
|
89
|
+
(props, ref) => <img ref={ref} {...props} />
|
|
90
|
+
);
|
|
91
|
+
MockImageComponent.displayName = "MockImageComponent";
|
|
92
|
+
|
|
93
|
+
export const WithCustomComponent: Story = {
|
|
94
|
+
render: args => (
|
|
95
|
+
<Image
|
|
96
|
+
{...args}
|
|
97
|
+
as={MockImageComponent}
|
|
98
|
+
src="https://placehold.co/350x150"
|
|
99
|
+
alt="Rendered via custom component (as prop)"
|
|
100
|
+
width={350}
|
|
101
|
+
height={150}
|
|
102
|
+
className="rounded border-2 border-dashed border-gray-300"
|
|
103
|
+
/>
|
|
104
|
+
),
|
|
105
|
+
parameters: {
|
|
106
|
+
docs: {
|
|
107
|
+
description: {
|
|
108
|
+
story:
|
|
109
|
+
"Use the `as` prop to render with a custom component. In Next.js, pass the Image component from next/image for optimized images.",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import type { ImageProps } from "@shared/components/image/types";
|
|
4
|
+
import { cx } from "@shared/utils";
|
|
5
|
+
|
|
6
|
+
export const Image = forwardRef<HTMLImageElement, ImageProps>(
|
|
7
|
+
({ as: ImageComponent, className = "", ...rest }, ref) => {
|
|
8
|
+
const combinedClassName = cx(className);
|
|
9
|
+
|
|
10
|
+
if (ImageComponent) {
|
|
11
|
+
return (
|
|
12
|
+
<ImageComponent ref={ref} className={combinedClassName} {...rest} />
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return <img ref={ref} className={combinedClassName} {...rest} />;
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
Image.displayName = "Image";
|
|
21
|
+
|
|
22
|
+
export type { ImageProps, ImageComponentProps } from "./types";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ComponentType, ImgHTMLAttributes } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Props passed to the custom image component when using the `as` prop.
|
|
5
|
+
* Covers native img attributes plus optional Next.js Image props (fill, sizes, priority, etc.).
|
|
6
|
+
*/
|
|
7
|
+
export interface ImageComponentProps
|
|
8
|
+
extends Omit<ImgHTMLAttributes<HTMLImageElement>, "alt"> {
|
|
9
|
+
/** Image source URL */
|
|
10
|
+
src: string;
|
|
11
|
+
/** Alt text (required for accessibility; use "" for decorative images) */
|
|
12
|
+
alt: string;
|
|
13
|
+
/** Optional; used by Next.js Image when using fill layout */
|
|
14
|
+
fill?: boolean;
|
|
15
|
+
/** Optional; used by Next.js Image for responsive sizes */
|
|
16
|
+
sizes?: string;
|
|
17
|
+
/** Optional; used by Next.js Image for priority loading */
|
|
18
|
+
priority?: boolean;
|
|
19
|
+
/** Optional; used by Next.js Image for blur placeholder */
|
|
20
|
+
placeholder?: "blur" | "empty";
|
|
21
|
+
/** Optional; used by Next.js Image for quality (1–100) */
|
|
22
|
+
quality?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ImageProps extends ImageComponentProps {
|
|
26
|
+
/** Custom component to render instead of native img (e.g. next/image) */
|
|
27
|
+
as?: ComponentType<ImageComponentProps>;
|
|
28
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Input } 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 Input> = {
|
|
@@ -116,27 +116,15 @@ export const Error: Story = {
|
|
|
116
116
|
// Different sizes
|
|
117
117
|
export const Sizes: Story = {
|
|
118
118
|
render: () => (
|
|
119
|
-
<div className="
|
|
119
|
+
<div className="max-w-md w-full space-y-4">
|
|
120
120
|
<div>
|
|
121
|
-
<Input
|
|
122
|
-
size="slim"
|
|
123
|
-
placeholder="Slim input"
|
|
124
|
-
label="Slim Size"
|
|
125
|
-
/>
|
|
121
|
+
<Input size="slim" placeholder="Slim input" label="Slim Size" />
|
|
126
122
|
</div>
|
|
127
123
|
<div>
|
|
128
|
-
<Input
|
|
129
|
-
size="medium"
|
|
130
|
-
placeholder="Medium input"
|
|
131
|
-
label="Medium Size"
|
|
132
|
-
/>
|
|
124
|
+
<Input size="medium" placeholder="Medium input" label="Medium Size" />
|
|
133
125
|
</div>
|
|
134
126
|
<div>
|
|
135
|
-
<Input
|
|
136
|
-
size="large"
|
|
137
|
-
placeholder="Large input"
|
|
138
|
-
label="Large Size"
|
|
139
|
-
/>
|
|
127
|
+
<Input size="large" placeholder="Large input" label="Large Size" />
|
|
140
128
|
</div>
|
|
141
129
|
</div>
|
|
142
130
|
),
|
|
@@ -201,7 +189,7 @@ export const Disabled: Story = {
|
|
|
201
189
|
// Different states
|
|
202
190
|
export const States: Story = {
|
|
203
191
|
render: () => (
|
|
204
|
-
<div className="
|
|
192
|
+
<div className="max-w-md w-full space-y-4">
|
|
205
193
|
<div>
|
|
206
194
|
<Input
|
|
207
195
|
label="Default State"
|
|
@@ -210,18 +198,10 @@ export const States: Story = {
|
|
|
210
198
|
/>
|
|
211
199
|
</div>
|
|
212
200
|
<div>
|
|
213
|
-
<Input
|
|
214
|
-
label="Hover State"
|
|
215
|
-
placeholder="Hover over me"
|
|
216
|
-
state="hover"
|
|
217
|
-
/>
|
|
201
|
+
<Input label="Hover State" placeholder="Hover over me" state="hover" />
|
|
218
202
|
</div>
|
|
219
203
|
<div>
|
|
220
|
-
<Input
|
|
221
|
-
label="Focus State"
|
|
222
|
-
placeholder="Focus on me"
|
|
223
|
-
state="focus"
|
|
224
|
-
/>
|
|
204
|
+
<Input label="Focus State" placeholder="Focus on me" state="focus" />
|
|
225
205
|
</div>
|
|
226
206
|
<div>
|
|
227
207
|
<Input
|
|
@@ -263,17 +243,9 @@ export const Phone: Story = {
|
|
|
263
243
|
// Form example
|
|
264
244
|
export const FormExample: Story = {
|
|
265
245
|
render: () => (
|
|
266
|
-
<form className="
|
|
267
|
-
<Input
|
|
268
|
-
|
|
269
|
-
placeholder="Enter your first name"
|
|
270
|
-
required
|
|
271
|
-
/>
|
|
272
|
-
<Input
|
|
273
|
-
label="Last Name"
|
|
274
|
-
placeholder="Enter your last name"
|
|
275
|
-
required
|
|
276
|
-
/>
|
|
246
|
+
<form className="max-w-md w-full space-y-4">
|
|
247
|
+
<Input label="First Name" placeholder="Enter your first name" required />
|
|
248
|
+
<Input label="Last Name" placeholder="Enter your last name" required />
|
|
277
249
|
<Input
|
|
278
250
|
label="Email"
|
|
279
251
|
placeholder="Enter your email"
|
|
@@ -287,11 +259,7 @@ export const FormExample: Story = {
|
|
|
287
259
|
suffixIconName="visibility"
|
|
288
260
|
required
|
|
289
261
|
/>
|
|
290
|
-
<Input
|
|
291
|
-
label="Phone Number"
|
|
292
|
-
placeholder="(555) 123-4567"
|
|
293
|
-
type="tel"
|
|
294
|
-
/>
|
|
262
|
+
<Input label="Phone Number" placeholder="(555) 123-4567" type="tel" />
|
|
295
263
|
</form>
|
|
296
264
|
),
|
|
297
265
|
parameters: {
|
|
@@ -306,7 +274,7 @@ export const FormExample: Story = {
|
|
|
306
274
|
// All variants showcase
|
|
307
275
|
export const AllVariants: Story = {
|
|
308
276
|
render: () => (
|
|
309
|
-
<div className="
|
|
277
|
+
<div className="max-w-2xl w-full space-y-6">
|
|
310
278
|
<div>
|
|
311
279
|
<h3 className="mb-3 text-lg font-semibold">Sizes</h3>
|
|
312
280
|
<div className="space-y-3">
|
|
@@ -355,4 +323,3 @@ export const AllVariants: Story = {
|
|
|
355
323
|
},
|
|
356
324
|
},
|
|
357
325
|
};
|
|
358
|
-
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
FocusEventHandler,
|
|
3
5
|
forwardRef,
|
|
@@ -6,10 +8,11 @@ import {
|
|
|
6
8
|
useCallback,
|
|
7
9
|
useState,
|
|
8
10
|
} from "react";
|
|
9
|
-
import {
|
|
11
|
+
import { InputFieldProps, InputProps } from "./types";
|
|
12
|
+
|
|
10
13
|
import { MaterialIcon } from "@shared/components/material-icon";
|
|
11
14
|
import { Text } from "@shared/components/text";
|
|
12
|
-
import {
|
|
15
|
+
import { cx } from "@shared/utils";
|
|
13
16
|
|
|
14
17
|
export const InputField: ForwardRefRenderFunction<
|
|
15
18
|
HTMLInputElement,
|
|
@@ -64,13 +67,11 @@ export const InputField: ForwardRefRenderFunction<
|
|
|
64
67
|
};
|
|
65
68
|
|
|
66
69
|
const togglePasswordVisibility = useCallback<
|
|
67
|
-
|
|
68
|
-
>(e => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
);
|
|
73
|
-
}, []);
|
|
70
|
+
MouseEventHandler<HTMLDivElement>
|
|
71
|
+
>(e => {
|
|
72
|
+
e.stopPropagation();
|
|
73
|
+
setInputType(prevType => (prevType === "password" ? "text" : "password"));
|
|
74
|
+
}, []);
|
|
74
75
|
|
|
75
76
|
return (
|
|
76
77
|
<div className="relative">
|
|
@@ -87,15 +88,19 @@ export const InputField: ForwardRefRenderFunction<
|
|
|
87
88
|
|
|
88
89
|
<div
|
|
89
90
|
className={cx(
|
|
90
|
-
"relative flex w-80 flex-row items-center rounded-xl border border-input-border bg-input-bg-surface
|
|
91
|
+
"relative flex w-80 flex-row items-center overflow-hidden rounded-xl border border-input-border bg-input-bg-surface",
|
|
91
92
|
sizeClasses[size || "medium"],
|
|
92
93
|
containerClassName,
|
|
93
|
-
(isHovered || effectiveState === "hover") &&
|
|
94
|
+
(isHovered || effectiveState === "hover") &&
|
|
95
|
+
!isFocused &&
|
|
96
|
+
effectiveState !== "error" &&
|
|
97
|
+
"border-input-border-hover",
|
|
94
98
|
(isFocused ||
|
|
95
99
|
effectiveState === "focus" ||
|
|
96
100
|
effectiveState === "active") &&
|
|
97
101
|
"border-input-border-selected outline outline-1 outline-input-border-selected",
|
|
98
|
-
effectiveState === "error" &&
|
|
102
|
+
effectiveState === "error" &&
|
|
103
|
+
"border-input-border-critical outline outline-1 outline-input-border-critical"
|
|
99
104
|
)}
|
|
100
105
|
>
|
|
101
106
|
{prefixIconName ? (
|
|
@@ -165,9 +170,7 @@ export const InputField: ForwardRefRenderFunction<
|
|
|
165
170
|
);
|
|
166
171
|
};
|
|
167
172
|
|
|
168
|
-
export const Input = forwardRef<HTMLInputElement, InputFieldProps>(
|
|
169
|
-
InputField
|
|
170
|
-
);
|
|
173
|
+
export const Input = forwardRef<HTMLInputElement, InputFieldProps>(InputField);
|
|
171
174
|
|
|
172
175
|
Input.displayName = "Input";
|
|
173
176
|
|
|
@@ -26,8 +26,7 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
26
26
|
"transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2";
|
|
27
27
|
|
|
28
28
|
const variantClasses = {
|
|
29
|
-
default:
|
|
30
|
-
"text-text underline",
|
|
29
|
+
default: "text-text underline",
|
|
31
30
|
};
|
|
32
31
|
|
|
33
32
|
const stateClasses = [
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AnchorHTMLAttributes,
|
|
3
|
-
type CSSProperties,
|
|
4
|
-
type MouseEvent,
|
|
5
|
-
type ReactNode,
|
|
6
|
-
} from "react";
|
|
7
|
-
|
|
8
|
-
export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
9
|
-
/** Content to render inside the link */
|
|
10
|
-
children: ReactNode;
|
|
11
|
-
/** URL to navigate to */
|
|
12
|
-
href?: string;
|
|
13
|
-
/** Custom className for the link */
|
|
14
|
-
className?: string;
|
|
15
|
-
/** Click handler function */
|
|
16
|
-
onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
|
|
17
|
-
/** Additional styling options */
|
|
18
|
-
variant?: "default" | "unstyled";
|
|
19
|
-
/** Custom styles */
|
|
20
|
-
style?: CSSProperties;
|
|
21
|
-
/** External link behavior - opens in new tab */
|
|
22
|
-
external?: boolean;
|
|
23
|
-
/** Disable the link */
|
|
24
|
-
disabled?: boolean;
|
|
25
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
type AnchorHTMLAttributes,
|
|
3
|
+
type CSSProperties,
|
|
4
|
+
type MouseEvent,
|
|
5
|
+
type ReactNode,
|
|
6
|
+
} from "react";
|
|
7
|
+
|
|
8
|
+
export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
9
|
+
/** Content to render inside the link */
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/** URL to navigate to */
|
|
12
|
+
href?: string;
|
|
13
|
+
/** Custom className for the link */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** Click handler function */
|
|
16
|
+
onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
|
|
17
|
+
/** Additional styling options */
|
|
18
|
+
variant?: "default" | "unstyled";
|
|
19
|
+
/** Custom styles */
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
/** External link behavior - opens in new tab */
|
|
22
|
+
external?: boolean;
|
|
23
|
+
/** Disable the link */
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
}
|