jattac.libs.web.zest-button 1.2.2 → 1.2.4
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 +7 -5
- package/dist/ZestButton.d.ts +6 -2
- package/dist/ZestContext.d.ts +9 -0
- package/dist/ZestProvider.d.ts +8 -0
- package/dist/hooks/useBusyState.d.ts +20 -0
- package/dist/hooks/useConfirmation.d.ts +13 -0
- package/dist/hooks/useThemeDetection.d.ts +1 -0
- package/dist/hooks/useZestConfig.d.ts +2 -0
- package/dist/index.cjs.js +376 -110
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +18 -2
- package/dist/index.esm.js +375 -111
- package/dist/index.esm.js.map +1 -1
- package/dist/semanticTypeDefaults.d.ts +4 -0
- package/docs/api.md +119 -0
- package/docs/breaking-changes.md +52 -0
- package/docs/configuration.md +192 -0
- package/docs/development.md +77 -0
- package/docs/examples.md +215 -0
- package/docs/features.md +113 -0
- package/package.json +24 -7
package/docs/features.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Features: A Guided Tour
|
|
2
|
+
|
|
3
|
+
This document provides a high-level showcase of what's possible with `ZestButton`. For detailed, practical implementation guides, please see our **[Cookbook](./examples.md)**.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### Asynchronous Operations & Feedback
|
|
8
|
+
|
|
9
|
+
**What it does:** Automatically handles loading states and provides clear success/failure feedback for any action that returns a Promise.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
const MyComponent = () => {
|
|
13
|
+
const handleAsyncClick = async () => {
|
|
14
|
+
// Simulate an API call that takes 2 seconds
|
|
15
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ZestButton onClick={handleAsyncClick}>
|
|
20
|
+
Perform Async Action
|
|
21
|
+
</ZestButton>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
*__Learn more in the [Your First Async Button recipe](./examples.md#recipe-1-your-first-async-button).__*
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### Confirmation Flow
|
|
30
|
+
|
|
31
|
+
**What it does:** Protects users from accidentally performing critical actions by requiring a second click to confirm.
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
const MyComponent = () => {
|
|
35
|
+
const handleDelete = () => alert('The item has been deleted!');
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<ZestButton
|
|
39
|
+
onClick={handleDelete}
|
|
40
|
+
zest={{
|
|
41
|
+
confirmOptions: { displayLabel: 'Confirm?', timeoutSecs: 5 },
|
|
42
|
+
visualOptions: { variant: 'danger' }
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
Delete Item
|
|
46
|
+
</ZestButton>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
```
|
|
50
|
+
*__Learn more in the [Safe "Delete" Button recipe](./examples.md#recipe-2-the-safe-delete-button).__*
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### Semantic Types
|
|
55
|
+
|
|
56
|
+
**What it does:** Streamlines development by allowing you to declare button intent (e.g., `'save'`, `'delete'`). The button automatically gets appropriate icons, colors, and behaviors.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const MyComponent = () => (
|
|
60
|
+
<div style={{ display: 'flex', gap: '1rem' }}>
|
|
61
|
+
<ZestButton zest={{ semanticType: 'save' }}>Save</ZestButton>
|
|
62
|
+
<ZestButton zest={{ semanticType: 'cancel' }}>Cancel</ZestButton>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
```
|
|
66
|
+
*__Learn how to create your own in the [Creating a Custom "Archive" Button recipe](./examples.md#recipe-4-creating-a-custom-archive-button).__*
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### Global Configuration
|
|
71
|
+
|
|
72
|
+
**What it does:** Allows you to define a consistent style (like size or button style) for all buttons across your entire application.
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
// In your App.tsx
|
|
76
|
+
const appZestConfig = {
|
|
77
|
+
defaultProps: {
|
|
78
|
+
visualOptions: { size: 'sm' },
|
|
79
|
+
buttonStyle: 'outline',
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const App = () => (
|
|
84
|
+
<ZestProvider config={appZestConfig}>
|
|
85
|
+
{/* All buttons inside will be small and outline by default */}
|
|
86
|
+
</ZestProvider>
|
|
87
|
+
);
|
|
88
|
+
```
|
|
89
|
+
*__Learn more in the [Standardizing Your Buttons recipe](./examples.md#recipe-3-standardizing-your-buttons-with-a-global-config).__*
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### Rich Styling
|
|
94
|
+
|
|
95
|
+
**What it does:** Provides multiple variants, sizes, and styles (`solid`, `outline`, `text`, `dashed`) to fit any UI context. It also automatically adapts to light and dark themes.
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
const MyComponent = () => (
|
|
99
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '1rem' }}>
|
|
100
|
+
<ZestButton zest={{ visualOptions: { variant: 'success', size: 'sm' } }}>
|
|
101
|
+
Small Success
|
|
102
|
+
</ZestButton>
|
|
103
|
+
<ZestButton zest={{ buttonStyle: 'outline', size: 'md' } }}>
|
|
104
|
+
Medium Outline
|
|
105
|
+
</ZestButton>
|
|
106
|
+
<ZestButton zest={{ visualOptions: { variant: 'danger', size: 'lg' } }}>
|
|
107
|
+
Large Danger
|
|
108
|
+
</ZestButton>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
```
|
|
112
|
+
*Explore all the recipes in the **[Cookbook](./examples.md)** to see these options in action.*
|
|
113
|
+
|
package/package.json
CHANGED
|
@@ -1,35 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jattac.libs.web.zest-button",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "A highly customizable and
|
|
3
|
+
"version": "1.2.4",
|
|
4
|
+
"description": "A highly customizable and production-ready React button component featuring robust asynchronous handling, rich visual feedback, and built-in confirmation flows for enhanced user experience",
|
|
5
|
+
"homepage": "https://github.com/nyingimaina/jattac.libs.web.zest-button.git#readme",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/nyingimaina/jattac.libs.web.zest-button.git.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/nyingimaina/jattac.libs.web.zest-button.git/issues"
|
|
12
|
+
},
|
|
5
13
|
"main": "dist/index.cjs.js",
|
|
6
14
|
"module": "dist/index.esm.js",
|
|
7
15
|
"types": "dist/index.d.ts",
|
|
8
16
|
"files": [
|
|
9
17
|
"dist",
|
|
10
|
-
"README.md"
|
|
18
|
+
"README.md",
|
|
19
|
+
"docs"
|
|
11
20
|
],
|
|
12
21
|
"scripts": {
|
|
13
22
|
"build": "rollup -c rollup.config.mjs",
|
|
14
|
-
"dev": "rollup -c rollup.config.mjs -w"
|
|
23
|
+
"dev": "rollup -c rollup.config.mjs -w",
|
|
24
|
+
"test": "echo \"No tests specified. See WORKPLAN.md for future plans.\" && exit 0"
|
|
15
25
|
},
|
|
16
26
|
"keywords": [
|
|
17
27
|
"react",
|
|
18
28
|
"button",
|
|
19
29
|
"ui",
|
|
20
30
|
"component",
|
|
21
|
-
"
|
|
31
|
+
"interactive",
|
|
32
|
+
"react-button",
|
|
33
|
+
"form",
|
|
34
|
+
"web",
|
|
22
35
|
"async",
|
|
23
36
|
"loading",
|
|
24
37
|
"confirmation",
|
|
25
38
|
"feedback",
|
|
39
|
+
"animation",
|
|
40
|
+
"transitions",
|
|
41
|
+
"ux",
|
|
42
|
+
"zest",
|
|
26
43
|
"jattac"
|
|
27
44
|
],
|
|
28
45
|
"author": "Jattac",
|
|
29
46
|
"license": "MIT",
|
|
30
47
|
"peerDependencies": {
|
|
31
48
|
"react": ">=16.8.0",
|
|
32
|
-
"react-dom": ">=16.8.0"
|
|
49
|
+
"react-dom": ">=16.8.0",
|
|
50
|
+
"react-icons": "^5.0.1"
|
|
33
51
|
},
|
|
34
52
|
"devDependencies": {
|
|
35
53
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
@@ -42,7 +60,6 @@
|
|
|
42
60
|
"postcss-modules": "6.0.1",
|
|
43
61
|
"react": "^18.2.0",
|
|
44
62
|
"react-dom": "^18.2.0",
|
|
45
|
-
"react-icons": "^5.0.1",
|
|
46
63
|
"rollup": "^4.13.0",
|
|
47
64
|
"rollup-plugin-dts": "^6.1.0",
|
|
48
65
|
"rollup-plugin-postcss": "^4.0.2",
|