@splenddev/kreativ-core 0.1.0 → 0.1.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 +37 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,13 +61,13 @@ Kreativ Core tokens · semantic tokens · typography · sizes · recipes
|
|
|
61
61
|
themes · validation · CSS variables · component metadata · React runtime
|
|
62
62
|
│
|
|
63
63
|
▼
|
|
64
|
-
Kreativ UI components + the default design language
|
|
64
|
+
Kreativ UI components + the default design language + extend*() helpers
|
|
65
65
|
│
|
|
66
66
|
▼
|
|
67
67
|
Your app
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
Use Kreativ UI to build apps. Reach for Core when you're building your own design system or tooling on the same foundation. Defaults (tokens, sizes, typography, recipes) belong to Kreativ UI, never to Core.
|
|
70
|
+
Use Kreativ UI to build apps. Reach for Core when you're building your own design system or tooling on the same foundation. Defaults (tokens, sizes, typography, recipes) belong to Kreativ UI, never to Core — and because "extending" means merging against _some_ default, the `extendTokens()`, `extendSemanticTokens()`, `extendTypography()`, `extendSizes()`, and `extendRecipes()` helpers live in Kreativ UI too. Core only ships the `defineX` functions that build a layer from scratch. See [Using Core standalone](#using-core-standalone) if you want that extend pattern without Kreativ UI.
|
|
71
71
|
|
|
72
72
|
### Providers
|
|
73
73
|
|
|
@@ -195,7 +195,7 @@ const theme = defineTheme({
|
|
|
195
195
|
|
|
196
196
|
`defineTheme()` keeps the exact shape you pass in while validating the relationships between layers. Metadata fields are `name`, `description`, `author`, and `source`, all optional.
|
|
197
197
|
|
|
198
|
-
#### Overriding
|
|
198
|
+
#### Overriding
|
|
199
199
|
|
|
200
200
|
Customize an existing theme with a `ThemeOverride`:
|
|
201
201
|
|
|
@@ -209,7 +209,7 @@ const override = {
|
|
|
209
209
|
};
|
|
210
210
|
```
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
Core itself doesn't merge an override against a default theme for you — there's no default theme to merge against here. That's what Kreativ UI's `extendTokens()`, `extendSemanticTokens()`, `extendTypography()`, `extendSizes()`, and `extendRecipes()` do, one layer at a time, against its built-in defaults. If you're not using Kreativ UI, see below.
|
|
213
213
|
|
|
214
214
|
### Validation
|
|
215
215
|
|
|
@@ -241,6 +241,13 @@ colors.brand → --kui-brand
|
|
|
241
241
|
--kui-intensity
|
|
242
242
|
```
|
|
243
243
|
|
|
244
|
+
`tokensToCssVars` takes an optional `prefix` argument (default `"kui"`), so you can generate variables under your own namespace instead:
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
tokensToCssVars(resolved, "light", theme.intensity, "myds");
|
|
248
|
+
// --myds-brand, --myds-mode, --myds-intensity, ...
|
|
249
|
+
```
|
|
250
|
+
|
|
244
251
|
Color values are normalized to RGB channels where appropriate, so the variables work with modern color-manipulation patterns.
|
|
245
252
|
|
|
246
253
|
### ThemeProvider
|
|
@@ -342,6 +349,31 @@ A component is controlled when `value` is defined. In controlled mode, `setValue
|
|
|
342
349
|
|
|
343
350
|
Responsive styles are generated from the active theme's breakpoint tokens, so components never hard-code breakpoints. The generated rules come back together with a data attribute that scopes them to the element.
|
|
344
351
|
|
|
352
|
+
## Using Core standalone
|
|
353
|
+
|
|
354
|
+
Core ships the `defineX` functions (`defineTokens`, `defineSemanticToken`, `defineTypography`, `defineSizes`, `defineRecipe`, `defineTheme`) but no built-in defaults, and no `extendX` helpers — those are a Kreativ UI concern, since "extending" means merging an override against _some_ default set, and Core doesn't ship one.
|
|
355
|
+
|
|
356
|
+
If you're building your own design system on Core, define your own defaults once, then write small `extend` wrappers over them the same way Kreativ UI does internally:
|
|
357
|
+
|
|
358
|
+
```ts
|
|
359
|
+
import { defineTokens, deepMerge } from "@splenddev/kreativ-core";
|
|
360
|
+
import type {
|
|
361
|
+
DesignTokens,
|
|
362
|
+
ThemeOverride,
|
|
363
|
+
} from "@splenddev/kreativ-core/types";
|
|
364
|
+
|
|
365
|
+
const defaultTokens = defineTokens({
|
|
366
|
+
colors: { blue: { 500: "#3b82f6", 600: "#2563eb" } },
|
|
367
|
+
spacing: { sm: "0.5rem", md: "1rem" },
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
export function extendTokens(override?: ThemeOverride["tokens"]): DesignTokens {
|
|
371
|
+
return deepMerge(defaultTokens, override);
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
The same pattern applies to `defineSemanticToken`, `defineTypography`, `defineSizes`, and `defineRecipe` — define the default layer, then merge overrides against it with `deepMerge` (for tokens) or a small per-key merge (for typography, sizes, and recipes, where overrides should merge one level deep rather than replace the whole entry).
|
|
376
|
+
|
|
345
377
|
## Design principles
|
|
346
378
|
|
|
347
379
|
- **Tokens before components.** Components consume the design system; they don't invent their own visual language.
|
|
@@ -349,7 +381,7 @@ Responsive styles are generated from the active theme's breakpoint tokens, so co
|
|
|
349
381
|
- **Strict primitives, flexible semantics.** Primitives stay terminal; semantic tokens do the referencing.
|
|
350
382
|
- **Metadata is part of the contract.** A component's role, relationships, and supported states are described to tooling, not just rendered.
|
|
351
383
|
- **Predictable composition.** Prop merging, theme extension, recipe resolution, and token resolution all follow explicit precedence.
|
|
352
|
-
- **Defaults belong to the implementation.** Core defines the system; Kreativ UI defines the look.
|
|
384
|
+
- **Defaults belong to the implementation.** Core defines the system; Kreativ UI defines the look — and owns the `extendX` helpers that merge against that look.
|
|
353
385
|
|
|
354
386
|
## Contributing
|
|
355
387
|
|
package/package.json
CHANGED