@fuf-stack/pixel-utils 1.4.0 → 2.0.0-next.1
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 +56 -4
- package/dist/index.d.mts +58 -715
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +128 -10
- package/dist/index.mjs.map +1 -1
- package/dist/tokens.css +574 -0
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Shared helper utilities for the fuf pixels component library.
|
|
4
4
|
|
|
5
|
+
## Token stylesheet
|
|
6
|
+
|
|
7
|
+
Import `@fuf-stack/pixel-utils/tokens.css` after Tailwind in your global CSS entry.
|
|
8
|
+
It provides owned semantic tokens and utilities in light/dark themes, including
|
|
9
|
+
`bg-content1`, `text-danger`, `text-small`, `border-small` and `rounded-small`.
|
|
10
|
+
Override `--pixel-*` variables in theme scopes. See [styling](../../docs/styling.md)
|
|
11
|
+
for source detection and theme customization. CSS is marked side-effectful
|
|
12
|
+
and is never imported through the JavaScript entry.
|
|
13
|
+
|
|
5
14
|
## Exports
|
|
6
15
|
|
|
7
16
|
### `cn(...classes)`
|
|
@@ -76,8 +85,39 @@ const classes = variantsToClassNames(
|
|
|
76
85
|
// => { base: 'shadow-lg', content: 'p-4 max-w-sm', trigger: 'cursor-pointer' }
|
|
77
86
|
```
|
|
78
87
|
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
`tv` includes the same prose merge rules as `cn`. Owned recipes additionally
|
|
89
|
+
classify existing semantic sizes, radii, borders, shadows and transitions.
|
|
90
|
+
The legacy standalone `cn` keeps its previous semantic classification for compatibility; use instance helpers for semantic utility classes. Recipes use the unmerged
|
|
91
|
+
Tailwind Variants engine, then resolve conflicts with an isolated instance.
|
|
92
|
+
Compound variants and recipe extension retain their classes until final merging.
|
|
93
|
+
|
|
94
|
+
### `createStyling(config?)`, `defaultStyling`
|
|
95
|
+
|
|
96
|
+
Create an immutable set of `cn`, `tv`, `resolve`, and `variantsToClassNames`
|
|
97
|
+
helpers using Tailwind Merge's `extend`/`override` configuration format. Custom
|
|
98
|
+
class groups and directional conflicts are supported. The configuration is
|
|
99
|
+
copied when the instance is created; separate instances do not share settings.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { createStyling, tv } from '@fuf-stack/pixel-utils';
|
|
103
|
+
|
|
104
|
+
export const styling = createStyling({
|
|
105
|
+
extend: { classGroups: { 'font-size': [{ text: ['body'] }] } },
|
|
106
|
+
});
|
|
107
|
+
styling.cn('text-sm text-danger', 'text-body');
|
|
108
|
+
// => 'text-danger text-body'
|
|
109
|
+
|
|
110
|
+
// Resolve an existing module-level recipe before merging slot overrides.
|
|
111
|
+
const input = tv({ slots: { input: 'text-danger text-sm' } });
|
|
112
|
+
styling.variantsToClassNames(styling.resolve(input), { input: 'text-body' });
|
|
113
|
+
// => { base: undefined, input: 'text-danger text-body' }
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Use `styling.tv` for application recipes. Use `styling.resolve` only with recipes
|
|
117
|
+
created by pixel-utils: classes discarded inside a third-party recipe cannot be
|
|
118
|
+
recovered. Define the corresponding utility in Tailwind separately; merge
|
|
119
|
+
configuration does not generate CSS. See [styling](../../docs/styling.md) for
|
|
120
|
+
React context usage and source detection.
|
|
81
121
|
|
|
82
122
|
### `slugify(string, options?)`
|
|
83
123
|
|
|
@@ -94,6 +134,18 @@ slugify('a.b.c', { replaceDots: true }); // => 'a_b_c'
|
|
|
94
134
|
|
|
95
135
|
Returns `true` when running inside Vitest or when `NODE_ENV` is `test`. Safe for both Node.js and browser environments.
|
|
96
136
|
|
|
97
|
-
|
|
137
|
+
## Migration from the HeroUI plugin
|
|
138
|
+
|
|
139
|
+
The `heroui` JavaScript export is removed as a breaking change. Replace the
|
|
140
|
+
Tailwind plugin with the token stylesheet and scan the built component packages:
|
|
141
|
+
|
|
142
|
+
```css
|
|
143
|
+
@import 'tailwindcss';
|
|
144
|
+
@import '@fuf-stack/pixel-utils/tokens.css';
|
|
145
|
+
@source '../node_modules/@fuf-stack/pixels/dist';
|
|
146
|
+
@source '../node_modules/@fuf-stack/uniform/dist';
|
|
147
|
+
```
|
|
98
148
|
|
|
99
|
-
|
|
149
|
+
Paths are relative to the stylesheet. Add Megapixels when used. Replace custom
|
|
150
|
+
`--heroui-*` variables with the corresponding `--pixel-*` variables. The default
|
|
151
|
+
palette and semantic utilities remain available without a plugin.
|