@camtomlabs/malix-design-system 0.1.7 → 0.3.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 +105 -0
- package/dist/index.cjs +499 -217
- package/dist/index.d.cts +180 -80
- package/dist/index.d.ts +180 -80
- package/dist/index.js +496 -218
- package/eslint-plugin.cjs +128 -0
- package/package.json +21 -10
- package/src/reset.css +212 -0
- package/src/styles.css +231 -55
- package/src/tokens.css +80 -14
- package/src/tokens.registry.json +34 -0
- package/stylelint.config.cjs +56 -0
- package/tailwind.preset.js +173 -0
package/README.md
CHANGED
|
@@ -23,11 +23,29 @@ npm install react react-dom
|
|
|
23
23
|
Import the bundled stylesheet once in your app's entry point (e.g. `main.tsx`, `layout.tsx`, or `_app.tsx`):
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
|
+
// Optional: opt-in reset scoped to @layer malix-reset.
|
|
27
|
+
// Import BEFORE styles.css so the layer order is established correctly.
|
|
28
|
+
import '@camtomlabs/malix-design-system/reset.css';
|
|
29
|
+
|
|
26
30
|
import '@camtomlabs/malix-design-system/styles.css';
|
|
27
31
|
```
|
|
28
32
|
|
|
29
33
|
That's it. All components are styled and ready to use.
|
|
30
34
|
|
|
35
|
+
### Why the reset is optional
|
|
36
|
+
|
|
37
|
+
`reset.css` lives inside `@layer malix-reset`, which means **any style you
|
|
38
|
+
write outside a layer will automatically win** — no specificity wars, no
|
|
39
|
+
`:not()` hacks. Use it if your project has a hostile global reset that
|
|
40
|
+
makes CSS Modules fight for background colors; skip it if you already
|
|
41
|
+
have your own reset.
|
|
42
|
+
|
|
43
|
+
Layer cascade order:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
malix-reset → malix-tokens → malix-components → app
|
|
47
|
+
```
|
|
48
|
+
|
|
31
49
|
## Usage
|
|
32
50
|
|
|
33
51
|
```tsx
|
|
@@ -43,6 +61,75 @@ export function MyPage() {
|
|
|
43
61
|
}
|
|
44
62
|
```
|
|
45
63
|
|
|
64
|
+
## Icons
|
|
65
|
+
|
|
66
|
+
Malix ships a canonical `<Icon>` wrapper that accepts any icon component
|
|
67
|
+
(lucide-react, phosphor-react, custom SVG) and enforces consistent
|
|
68
|
+
sizing and theming via `currentColor`.
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import { Icon } from '@camtomlabs/malix-design-system';
|
|
72
|
+
import { Plus, Search, Trash } from 'lucide-react';
|
|
73
|
+
|
|
74
|
+
<Icon as={Plus} size="md" label="Add item" /> // 16px, aria-label
|
|
75
|
+
<Icon as={Search} size="sm" /> // decorative (aria-hidden)
|
|
76
|
+
<Icon as={Trash} size="lg" /> // 20px
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Sizes: `'xs'` (12px), `'sm'` (14px), `'md'` (16px), `'lg'` (20px), `'xl'` (24px), or a raw number.
|
|
80
|
+
|
|
81
|
+
## ESLint Plugin — enforce canonical components
|
|
82
|
+
|
|
83
|
+
Malix ships an ESLint plugin that catches raw `<button>` and `<input>`
|
|
84
|
+
elements and tells you to use `<Button>` / `<Input>` from the DS.
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
// .eslintrc.cjs
|
|
88
|
+
module.exports = {
|
|
89
|
+
plugins: ['@camtomlabs/malix'],
|
|
90
|
+
rules: {
|
|
91
|
+
'@camtomlabs/malix/no-raw-button': 'warn',
|
|
92
|
+
'@camtomlabs/malix/no-raw-input': 'warn',
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Or use the recommended preset:
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
extends: ['plugin:@camtomlabs/malix/recommended']
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
You can escape the rule with a standard disable comment when needed:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
// eslint-disable-next-line @camtomlabs/malix/no-raw-button
|
|
107
|
+
<button type="submit" form="external-form-id" />
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The `no-raw-input` rule allows `type="hidden"` and `type="file"` by default.
|
|
111
|
+
|
|
112
|
+
## Theme Provider
|
|
113
|
+
|
|
114
|
+
Malix includes a React theme provider for managing dark mode:
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { MalixThemeProvider, useMalixTheme } from '@camtomlabs/malix-design-system';
|
|
118
|
+
|
|
119
|
+
// Wrap your app
|
|
120
|
+
<MalixThemeProvider defaultTheme="system">
|
|
121
|
+
<App />
|
|
122
|
+
</MalixThemeProvider>
|
|
123
|
+
|
|
124
|
+
// Use in any component
|
|
125
|
+
function ThemeToggle() {
|
|
126
|
+
const { theme, toggleTheme } = useMalixTheme();
|
|
127
|
+
return <button onClick={toggleTheme}>{theme}</button>;
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Supported themes: `'light'` | `'dark'` | `'system'`
|
|
132
|
+
|
|
46
133
|
## Design Tokens
|
|
47
134
|
|
|
48
135
|
Malix uses a CSS custom-property token system for colors, spacing, typography, and radius. You can also import the tokens stylesheet separately:
|
|
@@ -57,6 +144,24 @@ Or access the token registry programmatically:
|
|
|
57
144
|
import { tokenRegistry } from '@camtomlabs/malix-design-system';
|
|
58
145
|
```
|
|
59
146
|
|
|
147
|
+
### Quick Reference
|
|
148
|
+
|
|
149
|
+
| Category | Tokens |
|
|
150
|
+
|----------|--------|
|
|
151
|
+
| **Surfaces** | `--malix-surface`, `--malix-surface-secondary`, `--malix-surface-elevated` |
|
|
152
|
+
| **Card** | `--malix-card-bg`, `--malix-card-border`, `--malix-card-radius` |
|
|
153
|
+
| **Input** | `--malix-input-bg`, `--malix-input-border` |
|
|
154
|
+
| **Nav** | `--malix-nav-bg`, `--malix-nav-height` |
|
|
155
|
+
| **Text** | `--malix-foreground`, `--malix-foreground-secondary`, `--malix-foreground-tertiary` |
|
|
156
|
+
| **Primary** | `--malix-primary-bg`, `--malix-primary-hover`, `--malix-primary-active`, `--malix-primary-foreground` |
|
|
157
|
+
| **Semantic** | `--malix-success`, `--malix-warning`, `--malix-error`, `--malix-info` (each with `-light` and `-foreground`) |
|
|
158
|
+
| **Spacing** | `--malix-space-xs` (4px) through `--malix-space-3xl` (48px) |
|
|
159
|
+
| **Radius** | `--malix-radius-sm` (4px) through `--malix-radius-pill` (9999px) |
|
|
160
|
+
| **Typography** | `--malix-text-xs` (12px) through `--malix-text-display` (responsive) |
|
|
161
|
+
| **Layout** | `--malix-container-sm` (640px) through `--malix-container-xl` (1280px) |
|
|
162
|
+
| **Z-Index** | `--malix-z-dropdown` (100) through `--malix-z-notification` (600) |
|
|
163
|
+
| **Shadows** | `--malix-shadow-card-l1` / `l2` / `l3`, `--malix-shadow-overlay`, `--malix-shadow-tooltip` |
|
|
164
|
+
|
|
60
165
|
## Components
|
|
61
166
|
|
|
62
167
|
### Atoms
|