@windstream/react-shared-components 0.0.10 → 0.0.11
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/README.md +623 -623
- package/dist/contentful/index.d.ts +6 -2
- 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 +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +159 -159
- package/src/components/accordion/Accordion.stories.tsx +225 -225
- package/src/components/accordion/index.tsx +36 -36
- package/src/components/accordion/types.ts +9 -9
- package/src/components/alert-card/types.ts +9 -9
- package/src/components/brand-button/BrandButton.stories.tsx +221 -221
- package/src/components/brand-button/helpers.ts +35 -35
- package/src/components/brand-button/index.tsx +90 -90
- package/src/components/brand-button/types.ts +26 -26
- package/src/components/button/Button.stories.tsx +108 -108
- package/src/components/button/index.tsx +23 -23
- package/src/components/button/types.ts +14 -14
- package/src/components/call-button/CallButton.stories.tsx +324 -324
- package/src/components/call-button/index.tsx +80 -80
- package/src/components/call-button/types.ts +9 -9
- package/src/components/checkbox/Checkbox.stories.tsx +248 -248
- package/src/components/checkbox/types.ts +23 -23
- package/src/components/checklist/Checklist.stories.tsx +151 -151
- package/src/components/checklist/index.tsx +33 -33
- package/src/components/checklist/types.ts +5 -5
- package/src/components/collapse/Collapse.stories.tsx +256 -256
- package/src/components/collapse/index.tsx +44 -44
- package/src/components/collapse/types.ts +5 -5
- package/src/components/divider/Divider.stories.tsx +206 -206
- package/src/components/divider/index.tsx +23 -23
- package/src/components/divider/type.ts +2 -2
- package/src/components/input/Input.stories.tsx +358 -358
- package/src/components/input/index.tsx +174 -174
- package/src/components/input/types.ts +36 -36
- package/src/components/link/Link.stories.tsx +163 -163
- package/src/components/link/index.tsx +96 -96
- package/src/components/link/types.ts +25 -25
- package/src/components/list/List.stories.tsx +272 -272
- 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 +330 -330
- package/src/components/material-icon/constants.ts +95 -95
- 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 +171 -171
- package/src/components/modal/index.tsx +168 -168
- package/src/components/modal/types.ts +23 -23
- package/src/components/radio-button/index.tsx +73 -73
- package/src/components/radio-button/types.ts +21 -21
- package/src/components/see-more/SeeMore.stories.tsx +182 -182
- package/src/components/see-more/index.tsx +38 -38
- package/src/components/see-more/types.ts +3 -3
- package/src/components/select/Select.stories.tsx +410 -410
- package/src/components/select/index.tsx +150 -150
- package/src/components/select/types.ts +34 -34
- package/src/components/select-plan-button/SelectPlanButton.stories.tsx +160 -160
- package/src/components/select-plan-button/index.tsx +20 -20
- package/src/components/select-plan-button/types.ts +3 -3
- package/src/components/skeleton/Skeleton.stories.tsx +180 -180
- package/src/components/skeleton/index.tsx +61 -61
- package/src/components/skeleton/types.ts +3 -3
- package/src/components/spinner/Spinner.stories.tsx +335 -335
- package/src/components/spinner/index.tsx +44 -44
- package/src/components/spinner/types.ts +4 -4
- package/src/components/text/Text.stories.tsx +302 -302
- package/src/components/text/index.tsx +26 -26
- package/src/components/text/types.ts +45 -45
- package/src/components/tooltip/Tooltip.stories.tsx +220 -220
- package/src/components/tooltip/index.tsx +78 -78
- package/src/components/tooltip/types.ts +6 -6
- package/src/components/view-cart-button/ViewCartButton.stories.tsx +241 -241
- package/src/components/view-cart-button/index.tsx +38 -38
- package/src/components/view-cart-button/types.ts +4 -4
- package/src/contentful/blocks/accordion/index.tsx +7 -7
- package/src/contentful/blocks/button/index.tsx +5 -5
- package/src/contentful/blocks/callout/index.tsx +7 -7
- package/src/contentful/blocks/cards/index.tsx +7 -7
- package/src/contentful/blocks/carousel/index.tsx +7 -7
- package/src/contentful/blocks/cta-callout/index.tsx +6 -0
- package/src/contentful/blocks/cta-callout/types.ts +1 -0
- package/src/contentful/blocks/floating-banner/index.tsx +7 -7
- package/src/contentful/blocks/footer/index.tsx +7 -7
- package/src/contentful/blocks/image-promo-bar/index.tsx +7 -7
- package/src/contentful/blocks/modal/index.tsx +5 -5
- package/src/contentful/blocks/navigation/index.tsx +7 -7
- package/src/contentful/blocks/primary-hero/index.tsx +7 -7
- package/src/contentful/blocks/shape-background-wrapper/index.tsx +123 -123
- package/src/contentful/blocks/shape-background-wrapper/types.ts +35 -35
- package/src/contentful/blocks/text/index.tsx +6 -6
- package/src/contentful/index.ts +4 -1
- package/src/hooks/use-body-scroll-lock.ts +31 -31
- package/src/index.ts +81 -81
- package/src/setupTests.ts +46 -46
- package/src/styles/globals.css +275 -319
- package/src/types/global.d.ts +9 -9
- package/src/utils/index.ts +49 -49
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { ToolTipProps } from "./types";
|
|
2
|
-
|
|
3
|
-
export function Tooltip({
|
|
4
|
-
tooltipMsg,
|
|
5
|
-
className,
|
|
6
|
-
children,
|
|
7
|
-
}: ToolTipProps) {
|
|
8
|
-
return (
|
|
9
|
-
<>
|
|
10
|
-
<style>{`
|
|
11
|
-
.tooltip-custom {
|
|
12
|
-
position: relative;
|
|
13
|
-
cursor: pointer;
|
|
14
|
-
margin-top: 7px;
|
|
15
|
-
}
|
|
16
|
-
.tooltip-custom::after {
|
|
17
|
-
display: none;
|
|
18
|
-
position: absolute;
|
|
19
|
-
text-align: center;
|
|
20
|
-
z-index: 999;
|
|
21
|
-
content: attr(data-text);
|
|
22
|
-
top: 0;
|
|
23
|
-
left: -200%;
|
|
24
|
-
transform: translate(-50%, calc(-100% - 10px));
|
|
25
|
-
line-height: 1.1rem;
|
|
26
|
-
padding-left: 1rem;
|
|
27
|
-
padding-right: 1rem;
|
|
28
|
-
border-radius: 8px;
|
|
29
|
-
color: white;
|
|
30
|
-
background-color: black;
|
|
31
|
-
padding-bottom: 0.75rem;
|
|
32
|
-
padding-top: 0.75rem;
|
|
33
|
-
width: 270px;
|
|
34
|
-
font-size: 14px;
|
|
35
|
-
}
|
|
36
|
-
.tooltip-custom:hover::after {
|
|
37
|
-
display: block;
|
|
38
|
-
}
|
|
39
|
-
.tooltip-custom::before {
|
|
40
|
-
background-color: black;
|
|
41
|
-
content: " ";
|
|
42
|
-
display: none;
|
|
43
|
-
position: absolute;
|
|
44
|
-
width: 15px;
|
|
45
|
-
height: 15px;
|
|
46
|
-
z-index: 999;
|
|
47
|
-
top: 0;
|
|
48
|
-
left: 50%;
|
|
49
|
-
transform: translate(-50%, calc(-100% - 5px)) rotate(45deg);
|
|
50
|
-
}
|
|
51
|
-
.tooltip-custom:hover::before {
|
|
52
|
-
display: block;
|
|
53
|
-
}
|
|
54
|
-
@media (max-width: 640px) {
|
|
55
|
-
.tooltip-custom::after {
|
|
56
|
-
left: -124px;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
@media (max-width: 343px) {
|
|
60
|
-
.tooltip-custom::after {
|
|
61
|
-
left: 80px;
|
|
62
|
-
width: 160px;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
`}</style>
|
|
66
|
-
<span
|
|
67
|
-
className={`tooltip-custom ${className || ""}`}
|
|
68
|
-
data-text={tooltipMsg}
|
|
69
|
-
>
|
|
70
|
-
{children}
|
|
71
|
-
</span>
|
|
72
|
-
</>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
Tooltip.displayName = "Tooltip";
|
|
77
|
-
|
|
78
|
-
export type { ToolTipProps };
|
|
1
|
+
import { ToolTipProps } from "./types";
|
|
2
|
+
|
|
3
|
+
export function Tooltip({
|
|
4
|
+
tooltipMsg,
|
|
5
|
+
className,
|
|
6
|
+
children,
|
|
7
|
+
}: ToolTipProps) {
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<style>{`
|
|
11
|
+
.tooltip-custom {
|
|
12
|
+
position: relative;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
margin-top: 7px;
|
|
15
|
+
}
|
|
16
|
+
.tooltip-custom::after {
|
|
17
|
+
display: none;
|
|
18
|
+
position: absolute;
|
|
19
|
+
text-align: center;
|
|
20
|
+
z-index: 999;
|
|
21
|
+
content: attr(data-text);
|
|
22
|
+
top: 0;
|
|
23
|
+
left: -200%;
|
|
24
|
+
transform: translate(-50%, calc(-100% - 10px));
|
|
25
|
+
line-height: 1.1rem;
|
|
26
|
+
padding-left: 1rem;
|
|
27
|
+
padding-right: 1rem;
|
|
28
|
+
border-radius: 8px;
|
|
29
|
+
color: white;
|
|
30
|
+
background-color: black;
|
|
31
|
+
padding-bottom: 0.75rem;
|
|
32
|
+
padding-top: 0.75rem;
|
|
33
|
+
width: 270px;
|
|
34
|
+
font-size: 14px;
|
|
35
|
+
}
|
|
36
|
+
.tooltip-custom:hover::after {
|
|
37
|
+
display: block;
|
|
38
|
+
}
|
|
39
|
+
.tooltip-custom::before {
|
|
40
|
+
background-color: black;
|
|
41
|
+
content: " ";
|
|
42
|
+
display: none;
|
|
43
|
+
position: absolute;
|
|
44
|
+
width: 15px;
|
|
45
|
+
height: 15px;
|
|
46
|
+
z-index: 999;
|
|
47
|
+
top: 0;
|
|
48
|
+
left: 50%;
|
|
49
|
+
transform: translate(-50%, calc(-100% - 5px)) rotate(45deg);
|
|
50
|
+
}
|
|
51
|
+
.tooltip-custom:hover::before {
|
|
52
|
+
display: block;
|
|
53
|
+
}
|
|
54
|
+
@media (max-width: 640px) {
|
|
55
|
+
.tooltip-custom::after {
|
|
56
|
+
left: -124px;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
@media (max-width: 343px) {
|
|
60
|
+
.tooltip-custom::after {
|
|
61
|
+
left: 80px;
|
|
62
|
+
width: 160px;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
`}</style>
|
|
66
|
+
<span
|
|
67
|
+
className={`tooltip-custom ${className || ""}`}
|
|
68
|
+
data-text={tooltipMsg}
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</span>
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Tooltip.displayName = "Tooltip";
|
|
77
|
+
|
|
78
|
+
export type { ToolTipProps };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
export type ToolTipProps = {
|
|
4
|
-
tooltipMsg: string;
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
className?: string;
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export type ToolTipProps = {
|
|
4
|
+
tooltipMsg: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
7
|
};
|
|
@@ -1,241 +1,241 @@
|
|
|
1
|
-
import { ViewCartButton } from "./index";
|
|
2
|
-
import { DocsPage } from "@shared/stories/DocsTemplate";
|
|
3
|
-
|
|
4
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
5
|
-
import { useState } from "react";
|
|
6
|
-
|
|
7
|
-
const meta: Meta<typeof ViewCartButton> = {
|
|
8
|
-
title: "Components/ViewCartButton",
|
|
9
|
-
component: ViewCartButton,
|
|
10
|
-
tags: ["autodocs"],
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: "centered",
|
|
13
|
-
docs: {
|
|
14
|
-
page: DocsPage,
|
|
15
|
-
description: {
|
|
16
|
-
component:
|
|
17
|
-
"A button component for viewing cart contents with total price display and open/closed states.",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
argTypes: {
|
|
22
|
-
cartTotalText: {
|
|
23
|
-
control: { type: "text" },
|
|
24
|
-
description: "Text displaying the cart total",
|
|
25
|
-
},
|
|
26
|
-
isOpen: {
|
|
27
|
-
control: { type: "boolean" },
|
|
28
|
-
description: "Whether the cart is open",
|
|
29
|
-
},
|
|
30
|
-
onClick: {
|
|
31
|
-
action: "clicked",
|
|
32
|
-
description: "Callback function when button is clicked",
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
args: {
|
|
36
|
-
cartTotalText: "$99.99",
|
|
37
|
-
isOpen: false,
|
|
38
|
-
onClick: () => {},
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default meta;
|
|
43
|
-
type Story = StoryObj<typeof meta>;
|
|
44
|
-
|
|
45
|
-
// Default button
|
|
46
|
-
export const Default: Story = {
|
|
47
|
-
args: {},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// With cart total
|
|
51
|
-
export const WithCartTotal: Story = {
|
|
52
|
-
args: {
|
|
53
|
-
cartTotalText: "$149.99",
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// Open state
|
|
58
|
-
export const Open: Story = {
|
|
59
|
-
args: {
|
|
60
|
-
cartTotalText: "$99.99",
|
|
61
|
-
isOpen: true,
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// Closed state
|
|
66
|
-
export const Closed: Story = {
|
|
67
|
-
args: {
|
|
68
|
-
cartTotalText: "$99.99",
|
|
69
|
-
isOpen: false,
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// Interactive state
|
|
74
|
-
export const Interactive: Story = {
|
|
75
|
-
render: () => {
|
|
76
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
77
|
-
return (
|
|
78
|
-
<div className="w-full max-w-md">
|
|
79
|
-
<ViewCartButton
|
|
80
|
-
cartTotalText="$149.99"
|
|
81
|
-
isOpen={isOpen}
|
|
82
|
-
onClick={() => setIsOpen(!isOpen)}
|
|
83
|
-
/>
|
|
84
|
-
{isOpen && (
|
|
85
|
-
<div className="mt-4 p-4 bg-surface-secondary rounded">
|
|
86
|
-
<p className="body2 text-text">Cart is open</p>
|
|
87
|
-
</div>
|
|
88
|
-
)}
|
|
89
|
-
</div>
|
|
90
|
-
);
|
|
91
|
-
},
|
|
92
|
-
parameters: {
|
|
93
|
-
docs: {
|
|
94
|
-
description: {
|
|
95
|
-
story:
|
|
96
|
-
"Interactive ViewCartButton that toggles open/closed state on click.",
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// Different totals
|
|
103
|
-
export const DifferentTotals: Story = {
|
|
104
|
-
render: () => (
|
|
105
|
-
<div className="w-full max-w-md space-y-3">
|
|
106
|
-
<ViewCartButton cartTotalText="$0.00" isOpen={false} onClick={() => {}} />
|
|
107
|
-
<ViewCartButton cartTotalText="$29.99" isOpen={false} onClick={() => {}} />
|
|
108
|
-
<ViewCartButton cartTotalText="$99.99" isOpen={false} onClick={() => {}} />
|
|
109
|
-
<ViewCartButton cartTotalText="$249.99" isOpen={false} onClick={() => {}} />
|
|
110
|
-
</div>
|
|
111
|
-
),
|
|
112
|
-
parameters: {
|
|
113
|
-
docs: {
|
|
114
|
-
description: {
|
|
115
|
-
story: "ViewCartButton with different cart total values.",
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// Responsive behavior
|
|
122
|
-
export const Responsive: Story = {
|
|
123
|
-
render: () => (
|
|
124
|
-
<div className="space-y-8">
|
|
125
|
-
<div>
|
|
126
|
-
<h3 className="mb-2 text-sm font-medium text-gray-600">
|
|
127
|
-
Mobile View (btn-small)
|
|
128
|
-
</h3>
|
|
129
|
-
<div className="w-64 border border-gray-200 p-2">
|
|
130
|
-
<ViewCartButton
|
|
131
|
-
cartTotalText="$99.99"
|
|
132
|
-
isOpen={false}
|
|
133
|
-
onClick={() => {}}
|
|
134
|
-
/>
|
|
135
|
-
</div>
|
|
136
|
-
</div>
|
|
137
|
-
<div>
|
|
138
|
-
<h3 className="mb-2 text-sm font-medium text-gray-600">
|
|
139
|
-
Desktop View (btn-medium)
|
|
140
|
-
</h3>
|
|
141
|
-
<div className="w-full max-w-md border border-gray-200 p-2">
|
|
142
|
-
<ViewCartButton
|
|
143
|
-
cartTotalText="$99.99"
|
|
144
|
-
isOpen={false}
|
|
145
|
-
onClick={() => {}}
|
|
146
|
-
/>
|
|
147
|
-
</div>
|
|
148
|
-
</div>
|
|
149
|
-
</div>
|
|
150
|
-
),
|
|
151
|
-
parameters: {
|
|
152
|
-
docs: {
|
|
153
|
-
description: {
|
|
154
|
-
story:
|
|
155
|
-
"ViewCartButton adapts its size responsively - smaller on mobile, larger on desktop.",
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
// Open and closed states
|
|
162
|
-
export const OpenAndClosed: Story = {
|
|
163
|
-
render: () => (
|
|
164
|
-
<div className="w-full max-w-md space-y-4">
|
|
165
|
-
<div>
|
|
166
|
-
<h4 className="mb-2 text-sm font-medium">Closed State</h4>
|
|
167
|
-
<ViewCartButton
|
|
168
|
-
cartTotalText="$99.99"
|
|
169
|
-
isOpen={false}
|
|
170
|
-
onClick={() => {}}
|
|
171
|
-
/>
|
|
172
|
-
</div>
|
|
173
|
-
<div>
|
|
174
|
-
<h4 className="mb-2 text-sm font-medium">Open State</h4>
|
|
175
|
-
<ViewCartButton
|
|
176
|
-
cartTotalText="$99.99"
|
|
177
|
-
isOpen={true}
|
|
178
|
-
onClick={() => {}}
|
|
179
|
-
/>
|
|
180
|
-
</div>
|
|
181
|
-
</div>
|
|
182
|
-
),
|
|
183
|
-
parameters: {
|
|
184
|
-
docs: {
|
|
185
|
-
description: {
|
|
186
|
-
story: "ViewCartButton in both open and closed states.",
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
// All variants showcase
|
|
193
|
-
export const AllVariants: Story = {
|
|
194
|
-
render: () => (
|
|
195
|
-
<div className="w-full max-w-2xl space-y-6">
|
|
196
|
-
<div>
|
|
197
|
-
<h3 className="mb-3 text-lg font-semibold">States</h3>
|
|
198
|
-
<div className="space-y-3">
|
|
199
|
-
<ViewCartButton
|
|
200
|
-
cartTotalText="$99.99"
|
|
201
|
-
isOpen={false}
|
|
202
|
-
onClick={() => {}}
|
|
203
|
-
/>
|
|
204
|
-
<ViewCartButton
|
|
205
|
-
cartTotalText="$99.99"
|
|
206
|
-
isOpen={true}
|
|
207
|
-
onClick={() => {}}
|
|
208
|
-
/>
|
|
209
|
-
</div>
|
|
210
|
-
</div>
|
|
211
|
-
<div>
|
|
212
|
-
<h3 className="mb-3 text-lg font-semibold">Different Totals</h3>
|
|
213
|
-
<div className="space-y-3">
|
|
214
|
-
<ViewCartButton
|
|
215
|
-
cartTotalText="$0.00"
|
|
216
|
-
isOpen={false}
|
|
217
|
-
onClick={() => {}}
|
|
218
|
-
/>
|
|
219
|
-
<ViewCartButton
|
|
220
|
-
cartTotalText="$29.99"
|
|
221
|
-
isOpen={false}
|
|
222
|
-
onClick={() => {}}
|
|
223
|
-
/>
|
|
224
|
-
<ViewCartButton
|
|
225
|
-
cartTotalText="$149.99"
|
|
226
|
-
isOpen={false}
|
|
227
|
-
onClick={() => {}}
|
|
228
|
-
/>
|
|
229
|
-
</div>
|
|
230
|
-
</div>
|
|
231
|
-
</div>
|
|
232
|
-
),
|
|
233
|
-
parameters: {
|
|
234
|
-
docs: {
|
|
235
|
-
description: {
|
|
236
|
-
story: "Showcase of all ViewCartButton variants and states.",
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
};
|
|
241
|
-
|
|
1
|
+
import { ViewCartButton } from "./index";
|
|
2
|
+
import { DocsPage } from "@shared/stories/DocsTemplate";
|
|
3
|
+
|
|
4
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof ViewCartButton> = {
|
|
8
|
+
title: "Components/ViewCartButton",
|
|
9
|
+
component: ViewCartButton,
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: "centered",
|
|
13
|
+
docs: {
|
|
14
|
+
page: DocsPage,
|
|
15
|
+
description: {
|
|
16
|
+
component:
|
|
17
|
+
"A button component for viewing cart contents with total price display and open/closed states.",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
argTypes: {
|
|
22
|
+
cartTotalText: {
|
|
23
|
+
control: { type: "text" },
|
|
24
|
+
description: "Text displaying the cart total",
|
|
25
|
+
},
|
|
26
|
+
isOpen: {
|
|
27
|
+
control: { type: "boolean" },
|
|
28
|
+
description: "Whether the cart is open",
|
|
29
|
+
},
|
|
30
|
+
onClick: {
|
|
31
|
+
action: "clicked",
|
|
32
|
+
description: "Callback function when button is clicked",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
args: {
|
|
36
|
+
cartTotalText: "$99.99",
|
|
37
|
+
isOpen: false,
|
|
38
|
+
onClick: () => {},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default meta;
|
|
43
|
+
type Story = StoryObj<typeof meta>;
|
|
44
|
+
|
|
45
|
+
// Default button
|
|
46
|
+
export const Default: Story = {
|
|
47
|
+
args: {},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// With cart total
|
|
51
|
+
export const WithCartTotal: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
cartTotalText: "$149.99",
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Open state
|
|
58
|
+
export const Open: Story = {
|
|
59
|
+
args: {
|
|
60
|
+
cartTotalText: "$99.99",
|
|
61
|
+
isOpen: true,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Closed state
|
|
66
|
+
export const Closed: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
cartTotalText: "$99.99",
|
|
69
|
+
isOpen: false,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Interactive state
|
|
74
|
+
export const Interactive: Story = {
|
|
75
|
+
render: () => {
|
|
76
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
77
|
+
return (
|
|
78
|
+
<div className="w-full max-w-md">
|
|
79
|
+
<ViewCartButton
|
|
80
|
+
cartTotalText="$149.99"
|
|
81
|
+
isOpen={isOpen}
|
|
82
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
83
|
+
/>
|
|
84
|
+
{isOpen && (
|
|
85
|
+
<div className="mt-4 p-4 bg-surface-secondary rounded">
|
|
86
|
+
<p className="body2 text-text">Cart is open</p>
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
parameters: {
|
|
93
|
+
docs: {
|
|
94
|
+
description: {
|
|
95
|
+
story:
|
|
96
|
+
"Interactive ViewCartButton that toggles open/closed state on click.",
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Different totals
|
|
103
|
+
export const DifferentTotals: Story = {
|
|
104
|
+
render: () => (
|
|
105
|
+
<div className="w-full max-w-md space-y-3">
|
|
106
|
+
<ViewCartButton cartTotalText="$0.00" isOpen={false} onClick={() => {}} />
|
|
107
|
+
<ViewCartButton cartTotalText="$29.99" isOpen={false} onClick={() => {}} />
|
|
108
|
+
<ViewCartButton cartTotalText="$99.99" isOpen={false} onClick={() => {}} />
|
|
109
|
+
<ViewCartButton cartTotalText="$249.99" isOpen={false} onClick={() => {}} />
|
|
110
|
+
</div>
|
|
111
|
+
),
|
|
112
|
+
parameters: {
|
|
113
|
+
docs: {
|
|
114
|
+
description: {
|
|
115
|
+
story: "ViewCartButton with different cart total values.",
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Responsive behavior
|
|
122
|
+
export const Responsive: Story = {
|
|
123
|
+
render: () => (
|
|
124
|
+
<div className="space-y-8">
|
|
125
|
+
<div>
|
|
126
|
+
<h3 className="mb-2 text-sm font-medium text-gray-600">
|
|
127
|
+
Mobile View (btn-small)
|
|
128
|
+
</h3>
|
|
129
|
+
<div className="w-64 border border-gray-200 p-2">
|
|
130
|
+
<ViewCartButton
|
|
131
|
+
cartTotalText="$99.99"
|
|
132
|
+
isOpen={false}
|
|
133
|
+
onClick={() => {}}
|
|
134
|
+
/>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
<div>
|
|
138
|
+
<h3 className="mb-2 text-sm font-medium text-gray-600">
|
|
139
|
+
Desktop View (btn-medium)
|
|
140
|
+
</h3>
|
|
141
|
+
<div className="w-full max-w-md border border-gray-200 p-2">
|
|
142
|
+
<ViewCartButton
|
|
143
|
+
cartTotalText="$99.99"
|
|
144
|
+
isOpen={false}
|
|
145
|
+
onClick={() => {}}
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
),
|
|
151
|
+
parameters: {
|
|
152
|
+
docs: {
|
|
153
|
+
description: {
|
|
154
|
+
story:
|
|
155
|
+
"ViewCartButton adapts its size responsively - smaller on mobile, larger on desktop.",
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// Open and closed states
|
|
162
|
+
export const OpenAndClosed: Story = {
|
|
163
|
+
render: () => (
|
|
164
|
+
<div className="w-full max-w-md space-y-4">
|
|
165
|
+
<div>
|
|
166
|
+
<h4 className="mb-2 text-sm font-medium">Closed State</h4>
|
|
167
|
+
<ViewCartButton
|
|
168
|
+
cartTotalText="$99.99"
|
|
169
|
+
isOpen={false}
|
|
170
|
+
onClick={() => {}}
|
|
171
|
+
/>
|
|
172
|
+
</div>
|
|
173
|
+
<div>
|
|
174
|
+
<h4 className="mb-2 text-sm font-medium">Open State</h4>
|
|
175
|
+
<ViewCartButton
|
|
176
|
+
cartTotalText="$99.99"
|
|
177
|
+
isOpen={true}
|
|
178
|
+
onClick={() => {}}
|
|
179
|
+
/>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
),
|
|
183
|
+
parameters: {
|
|
184
|
+
docs: {
|
|
185
|
+
description: {
|
|
186
|
+
story: "ViewCartButton in both open and closed states.",
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// All variants showcase
|
|
193
|
+
export const AllVariants: Story = {
|
|
194
|
+
render: () => (
|
|
195
|
+
<div className="w-full max-w-2xl space-y-6">
|
|
196
|
+
<div>
|
|
197
|
+
<h3 className="mb-3 text-lg font-semibold">States</h3>
|
|
198
|
+
<div className="space-y-3">
|
|
199
|
+
<ViewCartButton
|
|
200
|
+
cartTotalText="$99.99"
|
|
201
|
+
isOpen={false}
|
|
202
|
+
onClick={() => {}}
|
|
203
|
+
/>
|
|
204
|
+
<ViewCartButton
|
|
205
|
+
cartTotalText="$99.99"
|
|
206
|
+
isOpen={true}
|
|
207
|
+
onClick={() => {}}
|
|
208
|
+
/>
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
<div>
|
|
212
|
+
<h3 className="mb-3 text-lg font-semibold">Different Totals</h3>
|
|
213
|
+
<div className="space-y-3">
|
|
214
|
+
<ViewCartButton
|
|
215
|
+
cartTotalText="$0.00"
|
|
216
|
+
isOpen={false}
|
|
217
|
+
onClick={() => {}}
|
|
218
|
+
/>
|
|
219
|
+
<ViewCartButton
|
|
220
|
+
cartTotalText="$29.99"
|
|
221
|
+
isOpen={false}
|
|
222
|
+
onClick={() => {}}
|
|
223
|
+
/>
|
|
224
|
+
<ViewCartButton
|
|
225
|
+
cartTotalText="$149.99"
|
|
226
|
+
isOpen={false}
|
|
227
|
+
onClick={() => {}}
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
),
|
|
233
|
+
parameters: {
|
|
234
|
+
docs: {
|
|
235
|
+
description: {
|
|
236
|
+
story: "Showcase of all ViewCartButton variants and states.",
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
|