@flanksource/clicky-ui 0.1.0

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 ADDED
@@ -0,0 +1,17 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ Copyright (c) Flanksource
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # @flanksource/clicky-ui
2
+
3
+ Flanksource's React component library built on [shadcn/ui](https://ui.shadcn.com/) with light/dark theming and density presets.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @flanksource/clicky-ui react react-dom tailwindcss
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { Button, ThemeProvider, DensityProvider } from "@flanksource/clicky-ui";
15
+ import "@flanksource/clicky-ui/styles.css";
16
+
17
+ export function App() {
18
+ return (
19
+ <ThemeProvider>
20
+ <DensityProvider>
21
+ <Button variant="default">Click me</Button>
22
+ </DensityProvider>
23
+ </ThemeProvider>
24
+ );
25
+ }
26
+ ```
27
+
28
+ ## Clicky AST Renderer
29
+
30
+ ```tsx
31
+ import { Clicky, type ClickyDocument } from "@flanksource/clicky-ui";
32
+
33
+ const document: ClickyDocument = {
34
+ version: 1,
35
+ node: {
36
+ kind: "text",
37
+ text: "hello from clicky",
38
+ plain: "hello from clicky",
39
+ },
40
+ };
41
+
42
+ export function ClickyPanel() {
43
+ return <Clicky data={document} />;
44
+ }
45
+ ```
46
+
47
+ `Clicky` also accepts a JSON string payload. The intended producer is the sibling `clicky` repo's tagged `html-react` AST, which preserves structural types such as trees, tables, code blocks, collapsed sections, buttons, and nested text content.
48
+
49
+ ## Tailwind preset
50
+
51
+ ```ts
52
+ // tailwind.config.ts
53
+ import preset from "@flanksource/clicky-ui/tailwind-preset";
54
+
55
+ export default {
56
+ presets: [preset],
57
+ content: ["./src/**/*.{ts,tsx}"],
58
+ };
59
+ ```
60
+
61
+ The preset wires up:
62
+
63
+ - Theme tokens via `[data-theme="light" | "dark"]` attributes on `<html>`.
64
+ - Density variants via `[data-density="compact" | "comfortable" | "spacious"]`.
65
+ - Spacing utilities (`gap-density-2`, `p-density-4`, etc.) scaled by the active density.
66
+
67
+ ## Theming
68
+
69
+ ```tsx
70
+ const { theme, resolvedTheme, setTheme } = useTheme();
71
+ const { density, setDensity } = useDensity();
72
+ ```
73
+
74
+ Both hooks persist their choice to `localStorage` under `clicky-ui-theme` / `clicky-ui-density`. Add this inline script to `<head>` to avoid FOUC:
75
+
76
+ ```html
77
+ <script>
78
+ (function () {
79
+ try {
80
+ var t = localStorage.getItem("clicky-ui-theme") || "system";
81
+ var d = localStorage.getItem("clicky-ui-density") || "comfortable";
82
+ var resolved =
83
+ t === "system"
84
+ ? window.matchMedia("(prefers-color-scheme: dark)").matches
85
+ ? "dark"
86
+ : "light"
87
+ : t;
88
+ document.documentElement.setAttribute("data-theme", resolved);
89
+ document.documentElement.setAttribute("data-density", d);
90
+ } catch (_) {}
91
+ })();
92
+ </script>
93
+ ```
94
+
95
+ ## License
96
+
97
+ Apache-2.0