@domphy/ui 0.1.2 → 0.1.4

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 CHANGED
@@ -1,69 +1,74 @@
1
- # @domphy/ui
2
-
3
- ~60 ready-to-use patches for Domphy — buttons, inputs, dialogs, tooltips, tabs, and more. Includes `@domphy/core` and `@domphy/theme`.
4
-
5
- ```bash
6
- npm install @domphy/ui
7
- ```
8
-
9
- ## What is a Patch?
10
-
11
- A Patch is a function that returns a partial element descriptor. It augments a native HTML element without wrapping or owning it. The element's own properties always win.
12
-
13
- ```ts
14
- import { ElementNode } from "@domphy/core"
15
- import { themeApply } from "@domphy/theme"
16
- import { button, tooltip, tabs } from "@domphy/ui"
17
-
18
- themeApply()
19
-
20
- const App = {
21
- div: [
22
- {
23
- button: "Save",
24
- $: [button(), tooltip({ content: "Save changes" })]
25
- }
26
- ],
27
- dataTheme: "light"
28
- }
29
-
30
- new ElementNode(App).render(document.body)
31
- ```
32
-
33
- ## Customization via ownership
34
-
35
- Every patch ships as readable source. To fully customize, copy the patch into your project and modify it directly — no configuration API to work around.
36
-
37
- ```ts
38
- import { toState, merge } from "@domphy/core"
39
- import { themeColor, themeSpacing, themeSize } from "@domphy/theme"
40
-
41
- // your own patch — full control
42
- function myButton() {
43
- return (base) => merge(base, {
44
- style: {
45
- fontSize: (l) => themeSize(l, "inherit"),
46
- padding: `${themeSpacing(1)} ${themeSpacing(3)}`,
47
- borderRadius: themeSpacing(2),
48
- backgroundColor: (l) => themeColor(l, "inherit", "primary"),
49
- color: (l) => themeColor(l, "shift-6", "primary"),
50
- "&:hover": {
51
- backgroundColor: (l) => themeColor(l, "increase-1", "primary"),
52
- },
53
- }
54
- })
55
- }
56
- ```
57
-
58
- ## CDN
59
-
60
- ```html
61
- <script src="https://unpkg.com/@domphy/ui/dist/core-theme-ui.global.js"></script>
62
- <script>
63
- const { core, theme, ui } = Domphy
64
- </script>
65
- ```
66
-
67
- ---
68
-
69
- **[Full documentation →](https://www.domphy.com/docs/ui/)**
1
+ # @domphy/ui
2
+
3
+ Ready-made patches for Domphy.
4
+
5
+ `@domphy/ui` includes `@domphy/core` and `@domphy/theme`, and provides patches for buttons, inputs, dialogs, menus, tabs, tooltips, and more.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @domphy/ui
11
+ ```
12
+
13
+ ## Quick Example
14
+
15
+ ```ts
16
+ import { ElementNode } from "@domphy/core"
17
+ import { themeApply } from "@domphy/theme"
18
+ import { button, tooltip } from "@domphy/ui"
19
+
20
+ themeApply()
21
+
22
+ const App = {
23
+ div: [
24
+ {
25
+ button: "Save",
26
+ $: [
27
+ button({ color: "primary" }),
28
+ tooltip({ content: "Save changes" }),
29
+ ],
30
+ },
31
+ ],
32
+ dataTheme: "light",
33
+ }
34
+
35
+ new ElementNode(App).render(document.body)
36
+ ```
37
+
38
+ ## What A Patch Is
39
+
40
+ A patch returns a `PartialElement` and merges into a native element.
41
+
42
+ It does not create a wrapper component or own a separate DOM boundary.
43
+
44
+ ```ts
45
+ {
46
+ button: "Save",
47
+ $: [button()],
48
+ }
49
+ ```
50
+
51
+ ## Customization
52
+
53
+ Most customization should happen in one of these ways:
54
+
55
+ 1. pass patch props
56
+ 2. use `dataTone` or `dataSize` context
57
+ 3. override inline on the element
58
+ 4. copy the patch into your app and create your own variant
59
+
60
+ ## CDN
61
+
62
+ ```html
63
+ <script src="https://unpkg.com/@domphy/ui/dist/core-theme-ui.global.js"></script>
64
+ <script>
65
+ const { core, theme, ui } = Domphy
66
+ </script>
67
+ ```
68
+
69
+ ## Docs
70
+
71
+ - [UI guide](https://www.domphy.com/docs/ui/)
72
+ - [Customization](https://www.domphy.com/docs/ui/customization)
73
+ - [Creation](https://www.domphy.com/docs/ui/creation)
74
+ - [Patch catalog](https://www.domphy.com/docs/ui/patches/button)