@gild-ui/core 0.0.0 → 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +122 -1
- package/dist/View-CL3vORfe.mjs +4914 -0
- package/dist/View-DOvf12An.cjs +6017 -0
- package/dist/breakpoints.cjs +110 -0
- package/dist/breakpoints.d.cts +65 -0
- package/dist/breakpoints.d.mts +2 -0
- package/dist/breakpoints.mjs +103 -0
- package/dist/catalog/entries.cjs +186 -0
- package/dist/catalog/entries.d.cts +4428 -0
- package/dist/catalog/entries.d.mts +4428 -0
- package/dist/catalog/entries.mjs +1 -0
- package/dist/catalog.cjs +1198 -0
- package/dist/catalog.d.cts +2 -0
- package/dist/catalog.d.mts +2 -0
- package/dist/catalog.mjs +1196 -0
- package/dist/index-BVkniYfB.d.mts +66 -0
- package/dist/index-CfaKnMOm.d.cts +106 -0
- package/dist/index-wAxAZHia.d.mts +106 -0
- package/dist/theme.cjs +478 -0
- package/dist/theme.d.cts +246 -0
- package/dist/theme.d.mts +246 -0
- package/dist/theme.mjs +451 -0
- package/dist/themeDefault-CjYwGUsb.cjs +74 -0
- package/dist/themeDefault-DBAILYB-.mjs +45 -0
- package/dist/types-DIyGsvvF.d.cts +411 -0
- package/dist/types-DRIGCQQY.d.mts +411 -0
- package/dist/utils.cjs +63 -0
- package/dist/utils.d.cts +40 -0
- package/dist/utils.d.mts +40 -0
- package/dist/utils.mjs +51 -0
- package/package.json +119 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Masoud Soroush <https://soroush.tech>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,124 @@
|
|
|
1
1
|
# @gild-ui/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@gild-ui/core)
|
|
4
|
+
[](https://app.codecov.io/gh/soroush-tech/design-system?flags%5B0%5D=core)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
7
|
+
What every platform of the Gild UI family shares and that needs no framework. The React,
|
|
8
|
+
React Native and Vue libraries build on it, and an app installs it to write its own theme with
|
|
9
|
+
`createTheme` and `defineThemes`. It holds the theme
|
|
10
|
+
(the tokens, `baseTheme`, `createTheme`), the breakpoint and container-query helpers, the pure
|
|
11
|
+
utilities, and the component catalog.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm i @gild-ui/core
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Its one dependency is `@umber-style/core`, the styling engine's core, which knows no framework: the
|
|
18
|
+
base theme marks the parts that are not CSS values with its `asIs()` and `defineTheme`, so the theme
|
|
19
|
+
carries `$modes` as plain data. It imports no React, React Native, Vue, DOM API or framework binding
|
|
20
|
+
of the engine, and a test fails when it does.
|
|
21
|
+
|
|
22
|
+
## The theme
|
|
23
|
+
|
|
24
|
+
One theme, read by every platform: the token scales (`palette`, `space`, `radii`, `typography`,
|
|
25
|
+
`breakpoints`, `transitions`, ...), `baseTheme`, `createTheme`, the `Theme` types and the component
|
|
26
|
+
defaults. It imports no framework: a platform library composes its own `Theme` on top of this one.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { baseTheme, createTheme } from '@gild-ui/core/theme'
|
|
30
|
+
|
|
31
|
+
const brand = createTheme(baseTheme, { palette: { primary: { main: '#0a7' } } })
|
|
32
|
+
brand.palette.primary.main // '#0a7'
|
|
33
|
+
brand.breakpoints.up('md') // '@media (width >= 840px)'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`createTheme` deep-merges a sparse override onto a base theme, keeps arrays and functions whole,
|
|
37
|
+
never mutates its arguments, and returns the base's own type, so a platform's extended theme comes
|
|
38
|
+
back as itself. `themeDefault(theme, key, fallback)` reads a component default the theme may
|
|
39
|
+
override, and `spacing(units)` steps the 8px unit.
|
|
40
|
+
|
|
41
|
+
Every scale is an open interface: declare it again to add a token, and the keys reach each
|
|
42
|
+
platform's components.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import type { PaletteEntry } from '@gild-ui/core/theme'
|
|
46
|
+
|
|
47
|
+
declare module '@gild-ui/core/theme' {
|
|
48
|
+
interface ThemePalette {
|
|
49
|
+
brand: PaletteEntry
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Breakpoints
|
|
55
|
+
|
|
56
|
+
`@gild-ui/core/breakpoints` holds the helpers behind `theme.breakpoints`:
|
|
57
|
+
`createMediaHelpers` and `createContainerQueries` return `up`, `down`, `only`, `between` and `not`
|
|
58
|
+
as range-syntax `@media` or `@container` rules, and `withBreakpointHelpers` attaches them to a
|
|
59
|
+
scale. They are pure string functions; `@soroush.tech/styled-system` has a copy of its own.
|
|
60
|
+
|
|
61
|
+
## Utilities
|
|
62
|
+
|
|
63
|
+
`@gild-ui/core/utils` holds pure helpers: `clamp`, `alpha`, `luminance`,
|
|
64
|
+
`generateBoxShadow`, `getAnchorRel`, `getShapeRadius`, `getSurfaceRadius` and the step arithmetic
|
|
65
|
+
of `precision`.
|
|
66
|
+
|
|
67
|
+
## The catalog
|
|
68
|
+
|
|
69
|
+
Every component as data, for tools that place and write components rather than render them: a
|
|
70
|
+
design tool's palette, a page's source writer, a generator. It loads in plain Node and survives
|
|
71
|
+
`JSON.stringify` unchanged.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { catalog } from '@gild-ui/core/catalog'
|
|
75
|
+
|
|
76
|
+
catalog.components.Select.subpath // 'Select'
|
|
77
|
+
catalog.components.Select.example // { component: 'Select', props: { placeholder: ... }, children: [...] }
|
|
78
|
+
catalog.components.Select.options.color // { scale: 'palette', default: 'primary' }
|
|
79
|
+
catalog.styleScales.p // 'space'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
| Field | What it is |
|
|
83
|
+
| ------------- | -------------------------------------------------------------------------------------------- |
|
|
84
|
+
| `categories` | The docs' categories, in their order, each with its components. |
|
|
85
|
+
| `styleScales` | Each style prop that reads a theme scale, and that scale: `p` to `space`, `color` to `text`. |
|
|
86
|
+
| `components` | One entry per component, keyed by its export name. |
|
|
87
|
+
|
|
88
|
+
An entry has the `name`, the `subpath` a platform library serves it from, its `category`, a
|
|
89
|
+
`summary`, whether a palette offers it (`isPlaceable`), its `example` and `variants` as nodes, the
|
|
90
|
+
`options` a picker offers, how its node props are written (`content`), a `twoWay` prop and its
|
|
91
|
+
`domEvents` when it has them, and the `preview` room its picture needs.
|
|
92
|
+
|
|
93
|
+
A node is `{ component, props, children }`, its children more nodes or text - the shape a tool
|
|
94
|
+
writes into source: `{ component: 'MenuItem', props: { value: 'web' }, children: ['Web'] }` is
|
|
95
|
+
`<MenuItem value="web">Web</MenuItem>`.
|
|
96
|
+
|
|
97
|
+
### What a platform adds
|
|
98
|
+
|
|
99
|
+
An entry says where a component lives inside a platform library, not which package. The platform's
|
|
100
|
+
library re-exports the catalog and adds its own facts. The React component library adds `module`:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { catalog } from '@gild-ui/react/catalog'
|
|
104
|
+
|
|
105
|
+
catalog.components.Select.module // '@gild-ui/react/Select'
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### The entries
|
|
109
|
+
|
|
110
|
+
`@gild-ui/core/catalog/entries` exports each component's entry as it is written
|
|
111
|
+
(`selectCatalog`) and the lists of values its props take (`selectVariantValues`), for the stories and
|
|
112
|
+
demos of a platform library, which read their option lists from the same arrays so that a story and
|
|
113
|
+
the catalog cannot disagree.
|
|
114
|
+
|
|
115
|
+
### Adding a component
|
|
116
|
+
|
|
117
|
+
Write `src/catalog/entries/ComponentName.ts` with `defineCatalogEntry`, and register it in
|
|
118
|
+
`src/catalog/sources.ts` with the subpath it is imported from and, for a member of a family, its
|
|
119
|
+
family. The tests hold the catalog to the docs: every component the docs list has an entry, every
|
|
120
|
+
entry is listed, every example names components the catalog has.
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|