@faststore/core 0.3.15 → 0.3.17
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/CHANGELOG.md +29 -0
- package/cypress/integration/analytics.test.js +3 -3
- package/cypress/integration/plp.test.js +1 -1
- package/package.json +4 -4
- package/src/Layout.tsx +6 -1
- package/src/components/cart/CartItem/CartItem.tsx +2 -2
- package/src/components/cart/CartSidebar/CartSidebar.tsx +5 -6
- package/src/components/cart/CartSidebar/cart-sidebar.module.scss +2 -0
- package/src/components/common/Alert/Alert.tsx +6 -22
- package/src/components/common/Footer/Footer.stories.mdx +1 -1
- package/src/components/common/Footer/FooterLinks.tsx +16 -12
- package/src/components/search/Filter/Facets.stories.mdx +9 -9
- package/src/components/search/Filter/Facets.tsx +69 -61
- package/src/components/search/Filter/facets.module.scss +16 -16
- package/src/components/search/Search.stories.mdx +28 -24
- package/src/components/search/SearchDropdown/SearchDropdown.stories.mdx +0 -1
- package/src/components/search/SearchInput/SearchInput.stories.mdx +0 -1
- package/src/components/search/SearchTop/SearchTop.stories.mdx +0 -1
- package/src/components/sections/ProducDetailsContent/ProductDetailsContent.tsx +147 -149
- package/src/components/sections/ProductDetails/ProductDetails.tsx +2 -2
- package/src/components/ui/Breadcrumb/Breadcrumb.tsx +17 -16
- package/src/components/ui/Gift/Gift.tsx +7 -13
- package/src/components/ui/ShippingSimulation/ShippingSimulation.stories.mdx +0 -27
- package/src/components/ui/ShippingSimulation/ShippingSimulation.tsx +6 -13
- package/src/components/ui/ShippingSimulation/shipping-simulation.module.scss +0 -39
- package/src/components/ui/SkuSelector/sku-selector.module.scss +1 -1
- package/tsconfig.json +1 -1
- package/src/components/sections/ProducDetailsContent/product-details-content.module.scss +0 -41
- package/src/components/ui/Accordion/Accordion.stories.mdx +0 -222
- package/src/components/ui/Accordion/Accordion.tsx +0 -39
- package/src/components/ui/Accordion/AccordionItem.stories.mdx +0 -116
- package/src/components/ui/Accordion/AccordionItem.tsx +0 -82
- package/src/components/ui/Accordion/accordion.module.scss +0 -65
- package/src/components/ui/Accordion/index.ts +0 -2
- package/src/components/ui/Alert/Alert.stories.mdx +0 -164
- package/src/components/ui/Alert/Alert.tsx +0 -81
- package/src/components/ui/Alert/alert.module.scss +0 -93
- package/src/components/ui/Alert/index.ts +0 -1
- package/src/components/ui/Dropdown/Dropdown.stories.mdx +0 -232
- package/src/components/ui/Dropdown/Dropdown.tsx +0 -12
- package/src/components/ui/Dropdown/DropdownButton.tsx +0 -20
- package/src/components/ui/Dropdown/DropdownItem.stories.mdx +0 -139
- package/src/components/ui/Dropdown/DropdownItem.tsx +0 -26
- package/src/components/ui/Dropdown/DropdownMenu.stories.mdx +0 -115
- package/src/components/ui/Dropdown/DropdownMenu.tsx +0 -34
- package/src/components/ui/Dropdown/dropdown.module.scss +0 -101
- package/src/components/ui/Dropdown/index.ts +0 -4
- package/src/components/ui/Gift/Gift.stories.mdx +0 -99
- package/src/components/ui/Gift/gift.module.scss +0 -94
- package/src/components/ui/PriceRange/PriceRange.stories.mdx +0 -192
- package/src/components/ui/PriceRange/PriceRange.tsx +0 -140
- package/src/components/ui/PriceRange/index.ts +0 -1
- package/src/components/ui/PriceRange/price-range.module.scss +0 -176
- package/src/components/ui/QuantitySelector/QuantitySelector.stories.mdx +0 -246
- package/src/components/ui/QuantitySelector/QuantitySelector.tsx +0 -103
- package/src/components/ui/QuantitySelector/index.ts +0 -1
- package/src/components/ui/QuantitySelector/quantity-selector.module.scss +0 -155
|
@@ -73,7 +73,7 @@ function ShippingSimulation({
|
|
|
73
73
|
displayClearButton={displayClearButton}
|
|
74
74
|
/>
|
|
75
75
|
|
|
76
|
-
<Link href="/" data-fs-shipping-simulation-link>
|
|
76
|
+
<Link href="/" data-fs-shipping-simulation-link size="small">
|
|
77
77
|
{"I don't know my Postal Code"}
|
|
78
78
|
<Icon name="ArrowSquareOut" width={18} height={18} />
|
|
79
79
|
</Link>
|
|
@@ -87,20 +87,13 @@ function ShippingSimulation({
|
|
|
87
87
|
</p>
|
|
88
88
|
</header>
|
|
89
89
|
|
|
90
|
-
<Table
|
|
90
|
+
<Table>
|
|
91
91
|
<TableBody>
|
|
92
92
|
{shippingOptions.map((option) => (
|
|
93
|
-
<TableRow
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
<TableCell data-fs-shipping-simulation-table-cell>
|
|
98
|
-
{option.carrier}
|
|
99
|
-
</TableCell>
|
|
100
|
-
<TableCell data-fs-shipping-simulation-table-cell>
|
|
101
|
-
{option.localizedEstimates}
|
|
102
|
-
</TableCell>
|
|
103
|
-
<TableCell data-fs-shipping-simulation-table-cell>
|
|
93
|
+
<TableRow key={option.carrier}>
|
|
94
|
+
<TableCell align="left">{option.carrier}</TableCell>
|
|
95
|
+
<TableCell>{option.localizedEstimates}</TableCell>
|
|
96
|
+
<TableCell align="right">
|
|
104
97
|
{option.price && (
|
|
105
98
|
<Price
|
|
106
99
|
formatter={formatter}
|
|
@@ -23,20 +23,10 @@
|
|
|
23
23
|
// Location
|
|
24
24
|
--fs-shipping-simulation-location-padding-bottom : var(--fs-spacing-2);
|
|
25
25
|
|
|
26
|
-
// Table
|
|
27
|
-
--fs-shipping-simulation-table-row-bkg-color : var(--fs-color-main-0);
|
|
28
|
-
--fs-shipping-simulation-table-row-even-bkg-color : transparent;
|
|
29
|
-
|
|
30
|
-
--fs-shipping-simulation-table-cell-padding : var(--fs-spacing-2);
|
|
31
|
-
--fs-shipping-simulation-table-cell-text-size : var(--fs-text-size-2);
|
|
32
|
-
--fs-shipping-simulation-table-cell-border-radius : var(--fs-border-radius);
|
|
33
|
-
|
|
34
26
|
// --------------------------------------------------------
|
|
35
27
|
// Structural Styles
|
|
36
28
|
// --------------------------------------------------------
|
|
37
29
|
|
|
38
|
-
font-size: var(--fs-shipping-simulation-text-size);
|
|
39
|
-
|
|
40
30
|
[data-fs-shipping-simulation-title] {
|
|
41
31
|
padding-bottom: var(--fs-shipping-simulation-title-padding-bottom);
|
|
42
32
|
}
|
|
@@ -64,33 +54,4 @@
|
|
|
64
54
|
[data-fs-shipping-simulation-location] {
|
|
65
55
|
padding-bottom: var(--fs-shipping-simulation-location-padding-bottom);
|
|
66
56
|
}
|
|
67
|
-
|
|
68
|
-
[data-fs-shipping-simulation-table] {
|
|
69
|
-
width: 100%;
|
|
70
|
-
border-collapse: collapse;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
[data-fs-shipping-simulation-table-row] {
|
|
74
|
-
background-color: var(--fs-shipping-simulation-table-row-bkg-color);
|
|
75
|
-
|
|
76
|
-
&:nth-child(even) {
|
|
77
|
-
background-color: var(--fs-shipping-simulation-table-row-even-bkg-color);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
[data-fs-shipping-simulation-table-cell] {
|
|
82
|
-
padding: var(--fs-shipping-simulation-table-cell-padding);
|
|
83
|
-
font-size: var(--fs-shipping-simulation-table-cell-text-size);
|
|
84
|
-
|
|
85
|
-
&:first-child {
|
|
86
|
-
border-top-left-radius: var(--fs-shipping-simulation-table-cell-border-radius);
|
|
87
|
-
border-bottom-left-radius: var(--fs-shipping-simulation-table-cell-border-radius);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
&:last-child {
|
|
91
|
-
text-align: right;
|
|
92
|
-
border-top-right-radius: var(--fs-shipping-simulation-table-cell-border-radius);
|
|
93
|
-
border-bottom-right-radius: var(--fs-shipping-simulation-table-cell-border-radius);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
57
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
.fs-product-details-content {
|
|
2
|
-
// -----------------------------
|
|
3
|
-
// Table
|
|
4
|
-
// -----------------------------
|
|
5
|
-
|
|
6
|
-
[data-fs-product-details-about] [data-fs-table] {
|
|
7
|
-
width: 100%;
|
|
8
|
-
|
|
9
|
-
[data-fs-accordion-item-button-icon] {
|
|
10
|
-
height: 18px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
[data-fs-icon] {
|
|
14
|
-
margin-right: var(--fs-spacing-2);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
tr:nth-child(even) td {
|
|
18
|
-
background-color: var(--fs-color-neutral-1);
|
|
19
|
-
border-top-right-radius: var(--fs-border-radius);
|
|
20
|
-
border-bottom-right-radius: var(--fs-border-radius);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
tr:nth-child(even) th {
|
|
24
|
-
background-color: var(--fs-color-neutral-1);
|
|
25
|
-
border-top-left-radius: var(--fs-border-radius);
|
|
26
|
-
border-bottom-left-radius: var(--fs-border-radius);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
td {
|
|
30
|
-
padding: var(--fs-spacing-2) var(--fs-spacing-3) var(--fs-spacing-2) 0;
|
|
31
|
-
text-align: right;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
th {
|
|
35
|
-
display: flex;
|
|
36
|
-
padding: var(--fs-spacing-2) 0 var(--fs-spacing-2) var(--fs-spacing-3);
|
|
37
|
-
font-weight: normal;
|
|
38
|
-
text-align: left;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'
|
|
2
|
-
import { List as UIList, LinkButton as UILinkButton } from '@faststore/ui'
|
|
3
|
-
import { useState } from 'react'
|
|
4
|
-
|
|
5
|
-
import Accordion, { AccordionItem } from '.'
|
|
6
|
-
import Icon from '../Icon'
|
|
7
|
-
|
|
8
|
-
<Meta
|
|
9
|
-
component={Accordion}
|
|
10
|
-
title="Molecules/Accordion/Overview"
|
|
11
|
-
argTypes={{
|
|
12
|
-
expandedIndices: { control: { disable: true } },
|
|
13
|
-
}}
|
|
14
|
-
/>
|
|
15
|
-
|
|
16
|
-
export const values = Array.from({ length: 3 }).map((_, i) => `Item ${i + 1}`)
|
|
17
|
-
|
|
18
|
-
export const items = [
|
|
19
|
-
{
|
|
20
|
-
title: 'Title 1',
|
|
21
|
-
values: [...values],
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
title: 'Title 2',
|
|
25
|
-
values: [...values],
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
title: 'Title 3',
|
|
29
|
-
values: [...values],
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
title: 'Title 4',
|
|
33
|
-
values: [...values],
|
|
34
|
-
},
|
|
35
|
-
]
|
|
36
|
-
|
|
37
|
-
export const Template = () => {
|
|
38
|
-
const [indices, setIndices] = useState([])
|
|
39
|
-
const onChange = (index) => {
|
|
40
|
-
setIndices([index])
|
|
41
|
-
}
|
|
42
|
-
return (
|
|
43
|
-
<Accordion expandedIndices={indices} onChange={onChange}>
|
|
44
|
-
{items.map((item, index) => (
|
|
45
|
-
<AccordionItem
|
|
46
|
-
key={item.title}
|
|
47
|
-
isExpanded={indices.includes(index)}
|
|
48
|
-
buttonLabel={item.title}
|
|
49
|
-
>
|
|
50
|
-
<UIList>
|
|
51
|
-
{item.values.map((label) => {
|
|
52
|
-
return <li key={label}>{label}</li>
|
|
53
|
-
})}
|
|
54
|
-
</UIList>
|
|
55
|
-
</AccordionItem>
|
|
56
|
-
))}
|
|
57
|
-
</Accordion>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const TemplateMultiple = () => {
|
|
62
|
-
const [indexes, setIndexes] = useState(new Set([]))
|
|
63
|
-
const onChange = (index) => {
|
|
64
|
-
if (indexes.has(index)) {
|
|
65
|
-
indexes.delete(index)
|
|
66
|
-
setIndexes(new Set(indexes))
|
|
67
|
-
} else {
|
|
68
|
-
setIndexes(new Set(indexes.add(index)))
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return (
|
|
72
|
-
<Accordion expandedIndices={indexes} onChange={onChange}>
|
|
73
|
-
{items.map((item, index) => (
|
|
74
|
-
<AccordionItem
|
|
75
|
-
key={item.title}
|
|
76
|
-
isExpanded={indexes.has(index)}
|
|
77
|
-
buttonLabel={item.title}
|
|
78
|
-
>
|
|
79
|
-
<UIList>
|
|
80
|
-
{item.values.map((name) => (
|
|
81
|
-
<li key={name}>{name}</li>
|
|
82
|
-
))}
|
|
83
|
-
</UIList>
|
|
84
|
-
</AccordionItem>
|
|
85
|
-
))}
|
|
86
|
-
</Accordion>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export const TemplateOneItem = () => {
|
|
91
|
-
const [indexes, setIndexes] = useState(new Set([0]))
|
|
92
|
-
const onChange = (index) => {
|
|
93
|
-
if (indexes.has(index)) {
|
|
94
|
-
indexes.delete(index)
|
|
95
|
-
setIndexes(new Set(indexes))
|
|
96
|
-
} else {
|
|
97
|
-
setIndexes(new Set(indexes.add(index)))
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return (
|
|
101
|
-
<Accordion expandedIndices={indexes} onChange={onChange}>
|
|
102
|
-
<AccordionItem isExpanded={indexes.has(0)} buttonLabel="Title 1">
|
|
103
|
-
<UIList>
|
|
104
|
-
{values.map((label) => {
|
|
105
|
-
return <li key={label}>{label}</li>
|
|
106
|
-
})}
|
|
107
|
-
</UIList>
|
|
108
|
-
</AccordionItem>
|
|
109
|
-
</Accordion>
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
<header>
|
|
114
|
-
|
|
115
|
-
# Accordion
|
|
116
|
-
|
|
117
|
-
Accordion displays an expandable/collapsible list of items.
|
|
118
|
-
|
|
119
|
-
</header>
|
|
120
|
-
|
|
121
|
-
## Overview
|
|
122
|
-
|
|
123
|
-
The `Accordion` component uses [FastStore UI Accordion](https://www.faststore.dev/reference/ui/molecules/Accordion) as base.
|
|
124
|
-
|
|
125
|
-
---
|
|
126
|
-
|
|
127
|
-
## Usage
|
|
128
|
-
|
|
129
|
-
`import Accordion, { AccordionItem } from 'src/components/ui/Accordion'`
|
|
130
|
-
|
|
131
|
-
<Canvas>
|
|
132
|
-
<Story name="default">{Template.bind({})}</Story>
|
|
133
|
-
</Canvas>
|
|
134
|
-
|
|
135
|
-
<ArgsTable story="default" />
|
|
136
|
-
|
|
137
|
-
---
|
|
138
|
-
|
|
139
|
-
## Variants
|
|
140
|
-
|
|
141
|
-
### Accordion Single Open
|
|
142
|
-
|
|
143
|
-
<Canvas>
|
|
144
|
-
<Story name="overview-default">{Template.bind({})}</Story>
|
|
145
|
-
</Canvas>
|
|
146
|
-
|
|
147
|
-
### Accordion Multiple Open
|
|
148
|
-
|
|
149
|
-
<Canvas>
|
|
150
|
-
<Story name="overview-multiple-expanded">{TemplateMultiple.bind({})}</Story>
|
|
151
|
-
</Canvas>
|
|
152
|
-
|
|
153
|
-
## Compound Components
|
|
154
|
-
|
|
155
|
-
<section className="sbdocs-list">
|
|
156
|
-
<ul className="sbdocs-ul-row">
|
|
157
|
-
<li>
|
|
158
|
-
<div>
|
|
159
|
-
<div style={{ width: '50%', height: '180px', paddingTop: '20px' }}>
|
|
160
|
-
<TemplateOneItem />
|
|
161
|
-
</div>
|
|
162
|
-
</div>
|
|
163
|
-
<article className="sbdocs-list-text">
|
|
164
|
-
<h3>Accordion Item</h3>
|
|
165
|
-
<p>
|
|
166
|
-
An item of the <code>Accordion</code> component.
|
|
167
|
-
</p>
|
|
168
|
-
<UILinkButton
|
|
169
|
-
size="small"
|
|
170
|
-
variant="tertiary"
|
|
171
|
-
href="../?path=/docs/molecules-accordion-accordionitem--default-story"
|
|
172
|
-
icon={<Icon name="ArrowRight" width="18" height="18" weight="bold" />}
|
|
173
|
-
iconPosition="right"
|
|
174
|
-
>
|
|
175
|
-
See more
|
|
176
|
-
</UILinkButton>
|
|
177
|
-
</article>
|
|
178
|
-
</li>
|
|
179
|
-
</ul>
|
|
180
|
-
</section>
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
## Use Cases
|
|
185
|
-
|
|
186
|
-
<section className="sbdocs-list">
|
|
187
|
-
<ul className="sbdocs-ul-row">
|
|
188
|
-
<li>
|
|
189
|
-
<article className="sbdocs-list-text">
|
|
190
|
-
<h3>ProductDetailsContent</h3>
|
|
191
|
-
<p>
|
|
192
|
-
Used by the <code>ProductDetailsContent</code> component to organize
|
|
193
|
-
product information in different sections.
|
|
194
|
-
</p>
|
|
195
|
-
<UILinkButton
|
|
196
|
-
size="small"
|
|
197
|
-
variant="tertiary"
|
|
198
|
-
href="../?path=/docs/organisms-productdetailscontent--default-story"
|
|
199
|
-
icon={<Icon name="ArrowRight" width="18" height="18" weight="bold" />}
|
|
200
|
-
iconPosition="right"
|
|
201
|
-
>
|
|
202
|
-
See more
|
|
203
|
-
</UILinkButton>
|
|
204
|
-
</article>
|
|
205
|
-
<article className="sbdocs-list-text">
|
|
206
|
-
<h3>Footer</h3>
|
|
207
|
-
<p>
|
|
208
|
-
Used by the <code>Footer</code> component on mobile devices.
|
|
209
|
-
</p>
|
|
210
|
-
<UILinkButton
|
|
211
|
-
size="small"
|
|
212
|
-
variant="tertiary"
|
|
213
|
-
href="../?path=/docs/organisms-footer--default-story"
|
|
214
|
-
icon={<Icon name="ArrowRight" width="18" height="18" weight="bold" />}
|
|
215
|
-
iconPosition="right"
|
|
216
|
-
>
|
|
217
|
-
See more
|
|
218
|
-
</UILinkButton>
|
|
219
|
-
</article>
|
|
220
|
-
</li>
|
|
221
|
-
</ul>
|
|
222
|
-
</section>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { AccordionProps } from '@faststore/ui'
|
|
2
|
-
import { Accordion as UIAccordion } from '@faststore/ui'
|
|
3
|
-
import { forwardRef } from 'react'
|
|
4
|
-
|
|
5
|
-
import styles from './accordion.module.scss'
|
|
6
|
-
|
|
7
|
-
interface Props extends Omit<AccordionProps, 'indices'> {
|
|
8
|
-
/**
|
|
9
|
-
* Indices that indicate which accordion items are opened.
|
|
10
|
-
*/
|
|
11
|
-
expandedIndices: Iterable<number>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const Accordion = forwardRef<HTMLDivElement, Props>(function Accordion(
|
|
15
|
-
{
|
|
16
|
-
expandedIndices,
|
|
17
|
-
onChange,
|
|
18
|
-
children,
|
|
19
|
-
testId = 'store-accordion',
|
|
20
|
-
...otherProps
|
|
21
|
-
},
|
|
22
|
-
ref
|
|
23
|
-
) {
|
|
24
|
-
return (
|
|
25
|
-
<UIAccordion
|
|
26
|
-
className={styles.fsAccordion}
|
|
27
|
-
data-fs-accordion
|
|
28
|
-
ref={ref}
|
|
29
|
-
onChange={onChange}
|
|
30
|
-
data-testid={testId}
|
|
31
|
-
indices={expandedIndices}
|
|
32
|
-
{...otherProps}
|
|
33
|
-
>
|
|
34
|
-
{children}
|
|
35
|
-
</UIAccordion>
|
|
36
|
-
)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
export default Accordion
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'
|
|
2
|
-
import { List as UIList } from '@faststore/ui'
|
|
3
|
-
import { useState } from 'react'
|
|
4
|
-
|
|
5
|
-
import Accordion, { AccordionItem } from '.'
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
AccordionButton as UIAccordionButton,
|
|
9
|
-
AccordionItem as UIAccordionItem,
|
|
10
|
-
AccordionPanel as UIAccordionPanel,
|
|
11
|
-
Icon as UIIcon,
|
|
12
|
-
} from '@faststore/ui'
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
TokenTable,
|
|
16
|
-
TokenRow,
|
|
17
|
-
TokenDivider,
|
|
18
|
-
} from 'src/../.storybook/components'
|
|
19
|
-
|
|
20
|
-
<Meta
|
|
21
|
-
title="Molecules/Accordion/AccordionItem"
|
|
22
|
-
component={AccordionItem}
|
|
23
|
-
argTypes={{
|
|
24
|
-
isExpanded: { control: 'boolean' },
|
|
25
|
-
buttonLabel: { defaultValue: 'Title 1' },
|
|
26
|
-
}}
|
|
27
|
-
/>
|
|
28
|
-
|
|
29
|
-
export const values = Array.from({ length: 5 }).map((_, i) => `Item ${i + 1}`)
|
|
30
|
-
|
|
31
|
-
export const Template = (args) => {
|
|
32
|
-
const [indexes, setIndexes] = useState(new Set([]))
|
|
33
|
-
const onChange = (index) => {
|
|
34
|
-
if (indexes.has(index)) {
|
|
35
|
-
indexes.delete(index)
|
|
36
|
-
setIndexes(new Set(indexes))
|
|
37
|
-
} else {
|
|
38
|
-
setIndexes(new Set(indexes.add(index)))
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return (
|
|
42
|
-
<Accordion expandedIndices={indexes} onChange={onChange}>
|
|
43
|
-
<AccordionItem {...args}>
|
|
44
|
-
<UIList>
|
|
45
|
-
{values.map((label) => {
|
|
46
|
-
return <li key={label}>{label}</li>
|
|
47
|
-
})}
|
|
48
|
-
</UIList>
|
|
49
|
-
</AccordionItem>
|
|
50
|
-
</Accordion>
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
<header>
|
|
55
|
-
|
|
56
|
-
# Accordion Item
|
|
57
|
-
|
|
58
|
-
An item of a set of items on `Accordion`.
|
|
59
|
-
|
|
60
|
-
</header>
|
|
61
|
-
|
|
62
|
-
## Overview
|
|
63
|
-
|
|
64
|
-
The `AccordionItem` is part of [Accordion](?path=/docs/molecules-accordion-overview--default-story) component.
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## Usage
|
|
69
|
-
|
|
70
|
-
`import Accordion, { AccordionItem } from 'src/components/ui/Accordion'`
|
|
71
|
-
|
|
72
|
-
<Canvas>
|
|
73
|
-
<Story name="default">{Template.bind({})}</Story>
|
|
74
|
-
</Canvas>
|
|
75
|
-
|
|
76
|
-
<ArgsTable story="default" />
|
|
77
|
-
|
|
78
|
-
<TokenTable>
|
|
79
|
-
<TokenRow
|
|
80
|
-
token="--fs-accordion-item-border-bottom-width"
|
|
81
|
-
value="var(--fs-border-width)"
|
|
82
|
-
/>
|
|
83
|
-
<TokenRow
|
|
84
|
-
token="--fs-accordion-item-border-bottom-color"
|
|
85
|
-
value="var(--fs-border-color-light)"
|
|
86
|
-
isColor
|
|
87
|
-
/>
|
|
88
|
-
</TokenTable>
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Nested Elements
|
|
93
|
-
|
|
94
|
-
### Button
|
|
95
|
-
|
|
96
|
-
<TokenTable>
|
|
97
|
-
<TokenRow
|
|
98
|
-
token="--fs-accordion-item-button-padding"
|
|
99
|
-
value="var(--fs-spacing-3) 0"
|
|
100
|
-
/>
|
|
101
|
-
<TokenRow
|
|
102
|
-
token="--fs-accordion-item-button-color"
|
|
103
|
-
value="var(--fs-color-text)"
|
|
104
|
-
isColor
|
|
105
|
-
/>
|
|
106
|
-
<TokenRow token="--fs-accordion-item-button-bkg-color" value="transparent" />
|
|
107
|
-
</TokenTable>
|
|
108
|
-
|
|
109
|
-
### Panel
|
|
110
|
-
|
|
111
|
-
<TokenTable>
|
|
112
|
-
<TokenRow
|
|
113
|
-
token="--fs-accordion-item-panel-padding-bottom"
|
|
114
|
-
value="var(--fs-spacing-4)"
|
|
115
|
-
/>
|
|
116
|
-
</TokenTable>
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { AccordionItemProps } from '@faststore/ui'
|
|
2
|
-
import {
|
|
3
|
-
AccordionButton as UIAccordionButton,
|
|
4
|
-
AccordionItem as UIAccordionItem,
|
|
5
|
-
AccordionPanel as UIAccordionPanel,
|
|
6
|
-
Icon as UIIcon,
|
|
7
|
-
} from '@faststore/ui'
|
|
8
|
-
import { forwardRef } from 'react'
|
|
9
|
-
import type { ReactNode } from 'react'
|
|
10
|
-
|
|
11
|
-
import Icon from 'src/components/ui/Icon'
|
|
12
|
-
|
|
13
|
-
type Props = Omit<AccordionItemProps<'article' | 'div'>, 'ref'> & {
|
|
14
|
-
/**
|
|
15
|
-
* Attribute to check whether the item is expanded or not.
|
|
16
|
-
*/
|
|
17
|
-
isExpanded: boolean
|
|
18
|
-
/**
|
|
19
|
-
* Label for Accordion button
|
|
20
|
-
*/
|
|
21
|
-
buttonLabel?: ReactNode
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const AccordionItem = forwardRef<HTMLDivElement, Props>(function AccordionItem(
|
|
25
|
-
{
|
|
26
|
-
children,
|
|
27
|
-
isExpanded,
|
|
28
|
-
index = 0,
|
|
29
|
-
buttonLabel = '',
|
|
30
|
-
testId = 'store-accordion-item',
|
|
31
|
-
as,
|
|
32
|
-
...otherProps
|
|
33
|
-
},
|
|
34
|
-
ref
|
|
35
|
-
) {
|
|
36
|
-
return (
|
|
37
|
-
<UIAccordionItem
|
|
38
|
-
ref={ref}
|
|
39
|
-
index={index}
|
|
40
|
-
data-testid={`${testId}-item`}
|
|
41
|
-
data-fs-accordion-item
|
|
42
|
-
as={as}
|
|
43
|
-
{...otherProps}
|
|
44
|
-
>
|
|
45
|
-
<UIAccordionButton
|
|
46
|
-
className="text__title-subsection"
|
|
47
|
-
data-fs-accordion-item-button
|
|
48
|
-
data-testid={`${testId}-button`}
|
|
49
|
-
>
|
|
50
|
-
{buttonLabel}
|
|
51
|
-
<UIIcon
|
|
52
|
-
data-testid={`${testId}-button-icon`}
|
|
53
|
-
data-fs-accordion-item-button-icon
|
|
54
|
-
component={
|
|
55
|
-
<>
|
|
56
|
-
<Icon
|
|
57
|
-
data-icon={isExpanded ? 'expanded' : true}
|
|
58
|
-
name="MinusCircle"
|
|
59
|
-
width={24}
|
|
60
|
-
height={24}
|
|
61
|
-
/>
|
|
62
|
-
<Icon
|
|
63
|
-
data-icon={isExpanded ? true : 'collapsed'}
|
|
64
|
-
name="PlusCircle"
|
|
65
|
-
width={24}
|
|
66
|
-
height={24}
|
|
67
|
-
/>
|
|
68
|
-
</>
|
|
69
|
-
}
|
|
70
|
-
/>
|
|
71
|
-
</UIAccordionButton>
|
|
72
|
-
<UIAccordionPanel
|
|
73
|
-
data-testid={`${testId}-panel`}
|
|
74
|
-
data-fs-accordion-item-panel
|
|
75
|
-
>
|
|
76
|
-
{children}
|
|
77
|
-
</UIAccordionPanel>
|
|
78
|
-
</UIAccordionItem>
|
|
79
|
-
)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
export default AccordionItem
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
@import "src/styles/scaffold";
|
|
2
|
-
|
|
3
|
-
.fs-accordion {
|
|
4
|
-
// --------------------------------------------------------
|
|
5
|
-
// Design Tokens for Accordion
|
|
6
|
-
// --------------------------------------------------------
|
|
7
|
-
|
|
8
|
-
// Item
|
|
9
|
-
--fs-accordion-item-border-bottom-width : var(--fs-border-width);
|
|
10
|
-
--fs-accordion-item-border-bottom-color : var(--fs-border-color-light);
|
|
11
|
-
|
|
12
|
-
// Item Button
|
|
13
|
-
--fs-accordion-item-button-padding : var(--fs-spacing-3) 0;
|
|
14
|
-
--fs-accordion-item-button-color : var(--fs-color-text);
|
|
15
|
-
--fs-accordion-item-button-bkg-color : transparent;
|
|
16
|
-
|
|
17
|
-
// Item Panel
|
|
18
|
-
--fs-accordion-item-panel-padding-bottom : var(--fs-spacing-4);
|
|
19
|
-
|
|
20
|
-
// --------------------------------------------------------
|
|
21
|
-
// Structural Styles
|
|
22
|
-
// --------------------------------------------------------
|
|
23
|
-
|
|
24
|
-
display: flex;
|
|
25
|
-
flex-direction: column;
|
|
26
|
-
justify-content: space-around;
|
|
27
|
-
|
|
28
|
-
[data-fs-accordion-item] {
|
|
29
|
-
border-bottom: var(--fs-accordion-item-border-bottom-width) solid var(--fs-accordion-item-border-bottom-color);
|
|
30
|
-
|
|
31
|
-
@include media(">=notebook") {
|
|
32
|
-
&:last-child {
|
|
33
|
-
border-bottom: 0;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
[data-fs-accordion-item-button] {
|
|
39
|
-
display: inline-flex;
|
|
40
|
-
align-items: center;
|
|
41
|
-
justify-content: space-between;
|
|
42
|
-
width: 100%;
|
|
43
|
-
padding: var(--fs-accordion-item-button-padding);
|
|
44
|
-
color: var(--fs-accordion-item-button-color);
|
|
45
|
-
cursor: pointer;
|
|
46
|
-
background-color: var(--fs-accordion-item-button-bkg-color);
|
|
47
|
-
border: 0;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
[data-fs-accordion-item-button-icon] {
|
|
51
|
-
display: flex;
|
|
52
|
-
|
|
53
|
-
[data-icon] {
|
|
54
|
-
display: none;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
[data-icon="expanded"], [data-icon="collapsed"] {
|
|
58
|
-
display: initial;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
[data-fs-accordion-item-panel] {
|
|
63
|
-
padding-bottom: var(--fs-accordion-item-panel-padding-bottom);
|
|
64
|
-
}
|
|
65
|
-
}
|