create-nuclo 0.3.36 → 0.3.38
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/package.json
CHANGED
|
@@ -9,6 +9,15 @@ npm install
|
|
|
9
9
|
npm run dev
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
## What's inside
|
|
13
|
+
|
|
14
|
+
- `index.html` — the page; the app is drawn into `<div id="app">`
|
|
15
|
+
- `src/main.ts` — starts the app
|
|
16
|
+
- `src/app.ts` — what the page shows, built from nuclo's tag functions
|
|
17
|
+
- `src/styles.ts` — how it looks: your colors and fonts, and one class per element
|
|
18
|
+
|
|
19
|
+
Start with `src/app.ts`. The [docs](https://nuclo.dev/en/docs) cover the rest.
|
|
20
|
+
|
|
12
21
|
## Scripts
|
|
13
22
|
|
|
14
23
|
- `npm run dev` — start the Vite dev server
|
|
@@ -1,38 +1,35 @@
|
|
|
1
1
|
import "nuclo";
|
|
2
|
-
import
|
|
3
|
-
import { styles
|
|
2
|
+
import nucloLogo from "nuclo/nuclo-logo";
|
|
3
|
+
import { styles } from "./styles";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// After import "nuclo", every HTML tag is a global function: main(), p(), a(), ...
|
|
6
|
+
// Pass it a class from styles.ts, an attributes object like { href }, and its children.
|
|
6
7
|
|
|
7
8
|
const links = [
|
|
8
|
-
{ href: "https://nuclo.dev/docs", title: "Docs", text: "Learn the API, from tags to SSR." },
|
|
9
|
-
{ href: "https://nuclo.dev/examples", title: "Examples", text: "Browse runnable apps and patterns." },
|
|
9
|
+
{ href: "https://nuclo.dev/en/docs", title: "Docs", text: "Learn the API, from tags to SSR." },
|
|
10
|
+
{ href: "https://nuclo.dev/en/examples", title: "Examples", text: "Browse runnable apps and patterns." },
|
|
10
11
|
{ href: "https://github.com/dan2dev/nuclo", title: "GitHub", text: "Read the source and report issues." },
|
|
11
12
|
];
|
|
12
13
|
|
|
13
|
-
export const App = () =>
|
|
14
|
-
|
|
14
|
+
export const App = () =>
|
|
15
|
+
main(
|
|
16
|
+
styles.page,
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
button(
|
|
21
|
-
s.button,
|
|
22
|
-
{ onClick: () => { count++; update(); } },
|
|
23
|
-
() => `Count is ${count}`,
|
|
18
|
+
section(
|
|
19
|
+
styles.hero,
|
|
20
|
+
nucloLogo({ height: 72 }, styles.logo),
|
|
21
|
+
p(styles.message, "Your app is ready. Start building in ", code(styles.code, "src/app.ts"), "."),
|
|
24
22
|
),
|
|
25
|
-
),
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
nav(
|
|
25
|
+
styles.links,
|
|
26
|
+
...links.map((link) =>
|
|
27
|
+
a(
|
|
28
|
+
styles.link,
|
|
29
|
+
{ href: link.href, target: "_blank", rel: "noopener noreferrer" },
|
|
30
|
+
strong(styles.linkTitle, link.title, span(styles.arrow, { "aria-hidden": "true" }, "↗")),
|
|
31
|
+
span(styles.linkText, link.text),
|
|
32
|
+
),
|
|
35
33
|
),
|
|
36
34
|
),
|
|
37
|
-
)
|
|
38
|
-
);
|
|
35
|
+
);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "nuclo";
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
|
|
3
|
+
// Your design tokens. Inside css() you can write color: "textMuted" instead of the hex value,
|
|
4
|
+
// and wide: { ... } for styles that apply only on screens at least 40rem wide.
|
|
5
|
+
export const { css, globalStyle } = createCss({
|
|
5
6
|
colors: {
|
|
6
7
|
text: "#0b0d12",
|
|
7
8
|
textMuted: "#5e6673",
|
|
@@ -9,107 +10,92 @@ export const { css, globalStyle, keyframes } = createCss({
|
|
|
9
10
|
surface: "#f7f7f8",
|
|
10
11
|
border: "rgba(16, 18, 24, 0.1)",
|
|
11
12
|
accent: "#c42800",
|
|
12
|
-
primary: "#d92d00",
|
|
13
|
-
primaryHover: "#c42800",
|
|
14
13
|
},
|
|
15
14
|
fonts: {
|
|
16
15
|
body: "system-ui, -apple-system, sans-serif",
|
|
16
|
+
mono: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
17
|
+
},
|
|
18
|
+
screens: {
|
|
19
|
+
wide: "(min-width: 40rem)",
|
|
17
20
|
},
|
|
18
21
|
});
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
globalStyle("body", {
|
|
23
|
-
m: 0,
|
|
24
|
-
font: "body",
|
|
25
|
-
leading: 1.6,
|
|
26
|
-
color: "text",
|
|
27
|
-
bg: "background",
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const focusRing = { outline: "2px solid", outlineColor: "accent", outlineOffset: 3 } as const;
|
|
31
|
-
|
|
32
|
-
const rise = keyframes({
|
|
33
|
-
from: { opacity: 0, transform: "translateY(0.75rem)" },
|
|
34
|
-
to: { opacity: 1, transform: "none" },
|
|
35
|
-
});
|
|
23
|
+
// Styles for plain HTML elements.
|
|
24
|
+
globalStyle("*", { boxSizing: "border-box" });
|
|
25
|
+
globalStyle("body", { m: 0, font: "body", leading: 1.6, color: "text", bg: "background" });
|
|
36
26
|
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
// A dotted grid behind the logo, fading out toward the edges.
|
|
28
|
+
globalStyle("body::before", {
|
|
29
|
+
content: '""',
|
|
30
|
+
position: "fixed",
|
|
31
|
+
inset: 0,
|
|
32
|
+
zIndex: -1,
|
|
33
|
+
backgroundImage: "radial-gradient(rgba(16, 18, 24, 0.12) 1px, transparent 1px)",
|
|
34
|
+
backgroundSize: "22px 22px",
|
|
35
|
+
raw: { "mask-image": "radial-gradient(ellipse 50% 45% at 50% 38%, #000, transparent)" },
|
|
41
36
|
});
|
|
42
37
|
|
|
38
|
+
// Each css() call returns a class. Pass it to a tag: main(styles.page, ...).
|
|
43
39
|
export const styles = {
|
|
44
40
|
page: css({
|
|
45
41
|
col: true,
|
|
46
42
|
items: "center",
|
|
47
43
|
justify: "center",
|
|
48
|
-
gap: "
|
|
44
|
+
gap: "3.5rem",
|
|
49
45
|
minH: "100svh",
|
|
50
|
-
maxW: "
|
|
46
|
+
maxW: "44rem",
|
|
51
47
|
mx: "auto",
|
|
52
48
|
px: "1.5rem",
|
|
53
49
|
py: "4rem",
|
|
54
50
|
}),
|
|
55
51
|
|
|
56
|
-
|
|
52
|
+
hero: css({ col: true, items: "center", gap: "1.5rem", align: "center" }),
|
|
57
53
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
logo: css({ maxW: "100%", h: "auto", filter: "drop-shadow(0 18px 24px rgba(255, 63, 0, 0.22))" }),
|
|
55
|
+
|
|
56
|
+
message: css({ m: 0, text: "0.9375rem", color: "textMuted", raw: { "text-wrap": "balance" } }),
|
|
57
|
+
|
|
58
|
+
code: css({
|
|
59
|
+
font: "mono",
|
|
60
|
+
text: "0.875em",
|
|
61
|
+
color: "text",
|
|
66
62
|
bg: "surface",
|
|
67
63
|
border: "1px solid",
|
|
68
64
|
borderColor: "border",
|
|
69
|
-
rounded:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
button: css({
|
|
73
|
-
minW: "10rem",
|
|
74
|
-
minH: "2.75rem",
|
|
75
|
-
px: "1.5rem",
|
|
76
|
-
border: "none",
|
|
77
|
-
rounded: 9999,
|
|
78
|
-
text: "1rem",
|
|
79
|
-
weight: 700,
|
|
80
|
-
fontVariantNumeric: "tabular-nums",
|
|
81
|
-
color: "#ffffff",
|
|
82
|
-
bg: "primary",
|
|
83
|
-
cursor: "pointer",
|
|
84
|
-
transition: "background-color 0.15s, transform 0.15s",
|
|
85
|
-
hover: { bg: "primaryHover" },
|
|
86
|
-
active: { transform: "scale(0.97)" },
|
|
87
|
-
focusVisible: focusRing,
|
|
65
|
+
rounded: 6,
|
|
66
|
+
px: "0.4em",
|
|
67
|
+
py: "0.1em",
|
|
88
68
|
}),
|
|
89
69
|
|
|
70
|
+
// One panel for all the links. The 1px gap between them shows the panel's
|
|
71
|
+
// background, which draws the dividers. Stacked on phones, side by side when wide.
|
|
90
72
|
links: css({
|
|
91
|
-
...intro(1.2),
|
|
92
73
|
display: "grid",
|
|
93
|
-
|
|
94
|
-
gap: "1rem",
|
|
74
|
+
gap: "1px",
|
|
95
75
|
w: "100%",
|
|
76
|
+
bg: "border",
|
|
77
|
+
border: "1px solid",
|
|
78
|
+
borderColor: "border",
|
|
79
|
+
rounded: 16,
|
|
80
|
+
overflow: "hidden",
|
|
81
|
+
boxShadow: "0 24px 60px -36px rgba(15, 23, 42, 0.25)",
|
|
82
|
+
wide: { gridTemplateColumns: "repeat(3, 1fr)" },
|
|
96
83
|
}),
|
|
97
84
|
|
|
98
85
|
link: css({
|
|
99
86
|
col: true,
|
|
100
87
|
gap: "0.25rem",
|
|
101
88
|
p: "1.25rem",
|
|
102
|
-
border: "1px solid",
|
|
103
|
-
borderColor: "border",
|
|
104
|
-
rounded: 12,
|
|
105
89
|
color: "text",
|
|
90
|
+
bg: "background",
|
|
106
91
|
textDecoration: "none",
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
focusVisible: focusRing,
|
|
92
|
+
hover: { bg: "surface" },
|
|
93
|
+
focusVisible: { outline: "2px solid", outlineColor: "accent", outlineOffset: -2 },
|
|
110
94
|
}),
|
|
111
95
|
|
|
96
|
+
linkTitle: css({ row: true, justify: "space-between", weight: 650 }),
|
|
97
|
+
|
|
112
98
|
arrow: css({ color: "accent" }),
|
|
113
99
|
|
|
114
|
-
linkText: css({ text: "0.875rem", color: "textMuted" }),
|
|
100
|
+
linkText: css({ text: "0.875rem", leading: 1.5, color: "textMuted" }),
|
|
115
101
|
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import "nuclo";
|
|
2
|
-
import { styles as s } from "./styles";
|
|
3
|
-
|
|
4
|
-
// The Nuclo mark, drawn the way nuclo.dev draws it: a Spirograph wheel rolls inside a ring and
|
|
5
|
-
// two pens on the wheel trace the mark and its play triangle, then the ink sets.
|
|
6
|
-
// Every animated value is a plain variable read by a () => attribute; update("logo") repaints
|
|
7
|
-
// only this svg each frame.
|
|
8
|
-
|
|
9
|
-
const N = 360; // points per pen lap
|
|
10
|
-
const R = 96; // the fixed ring
|
|
11
|
-
const r = 32; // the rolling wheel: R / r = 3 gives three lobes
|
|
12
|
-
const S = 88 / (R - r + 90); // fits the mark in the 200 × 200 box
|
|
13
|
-
const DRAW = 1.4; // seconds for one lap of the wheel
|
|
14
|
-
const INK = 0.2; // seconds for the ink to set
|
|
15
|
-
|
|
16
|
-
// One lap of a pen at distance d from the wheel's center
|
|
17
|
-
const lap = (d: number) =>
|
|
18
|
-
Array.from({ length: N + 1 }, (_, i) => {
|
|
19
|
-
const t = (i / N) * 2 * Math.PI;
|
|
20
|
-
const u = ((R - r) / r) * t;
|
|
21
|
-
return [100 + S * ((R - r) * Math.cos(t) + d * Math.cos(u)), 100 + S * ((R - r) * Math.sin(t) - d * Math.sin(u))];
|
|
22
|
-
});
|
|
23
|
-
const hub = lap(0);
|
|
24
|
-
const shape = lap(90);
|
|
25
|
-
const play = lap(12);
|
|
26
|
-
|
|
27
|
-
let k = 0; // points drawn so far
|
|
28
|
-
let ink = 0; // 0 → 1 once the outline is closed
|
|
29
|
-
|
|
30
|
-
const path = (pts: number[][]) =>
|
|
31
|
-
"M" + pts.slice(0, k + 1).map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`).join("L") + (k === N ? "Z" : "");
|
|
32
|
-
|
|
33
|
-
function draw() {
|
|
34
|
-
if (matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
35
|
-
k = N;
|
|
36
|
-
ink = 1;
|
|
37
|
-
return update("logo");
|
|
38
|
-
}
|
|
39
|
-
const start = performance.now();
|
|
40
|
-
const frame = (now: number) => {
|
|
41
|
-
const t = (now - start) / 1000;
|
|
42
|
-
k = Math.round((0.5 - Math.cos(Math.PI * Math.min(1, t / DRAW)) / 2) * N);
|
|
43
|
-
ink = Math.min(1, Math.max(0, (t - DRAW) / INK));
|
|
44
|
-
update("logo");
|
|
45
|
-
if (ink < 1) requestAnimationFrame(frame);
|
|
46
|
-
};
|
|
47
|
-
requestAnimationFrame(frame);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const arm = (pts: number[][]) =>
|
|
51
|
-
lineSvg({ x1: () => hub[k][0], y1: () => hub[k][1], x2: () => pts[k][0], y2: () => pts[k][1] });
|
|
52
|
-
|
|
53
|
-
const pen = (pts: number[][]) =>
|
|
54
|
-
circleSvg({ cx: () => pts[k][0], cy: () => pts[k][1], r: 5, fill: "currentColor", stroke: "#f26a2e", "stroke-width": 1.5, opacity: () => 1 - ink });
|
|
55
|
-
|
|
56
|
-
const trace = (pts: number[][], fill: string) =>
|
|
57
|
-
pathSvg({ d: () => path(pts), fill, "fill-opacity": () => ink, stroke: "#f26a2e", "stroke-width": 2, "stroke-opacity": () => 1 - ink });
|
|
58
|
-
|
|
59
|
-
export const Logo = () => svgSvg(
|
|
60
|
-
s.logo,
|
|
61
|
-
{ viewBox: "0 0 200 200", width: 128, height: 128, role: "img", "aria-label": "Nuclo", onMount: draw },
|
|
62
|
-
scope("logo"),
|
|
63
|
-
defsSvg(
|
|
64
|
-
linearGradientSvg(
|
|
65
|
-
{ id: "nuclo-fill", x1: 0, y1: 0, x2: 0, y2: 1 },
|
|
66
|
-
stopSvg({ offset: "0", "stop-color": "#ea3f25" }),
|
|
67
|
-
stopSvg({ offset: "1", "stop-color": "#ed6a2c" }),
|
|
68
|
-
),
|
|
69
|
-
),
|
|
70
|
-
// The ring, the wheel and its arms fade out as the ink sets
|
|
71
|
-
gSvg(
|
|
72
|
-
{ fill: "none", stroke: "#f26a2e", "stroke-width": 2, opacity: () => 1 - ink },
|
|
73
|
-
circleSvg({ cx: 100, cy: 100, r: R * S, "stroke-opacity": 0.25 }),
|
|
74
|
-
circleSvg({ cx: () => hub[k][0], cy: () => hub[k][1], r: r * S }),
|
|
75
|
-
arm(shape),
|
|
76
|
-
arm(play),
|
|
77
|
-
),
|
|
78
|
-
trace(shape, "url(#nuclo-fill)"),
|
|
79
|
-
trace(play, "#111"),
|
|
80
|
-
pen(shape),
|
|
81
|
-
pen(play),
|
|
82
|
-
);
|