@pimolu/core 0.1.0-beta.3 → 0.1.0-beta.3.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.fr.md +98 -42
- package/README.md +98 -42
- package/package.json +1 -1
package/README.fr.md
CHANGED
|
@@ -1,42 +1,98 @@
|
|
|
1
|
-
# @pimolu/core
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
# @pimolu/core
|
|
2
|
+
|
|
3
|
+
**Des noms de classes prévisibles, sans runtime.**
|
|
4
|
+
|
|
5
|
+
Un petit utilitaire indépendant du framework pour composer des noms de classes à partir de variantes nommées. `createVariants` renvoie une chaîne. Il ne génère pas de CSS, n'injecte pas de styles et ne nécessite pas React.
|
|
6
|
+
|
|
7
|
+
[Source](https://github.com/pimoludev/ui/tree/main/packages/core) · [Composants](https://pimolu.com/components)
|
|
8
|
+
|
|
9
|
+
> **Bêta :** `0.1.0-beta.3.1` est une prévisualisation.
|
|
10
|
+
|
|
11
|
+
## Pourquoi @pimolu/core ?
|
|
12
|
+
|
|
13
|
+
- **Zéro dépendance.** Un petit utilitaire sans runtime, sans CSS-in-JS et sans couplage au build.
|
|
14
|
+
- **Variantes typées.** Déduisez un type `VariantProps` directement depuis la définition des variantes.
|
|
15
|
+
- **Sortie déterministe.** L'ordre des classes est prévisible et une classe supplémentaire est ajoutée en dernier.
|
|
16
|
+
- **Utilisable au-delà de Pimolu.** Employez-le avec n'importe quelle architecture CSS qui veut des variantes nommées sans runtime de style.
|
|
17
|
+
- **La base des composants Pimolu.** Le même utilitaire alimente les variantes React de Pimolu.
|
|
18
|
+
|
|
19
|
+
## En bref
|
|
20
|
+
|
|
21
|
+
| | |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| Export | `createVariants` |
|
|
24
|
+
| Types | `VariantProps` |
|
|
25
|
+
| Dépendances runtime | Aucune |
|
|
26
|
+
| Génération CSS | Aucune |
|
|
27
|
+
| React requis | Non |
|
|
28
|
+
| Distribution | ESM + déclarations TypeScript |
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm add @pimolu/core@beta
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Utilisation
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { createVariants, type VariantProps } from "@pimolu/core";
|
|
40
|
+
|
|
41
|
+
const button = createVariants({
|
|
42
|
+
base: "button",
|
|
43
|
+
variants: {
|
|
44
|
+
size: {
|
|
45
|
+
sm: "button--sm",
|
|
46
|
+
md: "button--md",
|
|
47
|
+
},
|
|
48
|
+
tone: {
|
|
49
|
+
neutral: "button--neutral",
|
|
50
|
+
primary: "button--primary",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
defaultVariants: {
|
|
54
|
+
size: "md",
|
|
55
|
+
tone: "neutral",
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
type ButtonVariants = VariantProps<typeof button>;
|
|
60
|
+
|
|
61
|
+
const options: ButtonVariants = { size: "sm", tone: "primary" };
|
|
62
|
+
|
|
63
|
+
button(options);
|
|
64
|
+
// "button button--sm button--primary"
|
|
65
|
+
|
|
66
|
+
button({}, "checkout-button");
|
|
67
|
+
// "button button--md button--neutral checkout-button"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`createVariants` accepte :
|
|
71
|
+
|
|
72
|
+
| Option | Rôle |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `base` | Classes toujours appliquées |
|
|
75
|
+
| `variants` | Groupes nommés de classes conditionnelles |
|
|
76
|
+
| `defaultVariants` | Valeurs de repli quand une variante est omise |
|
|
77
|
+
| second argument | Classes supplémentaires ajoutées au résultat |
|
|
78
|
+
|
|
79
|
+
L'utilitaire ne connaît pas le CSS. Fournissez les sélecteurs correspondants dans votre feuille, ou utilisez-le avec les styles publiés de Pimolu.
|
|
80
|
+
|
|
81
|
+
## La famille de packages
|
|
82
|
+
|
|
83
|
+
| Package | Rôle |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| [`@pimolu/react`](https://www.npmjs.com/package/@pimolu/react) | Composants, hooks et layouts React |
|
|
86
|
+
| [`@pimolu/web-styles`](https://www.npmjs.com/package/@pimolu/web-styles) | CSS complet, entrée en couches et CSS par composant |
|
|
87
|
+
| [`@pimolu/themes`](https://www.npmjs.com/package/@pimolu/themes) | Thèmes clair/sombre, sept presets et données visuelles |
|
|
88
|
+
| [`@pimolu/design-tokens`](https://www.npmjs.com/package/@pimolu/design-tokens) | Tokens primitifs en CSS et JSON |
|
|
89
|
+
| [`@pimolu/core`](https://www.npmjs.com/package/@pimolu/core) | Utilitaire de classes de variantes indépendant du framework |
|
|
90
|
+
|
|
91
|
+
## Documentation et état
|
|
92
|
+
|
|
93
|
+
- [Catalogue de composants](https://pimolu.com/components)
|
|
94
|
+
- [Source et issues](https://github.com/pimoludev/ui)
|
|
95
|
+
|
|
96
|
+
Pimolu UI est en bêta. Le registre React est implémenté ; les registres native, Angular et web components sont des directions futures. L'utilitaire core est volontairement petit et sans comportement runtime spécifique à Pimolu.
|
|
97
|
+
|
|
98
|
+
MIT © Pimolu
|
package/README.md
CHANGED
|
@@ -1,42 +1,98 @@
|
|
|
1
|
-
# @pimolu/core
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
# @pimolu/core
|
|
2
|
+
|
|
3
|
+
**Predictable class names, without a runtime.**
|
|
4
|
+
|
|
5
|
+
A tiny, framework-independent utility for composing class names from named variants. `createVariants` returns a string. It does not generate CSS, inject styles or require React.
|
|
6
|
+
|
|
7
|
+
[Source](https://github.com/pimoludev/ui/tree/main/packages/core) · [Component docs](https://pimolu.com/components)
|
|
8
|
+
|
|
9
|
+
> **Beta:** `0.1.0-beta.3.1` is a preview.
|
|
10
|
+
|
|
11
|
+
## Why @pimolu/core?
|
|
12
|
+
|
|
13
|
+
- **Zero dependencies.** A small utility with no runtime, no CSS-in-JS and no build-time coupling.
|
|
14
|
+
- **Typed variants.** Infer a `VariantProps` type directly from the variant definition.
|
|
15
|
+
- **Deterministic output.** Class order is predictable, and an optional extra class is appended last.
|
|
16
|
+
- **Works beyond Pimolu.** Use it for any CSS architecture that wants named variants without a styling runtime.
|
|
17
|
+
- **The base of Pimolu components.** The same utility powers Pimolu's React variants.
|
|
18
|
+
|
|
19
|
+
## At a glance
|
|
20
|
+
|
|
21
|
+
| | |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| Export | `createVariants` |
|
|
24
|
+
| Types | `VariantProps` |
|
|
25
|
+
| Runtime dependencies | None |
|
|
26
|
+
| CSS generation | None |
|
|
27
|
+
| React required | No |
|
|
28
|
+
| Distribution | ESM + TypeScript declarations |
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm add @pimolu/core@beta
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Use
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { createVariants, type VariantProps } from "@pimolu/core";
|
|
40
|
+
|
|
41
|
+
const button = createVariants({
|
|
42
|
+
base: "button",
|
|
43
|
+
variants: {
|
|
44
|
+
size: {
|
|
45
|
+
sm: "button--sm",
|
|
46
|
+
md: "button--md",
|
|
47
|
+
},
|
|
48
|
+
tone: {
|
|
49
|
+
neutral: "button--neutral",
|
|
50
|
+
primary: "button--primary",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
defaultVariants: {
|
|
54
|
+
size: "md",
|
|
55
|
+
tone: "neutral",
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
type ButtonVariants = VariantProps<typeof button>;
|
|
60
|
+
|
|
61
|
+
const options: ButtonVariants = { size: "sm", tone: "primary" };
|
|
62
|
+
|
|
63
|
+
button(options);
|
|
64
|
+
// "button button--sm button--primary"
|
|
65
|
+
|
|
66
|
+
button({}, "checkout-button");
|
|
67
|
+
// "button button--md button--neutral checkout-button"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`createVariants` accepts:
|
|
71
|
+
|
|
72
|
+
| Option | Purpose |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `base` | Always-applied class names |
|
|
75
|
+
| `variants` | Named groups of conditional classes |
|
|
76
|
+
| `defaultVariants` | Fallbacks when a variant is omitted |
|
|
77
|
+
| second argument | Extra class names appended to the result |
|
|
78
|
+
|
|
79
|
+
The utility does not know about CSS. Provide matching selectors in your own stylesheet, or use it alongside Pimolu's published styles.
|
|
80
|
+
|
|
81
|
+
## The package family
|
|
82
|
+
|
|
83
|
+
| Package | Role |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| [`@pimolu/react`](https://www.npmjs.com/package/@pimolu/react) | React components, hooks and layouts |
|
|
86
|
+
| [`@pimolu/web-styles`](https://www.npmjs.com/package/@pimolu/web-styles) | Plain CSS bundle, layered entry and per-component CSS |
|
|
87
|
+
| [`@pimolu/themes`](https://www.npmjs.com/package/@pimolu/themes) | Light/dark themes, seven presets and visual data |
|
|
88
|
+
| [`@pimolu/design-tokens`](https://www.npmjs.com/package/@pimolu/design-tokens) | Primitive tokens in CSS and JSON |
|
|
89
|
+
| [`@pimolu/core`](https://www.npmjs.com/package/@pimolu/core) | Framework-independent variant class utility |
|
|
90
|
+
|
|
91
|
+
## Documentation and status
|
|
92
|
+
|
|
93
|
+
- [Component catalogue](https://pimolu.com/components)
|
|
94
|
+
- [Source and issues](https://github.com/pimoludev/ui)
|
|
95
|
+
|
|
96
|
+
Pimolu UI is a beta. The React registry is implemented; native, Angular and web-component registries are future directions. The core utility is intentionally small and has no Pimolu-specific runtime behavior.
|
|
97
|
+
|
|
98
|
+
MIT © Pimolu
|