@aristobyte-ui/switch 2.8.0 → 2.9.0
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 +98 -0
- package/es/.tsbuildinfo +1 -1
- package/lib/.tsbuildinfo +1 -1
- package/package.json +10 -2
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# `@aristobyte-ui/switch`
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://img.shields.io/badge/TypeScript-5.8-blue?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript" />
|
|
5
|
+
<img src="https://img.shields.io/badge/Build-Turbo-green?style=for-the-badge&logo=turbo&logoColor=white" alt="TurboRepo" />
|
|
6
|
+
<img src="https://img.shields.io/badge/Lint-Strict-red?style=for-the-badge&logo=eslint&logoColor=white" alt="ESLint" />
|
|
7
|
+
<img src="https://img.shields.io/badge/License-MIT-black?style=for-the-badge&logo=open-source-initiative&logoColor=white" alt="License" />
|
|
8
|
+
<img src="https://img.shields.io/badge/AristoByte-UI-purple?style=for-the-badge&logo=react&logoColor=white" alt="AristoByte UI" />
|
|
9
|
+
<img src="https://img.shields.io/badge/Node-20.17.0+-339933?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js >=20.17.0" />
|
|
10
|
+
<img src="https://img.shields.io/badge/Yarn-1.22+-2C8EBB?style=for-the-badge&logo=yarn&logoColor=white" alt="Yarn >=1.22" />
|
|
11
|
+
<img src="https://img.shields.io/badge/NPM-10.8+-CB3837?style=for-the-badge&logo=npm&logoColor=white" alt="NPM >=10.8" />
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
A highly flexible and type-safe Switch component for React with multiple sizes, variants, and label alignment options.
|
|
15
|
+
|
|
16
|
+
## 📦 Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Install via Yarn
|
|
20
|
+
yarn add -D @aristobyte-ui/switch
|
|
21
|
+
|
|
22
|
+
# Or via npm
|
|
23
|
+
npm install -D @aristobyte-ui/switch
|
|
24
|
+
|
|
25
|
+
# Or via pnpm
|
|
26
|
+
pnpm add -D @aristobyte-ui/switch
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 🛠 Usage
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { Switch } from "@aristobyte-ui/switch";
|
|
33
|
+
|
|
34
|
+
export const Demo = () => (
|
|
35
|
+
<Switch
|
|
36
|
+
label="Enable notifications"
|
|
37
|
+
alignLabel="horizontal"
|
|
38
|
+
switchSize="md"
|
|
39
|
+
variant="primary"
|
|
40
|
+
checked={true}
|
|
41
|
+
onChange={() => console.log("Toggled!")}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 📂 Presets Available
|
|
47
|
+
|
|
48
|
+
**alignLabel**: `"horizontal"` | `"vertical"` (default: `"vertical"`)
|
|
49
|
+
|
|
50
|
+
**switchSize**: `"xsm"` | `"sm"` | `"md"` | `"lg"` | `"xlg"` (default: `"md"`)
|
|
51
|
+
|
|
52
|
+
**variant**: `"default"` | `"primary"` | `"secondary"` | `"success"` | `"error"` | `"warning"` (default: `"default"`)
|
|
53
|
+
|
|
54
|
+
**trackIcon** & **thumbIcon**: Optional React components for custom icons
|
|
55
|
+
|
|
56
|
+
**disabled**: Boolean flag to disable switch
|
|
57
|
+
|
|
58
|
+
## 🔧 Example in a Package
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<Switch
|
|
62
|
+
label="Dark Mode"
|
|
63
|
+
switchSize="lg"
|
|
64
|
+
variant="secondary"
|
|
65
|
+
trackIcon={{ checked: CheckIcon, unchecked: CloseIcon }}
|
|
66
|
+
thumbIcon={StarIcon}
|
|
67
|
+
checked={false}
|
|
68
|
+
/>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 📊 Why This Matters
|
|
72
|
+
|
|
73
|
+
- **Performance-first:** Lightweight CSS transitions ensure smooth toggling with zero layout thrashing.
|
|
74
|
+
- **Fully typed:** TypeScript-first API for predictable integration and IDE autocomplete.
|
|
75
|
+
- **AristoByteUI ready:** Integrates seamlessly with design tokens and SCSS modules.
|
|
76
|
+
- **Flexible:** Supports multiple sizes, label alignments, variants, and custom icons.
|
|
77
|
+
|
|
78
|
+
## 🏆 Philosophy
|
|
79
|
+
|
|
80
|
+
- **Modular architecture:** Switch component is fully composable.
|
|
81
|
+
- **Declarative styling:** SCSS modules keep styles maintainable and scoped.
|
|
82
|
+
- **Strict typing & runtime flexibility:** Props fully typed while allowing runtime overrides.
|
|
83
|
+
- **Developer experience optimized:** Easy to use with predictable behavior and minimal boilerplate.
|
|
84
|
+
|
|
85
|
+
## 📜 License
|
|
86
|
+
|
|
87
|
+
[MIT](./LICENSE) © AristoByte
|
|
88
|
+
|
|
89
|
+
## 🛡 Shields Showcase
|
|
90
|
+
|
|
91
|
+
<p align="center">
|
|
92
|
+
<img src="https://img.shields.io/badge/Consistency-100%25-green?style=for-the-badge&logo=typescript" />
|
|
93
|
+
<img src="https://img.shields.io/badge/Maintained-Active-brightgreen?style=for-the-badge&logo=github" />
|
|
94
|
+
<img src="https://img.shields.io/badge/Strictness-High-critical?style=for-the-badge&logo=eslint" />
|
|
95
|
+
<img src="https://img.shields.io/badge/Declarations-Enabled-blue?style=for-the-badge&logo=typescript" />
|
|
96
|
+
<img src="https://img.shields.io/badge/Monorepo-Turbo-green?style=for-the-badge&logo=monorepo" />
|
|
97
|
+
<img src="https://img.shields.io/badge/Interop-ESM%2FCJS-orange?style=for-the-badge&logo=javascript" />
|
|
98
|
+
</p>
|