@faststore/components 4.1.0-dev.1 → 4.1.0-dev.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 +90 -10
- package/package.json +23 -22
- package/src/molecules/Toast/Toast.tsx +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://faststore
|
|
2
|
+
<a href="https://developers.vtex.com/docs/guides/faststore">
|
|
3
3
|
<img alt="Faststore" src="../ui/static/logo.png" width="60" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
@@ -8,15 +8,95 @@
|
|
|
8
8
|
</h1>
|
|
9
9
|
<p align="center">
|
|
10
10
|
<strong>
|
|
11
|
-
|
|
11
|
+
FastStore UI components without a style layer
|
|
12
12
|
</strong>
|
|
13
13
|
</p>
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
<img src="https://badge.fury.io/js/%40faststore%2Fui.svg" />
|
|
18
|
-
</a>
|
|
19
|
-
<a href="https://bundlephobia.com/package/@faststore/components" style="padding: 0px 0px 0px 2px">
|
|
20
|
-
<img src="https://badgen.net/bundlephobia/dependency-count/@faststore/components" />
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://www.npmjs.com/package/@faststore/components">
|
|
16
|
+
<img src="https://badge.fury.io/js/%40faststore%2Fcomponents.svg" alt="npm version" />
|
|
21
17
|
</a>
|
|
22
|
-
</
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
`@faststore/components` provides the structure, logic, and accessibility of FastStore UI components — without any styling. It organizes the components into atoms, molecules, and organisms.
|
|
21
|
+
|
|
22
|
+
Styling is handled separately by `@faststore/ui`, which consumes this package and applies design tokens and structural SCSS on top of the data attributes defined here.
|
|
23
|
+
|
|
24
|
+
## Package structure
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
src/
|
|
28
|
+
├── atoms/ # Basic building blocks (Button, Input, Badge, Icon, etc.)
|
|
29
|
+
├── molecules/ # Composite components (Accordion, CartItem, ProductCard, etc.)
|
|
30
|
+
├── organisms/ # Complex feature components (Hero, Filter, ProductShelf, etc.)
|
|
31
|
+
├── hooks/ # UI state hooks (useSlider, useSearch, useTrapFocus, etc.)
|
|
32
|
+
├── typings/ # Shared TypeScript types
|
|
33
|
+
└── index.ts # Public exports
|
|
34
|
+
test/
|
|
35
|
+
└── molecules/ # Component tests (incomplete — see note below)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> **Note:** Test coverage is currently incomplete. Tests should live in `test/{category}/{ComponentName}/` for all atoms, molecules, and organisms. Contributions adding missing test coverage are welcome.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## How to run
|
|
42
|
+
|
|
43
|
+
### Prerequisites
|
|
44
|
+
|
|
45
|
+
- Node.js ≥ 20
|
|
46
|
+
- pnpm
|
|
47
|
+
|
|
48
|
+
### Local setup
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# 1. Install dependencies (from the repo root)
|
|
52
|
+
pnpm install
|
|
53
|
+
|
|
54
|
+
# 2. Start the build in watch mode
|
|
55
|
+
pnpm dev
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## How to develop
|
|
59
|
+
|
|
60
|
+
### Adding a new component
|
|
61
|
+
|
|
62
|
+
1. **Categorize** the component: atom, molecule, or organism
|
|
63
|
+
2. **Create** `src/{category}/{ComponentName}/{ComponentName}.tsx` and `index.ts`
|
|
64
|
+
3. **Use data attributes** for styling hooks — no style imports in this package:
|
|
65
|
+
```tsx
|
|
66
|
+
<div
|
|
67
|
+
data-fs-badge // root identifier
|
|
68
|
+
data-fs-badge-size={size} // state attribute
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</div>
|
|
72
|
+
```
|
|
73
|
+
4. **Export** from `src/index.ts`
|
|
74
|
+
5. **Add styles** in `@faststore/ui` using the data attributes as selectors
|
|
75
|
+
6. **Write tests** in `test/{category}/{ComponentName}/`
|
|
76
|
+
|
|
77
|
+
> For the full implementation checklist (accessibility, props interface, composability guidelines), refer to the [Component Implementation Guidelines](../../AGENTS.md#-faststore-components-implementation-guidelines) in `AGENTS.md`.
|
|
78
|
+
|
|
79
|
+
### Data attribute naming convention
|
|
80
|
+
|
|
81
|
+
| Context | Pattern | Example |
|
|
82
|
+
| :--- | :--- | :--- |
|
|
83
|
+
| Root element | `data-fs-{component}` | `data-fs-badge` |
|
|
84
|
+
| Internal structure | `data-fs-{component}-{part}` | `data-fs-badge-wrapper` |
|
|
85
|
+
| State | `data-fs-{component}-{state}={value}` | `data-fs-button-variant="primary"` |
|
|
86
|
+
|
|
87
|
+
## How to test
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pnpm test
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
For interactive visual testing, use Storybook. Run `pnpm dev` from `packages/storybook/` to launch it.
|
|
94
|
+
|
|
95
|
+
## How to publish
|
|
96
|
+
|
|
97
|
+
Versioning and publishing are managed at the monorepo root by Lerna. Do not publish this package independently. Refer to the [Contributing guidelines](../../CONTRIBUTING.MD) for the full release workflow.
|
|
98
|
+
|
|
99
|
+
## Documentation
|
|
100
|
+
|
|
101
|
+
- **Component reference:** [developers.vtex.com/docs/guides/faststore/components-index](https://developers.vtex.com/docs/guides/faststore/components-index)
|
|
102
|
+
- **Implementation guidelines:** [`AGENTS.md`](../../AGENTS.md#-faststore-components-implementation-guidelines)
|
package/package.json
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/components",
|
|
3
|
-
"version": "4.1.0-dev.
|
|
3
|
+
"version": "4.1.0-dev.11",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/es/index.mjs",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"dev": "vite build --watch",
|
|
9
|
-
"build": "vite build",
|
|
10
|
-
"test": "vitest run"
|
|
11
|
-
},
|
|
12
7
|
"exports": {
|
|
13
8
|
".": {
|
|
14
9
|
"types": "./dist/index.d.ts",
|
|
@@ -26,28 +21,29 @@
|
|
|
26
21
|
"directory": "packages/components"
|
|
27
22
|
},
|
|
28
23
|
"peerDependencies": {
|
|
29
|
-
"react": "
|
|
30
|
-
"react-dom": "
|
|
31
|
-
"tabbable": "
|
|
24
|
+
"react": "18.2.0",
|
|
25
|
+
"react-dom": "18.2.0",
|
|
26
|
+
"tabbable": "5.2.1"
|
|
32
27
|
},
|
|
33
28
|
"dependencies": {
|
|
34
|
-
"react-intersection-observer": "
|
|
35
|
-
"react-swipeable": "
|
|
29
|
+
"react-intersection-observer": "^8.32.5",
|
|
30
|
+
"react-swipeable": "^7.0.0"
|
|
36
31
|
},
|
|
37
32
|
"devDependencies": {
|
|
38
33
|
"@testing-library/jest-dom": "^6.9.1",
|
|
39
|
-
"@testing-library/react": "
|
|
34
|
+
"@testing-library/react": "14.3.1",
|
|
40
35
|
"@types/papaparse": "^5.5.0",
|
|
41
|
-
"@types/react": "
|
|
42
|
-
"@types/react-dom": "
|
|
43
|
-
"@types/tabbable": "
|
|
36
|
+
"@types/react": "^18.3.27",
|
|
37
|
+
"@types/react-dom": "^18",
|
|
38
|
+
"@types/tabbable": "^3.1.1",
|
|
39
|
+
"@vitest/coverage-v8": "4.0.7",
|
|
44
40
|
"papaparse": "^5.5.3",
|
|
45
41
|
"react-dropzone": "^14.3.8",
|
|
46
|
-
"tabbable": "
|
|
47
|
-
"tslib": "
|
|
48
|
-
"vite": "
|
|
49
|
-
"vite-plugin-dts": "
|
|
50
|
-
"vitest": "
|
|
42
|
+
"tabbable": "5.2.1",
|
|
43
|
+
"tslib": "2.8.1",
|
|
44
|
+
"vite": "7.1.5",
|
|
45
|
+
"vite-plugin-dts": "4.5.4",
|
|
46
|
+
"vitest": "4.0.7",
|
|
51
47
|
"vitest-axe": "^0.1.0"
|
|
52
48
|
},
|
|
53
49
|
"engines": {
|
|
@@ -56,5 +52,10 @@
|
|
|
56
52
|
"publishConfig": {
|
|
57
53
|
"access": "public"
|
|
58
54
|
},
|
|
59
|
-
"
|
|
60
|
-
|
|
55
|
+
"scripts": {
|
|
56
|
+
"dev": "vite build --watch",
|
|
57
|
+
"build": "vite build",
|
|
58
|
+
"test": "vitest run",
|
|
59
|
+
"test:coverage": "vitest run --coverage"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -5,7 +5,7 @@ import { useUI } from '../../hooks'
|
|
|
5
5
|
function Toast() {
|
|
6
6
|
const { toasts, popToast } = useUI()
|
|
7
7
|
const toast = toasts[toasts.length - 1]
|
|
8
|
-
const timeoutRef = useRef<
|
|
8
|
+
const timeoutRef = useRef<ReturnType<typeof setTimeout>>()
|
|
9
9
|
|
|
10
10
|
const [visible, setVisible] = useState(false)
|
|
11
11
|
|