@abraca/junis 2.84.0 → 2.85.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/dist/module.json +1 -1
- package/dist/module.mjs +35 -3
- package/dist/runtime/assets/css/jun.css +1 -1
- package/dist/runtime/components/JunBlobBackdrop.client.vue +1 -1
- package/dist/runtime/components/JunHead.vue +37 -5
- package/dist/runtime/components/JunLogo.vue +10 -45
- package/dist/runtime/components/JunPatternBackdrop.client.vue +1 -1
- package/dist/runtime/components/JunShaderBackdrop.client.vue +1 -1
- package/dist/runtime/components/renderers/JunConfigRenderer.vue +14 -14
- package/dist/runtime/components/renderers/JunEntryRenderer.vue +6 -8
- package/dist/runtime/components/renderers/JunFestivalRenderer.vue +1 -1
- package/dist/runtime/components/renderers/JunHomeRenderer.vue +3 -3
- package/dist/runtime/components/renderers/JunLiveRenderer.vue +1 -1
- package/dist/runtime/components/renderers/JunNowRenderer.vue +2 -2
- package/dist/runtime/components/renderers/JunUsesRenderer.vue +6 -8
- package/dist/runtime/composables/useJunOptions.d.ts +1 -0
- package/dist/runtime/composables/useJunTheme.js +9 -48
- package/dist/runtime/plugins/jun-sw.client.d.ts +2 -0
- package/dist/runtime/plugins/jun-sw.client.js +36 -0
- package/dist/runtime/server/plugins/jun-janitor.js +2 -1
- package/dist/runtime/server/routes/jun-icon.png.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-icon.png.get.js +25 -0
- package/dist/runtime/server/routes/jun-icon.svg.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-icon.svg.get.js +9 -0
- package/dist/runtime/server/routes/jun-splash.png.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-splash.png.get.js +37 -0
- package/dist/runtime/server/routes/jun-sw.js.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-sw.js.get.js +126 -0
- package/dist/runtime/server/routes/manifest.webmanifest.get.d.ts +24 -0
- package/dist/runtime/server/routes/manifest.webmanifest.get.js +51 -0
- package/dist/runtime/server/utils/junBrand.d.ts +4 -0
- package/dist/runtime/server/utils/junBrand.js +9 -0
- package/dist/runtime/server/utils/junIcon.d.ts +44 -0
- package/dist/runtime/server/utils/junIcon.js +374 -0
- package/dist/runtime/types.d.ts +25 -2
- package/dist/runtime/utils/junIdentity.d.ts +121 -0
- package/dist/runtime/utils/junIdentity.js +115 -0
- package/dist/runtime/utils/junMark.d.ts +254 -0
- package/dist/runtime/utils/junMark.js +169 -0
- package/package.json +1 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The site mark, as DATA.
|
|
3
|
+
*
|
|
4
|
+
* `<JunLogo>` renders this; so does the favicon; so does the PNG rasteriser
|
|
5
|
+
* behind the app icons. Three renderers, one geometry — which is the whole
|
|
6
|
+
* reason this file exists. The mark used to live inside the component, so the
|
|
7
|
+
* only way to put it in a favicon was to draw it a second time by hand, and a
|
|
8
|
+
* second drawing is a second thing to keep in step.
|
|
9
|
+
*
|
|
10
|
+
* ⚠️ **ZERO IMPORTS, and it must stay that way.** This module is loaded from
|
|
11
|
+
* the app bundle (auto-imported through `runtime/utils`), from the Nitro
|
|
12
|
+
* bundle (relative import in the icon routes) and from a plain `node`
|
|
13
|
+
* process in the test suite. Anything reaching for `#imports`, `vue` or a
|
|
14
|
+
* Nitro virtual would take two of those three down.
|
|
15
|
+
*
|
|
16
|
+
* The colours are NOT here. A mark is a shape; what colour it is depends on the
|
|
17
|
+
* site's accent and the colour scheme, and both of those are resolved by the
|
|
18
|
+
* caller — `junThemeCss()` for the DOM, `junMarkColors()` for everything with
|
|
19
|
+
* no DOM to read.
|
|
20
|
+
*/
|
|
21
|
+
/** The one coordinate system every mark is drawn in. */
|
|
22
|
+
export declare const JUN_MARK_VIEWBOX = 48;
|
|
23
|
+
export type JunMarkName = 'sprout' | 'node' | 'page' | 'sun';
|
|
24
|
+
/** Every mark this build knows, in the order the settings picker lists them. */
|
|
25
|
+
export declare const JUN_MARK_NAMES: JunMarkName[];
|
|
26
|
+
/**
|
|
27
|
+
* A drawn mark: strokes first, nodes on top.
|
|
28
|
+
*
|
|
29
|
+
* `join` means "this stroke turns corners" — it gets a round LINEJOIN and the
|
|
30
|
+
* default butt cap, which is what a closed outline wants; everything else is a
|
|
31
|
+
* round-capped monoline.
|
|
32
|
+
*/
|
|
33
|
+
export interface JunMarkGeometry {
|
|
34
|
+
paths: {
|
|
35
|
+
d: string;
|
|
36
|
+
w: number;
|
|
37
|
+
join?: boolean;
|
|
38
|
+
}[];
|
|
39
|
+
/** Filled nodes, in the order `JunIntro` reveals them. Three, at most. */
|
|
40
|
+
dots: {
|
|
41
|
+
cx: number;
|
|
42
|
+
cy: number;
|
|
43
|
+
r: number;
|
|
44
|
+
}[];
|
|
45
|
+
}
|
|
46
|
+
export declare const JUN_MARKS: Record<Exclude<JunMarkName, 'sun'>, JunMarkGeometry>;
|
|
47
|
+
/**
|
|
48
|
+
* `sun`, derived from the dock blob rather than redrawn by eye.
|
|
49
|
+
*
|
|
50
|
+
* See `<JunLogo>`'s header for the full derivation (three nested DOM boxes at
|
|
51
|
+
* the CSS scale factor 48/32). What matters here is that the numbers are the
|
|
52
|
+
* SAME numbers: the favicon and the app icon are the navbar's mark at another
|
|
53
|
+
* size, not a lookalike.
|
|
54
|
+
*/
|
|
55
|
+
export declare const JUN_SUN: {
|
|
56
|
+
/** Body gradient, corner to corner of the 48-unit box. */
|
|
57
|
+
readonly body: {
|
|
58
|
+
readonly r: 24;
|
|
59
|
+
readonly cx: 24;
|
|
60
|
+
readonly cy: 24;
|
|
61
|
+
};
|
|
62
|
+
/** The white/contrasting core. */
|
|
63
|
+
readonly core: {
|
|
64
|
+
readonly r: 12;
|
|
65
|
+
readonly cx: 24;
|
|
66
|
+
readonly cy: 24;
|
|
67
|
+
};
|
|
68
|
+
/** The core's glow, pinned below-right and clipped by the core. */
|
|
69
|
+
readonly glow: {
|
|
70
|
+
readonly cx: 45;
|
|
71
|
+
readonly cy: 45;
|
|
72
|
+
readonly r: 46.67;
|
|
73
|
+
readonly clipR: 12;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* The core's soft ring — the blob's `box-shadow`, drawn as GEOMETRY rather
|
|
77
|
+
* than as a CSS `drop-shadow`, because a filter rasterises the subtree it
|
|
78
|
+
* applies to and a raster taken inside a composited layer is reused at that
|
|
79
|
+
* layer's scale.
|
|
80
|
+
*/
|
|
81
|
+
readonly halo: {
|
|
82
|
+
readonly r: 17;
|
|
83
|
+
readonly cx: 24;
|
|
84
|
+
readonly cy: 24;
|
|
85
|
+
readonly color: "#000000";
|
|
86
|
+
readonly inner: 0.22;
|
|
87
|
+
readonly mid: 0.1;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The four colours a mark can need, already resolved to something with no CSS
|
|
92
|
+
* context — a favicon and a PNG both render with no stylesheet in scope, so
|
|
93
|
+
* `var(--jun-sun-from)` is not an answer there.
|
|
94
|
+
*/
|
|
95
|
+
export interface JunMarkColors {
|
|
96
|
+
/** Monoline strokes and dots. `currentColor` in the DOM. */
|
|
97
|
+
ink: string;
|
|
98
|
+
sunFrom: string;
|
|
99
|
+
sunTo: string;
|
|
100
|
+
sunCore: string;
|
|
101
|
+
sunGlow: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The MONOCHROME site, per scheme — the values `jun.css` declares statically
|
|
105
|
+
* because there is no accent hex to derive an orb from. Near-black orb with a
|
|
106
|
+
* white core in light; inverted in dark, since a white orb with a white core is
|
|
107
|
+
* a featureless disc.
|
|
108
|
+
*
|
|
109
|
+
* These must stay identical to the `--jun-sun-*` block in `jun.css`. They are
|
|
110
|
+
* the same four numbers said twice — once for the DOM, once for everything with
|
|
111
|
+
* no stylesheet in scope — and `test/jun-mark.test.ts` compares them.
|
|
112
|
+
*/
|
|
113
|
+
export declare const JUN_MARK_MONO: Record<'light' | 'dark', JunMarkColors>;
|
|
114
|
+
/**
|
|
115
|
+
* Shift a hex toward black (`amount < 0`) or white (`amount > 0`).
|
|
116
|
+
*
|
|
117
|
+
* Straight channel interpolation rather than an HSL round-trip: the only job
|
|
118
|
+
* here is a second gradient stop that reads as the same colour under a slightly
|
|
119
|
+
* different light, and a hue-preserving lighten is exactly what a naive HSL
|
|
120
|
+
* lighten is NOT (it desaturates pale colours into white).
|
|
121
|
+
*/
|
|
122
|
+
export declare function junShade(hex: string, amount: number): string;
|
|
123
|
+
/** `#rgb` or `#rrggbb` → channel bytes. The rasteriser's only colour input. */
|
|
124
|
+
export declare function junHexToRgb(hex: string): [number, number, number];
|
|
125
|
+
/** Perceived brightness, 0–1. Rec. 601 weights — good enough to pick a core. */
|
|
126
|
+
export declare function junLuminance(hex: string): number;
|
|
127
|
+
/**
|
|
128
|
+
* The orb's colours. `core` is optional — derived by luminance when absent, and
|
|
129
|
+
* stated when an accent has an original to be faithful to. The house amber
|
|
130
|
+
* measures 0.72 bright, which the derivation would answer with a DARK core; the
|
|
131
|
+
* mark was drawn with a white one, and the mark is what that preset exists to
|
|
132
|
+
* reproduce.
|
|
133
|
+
*/
|
|
134
|
+
export interface JunOrbTriple {
|
|
135
|
+
from: string;
|
|
136
|
+
to: string;
|
|
137
|
+
core?: string;
|
|
138
|
+
glow: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Accent → light/dark `--ui-primary`. `mono` (absent here) keeps jun.css's
|
|
142
|
+
* black/white.
|
|
143
|
+
*
|
|
144
|
+
* `sun` additionally carries an explicit `orb`: the exact two-stop amber the
|
|
145
|
+
* `sun` mark was DRAWN in, lifted from the junis-desktop dock blob. Deriving it
|
|
146
|
+
* from the primary instead would land a few degrees off, and this is the one
|
|
147
|
+
* colour on the site that has an original to be faithful to.
|
|
148
|
+
*
|
|
149
|
+
* Its `--ui-primary` is a touch deeper than the orb on LIGHT, and that is not
|
|
150
|
+
* an inconsistency: `#ff9f00` on white is below every contrast floor, and this
|
|
151
|
+
* value paints links, focus rings and the loading bar. The orb, which is a
|
|
152
|
+
* filled disc rather than text, keeps the original exactly.
|
|
153
|
+
*
|
|
154
|
+
* Here rather than in `useJunTheme` because the favicon and the app icon need
|
|
155
|
+
* to answer "what colour is this site's mark" on the SERVER, where that
|
|
156
|
+
* composable does not load.
|
|
157
|
+
*/
|
|
158
|
+
export declare const JUN_ACCENTS: Record<string, {
|
|
159
|
+
light: string;
|
|
160
|
+
dark: string;
|
|
161
|
+
orb?: {
|
|
162
|
+
light: JunOrbTriple;
|
|
163
|
+
dark: JunOrbTriple;
|
|
164
|
+
};
|
|
165
|
+
}>;
|
|
166
|
+
/**
|
|
167
|
+
* The mark and its colours for BOTH schemes, resolved from a Site Config's
|
|
168
|
+
* theme keys — the one function the favicon, the manifest and the icon routes
|
|
169
|
+
* all call so they cannot disagree about what the site looks like.
|
|
170
|
+
*
|
|
171
|
+
* The precedence is the same one `junThemeCss()` applies: a custom hex beats
|
|
172
|
+
* the preset, either side alone falls back to the preset's value for the other
|
|
173
|
+
* scheme, and a custom hex overrides the preset's own orb (that is the owner
|
|
174
|
+
* speaking about this site).
|
|
175
|
+
*/
|
|
176
|
+
export declare function junMarkColorsFor(cfg: {
|
|
177
|
+
themeAccent?: unknown;
|
|
178
|
+
themeAccentCustomLight?: unknown;
|
|
179
|
+
themeAccentCustomDark?: unknown;
|
|
180
|
+
}): {
|
|
181
|
+
light: JunMarkColors;
|
|
182
|
+
dark: JunMarkColors;
|
|
183
|
+
};
|
|
184
|
+
/** A stored `brandLogo` value, validated against what this build can draw. */
|
|
185
|
+
export declare function junMarkName(value: unknown, fallback?: JunMarkName): JunMarkName;
|
|
186
|
+
/**
|
|
187
|
+
* The `sun` mark's four colours, from one accent hex.
|
|
188
|
+
*
|
|
189
|
+
* The mark is the site's accent stated as an object: a body gradient running
|
|
190
|
+
* from a slightly lifted accent to a slightly deeper one, a core, and an inner
|
|
191
|
+
* glow in the accent itself. The ~10% step between the two stops is what the
|
|
192
|
+
* hand-drawn original had — enough for the orb to read as lit from the upper
|
|
193
|
+
* left, not enough to look like two colours.
|
|
194
|
+
*
|
|
195
|
+
* **The core is chosen by the body's brightness, not by the colour scheme.**
|
|
196
|
+
* White on a pale orb is a featureless disc, and that is not a dark-mode
|
|
197
|
+
* problem — a site whose accent is a pale yellow has it in broad daylight.
|
|
198
|
+
*/
|
|
199
|
+
export declare function junSunColors(hex: string | undefined, orb?: JunOrbTriple): {
|
|
200
|
+
from: string;
|
|
201
|
+
to: string;
|
|
202
|
+
core: string;
|
|
203
|
+
glow: string;
|
|
204
|
+
} | null;
|
|
205
|
+
/**
|
|
206
|
+
* Resolve every colour a mark can need for ONE scheme, with no DOM.
|
|
207
|
+
*
|
|
208
|
+
* `accentHex` is the site's `--ui-primary` for that scheme; `orb` is a preset's
|
|
209
|
+
* explicitly stated orb. Pass neither and you get the monochrome mark, which is
|
|
210
|
+
* a real answer rather than a failure — a site with no accent still has a
|
|
211
|
+
* colour, and it is that one.
|
|
212
|
+
*/
|
|
213
|
+
export declare function junMarkColors(scheme: 'light' | 'dark', accentHex?: string, orb?: JunOrbTriple): JunMarkColors;
|
|
214
|
+
/**
|
|
215
|
+
* The mark's shapes, as SVG source, with every colour taken from CSS CLASSES
|
|
216
|
+
* rather than from presentation attributes.
|
|
217
|
+
*
|
|
218
|
+
* That is not a style preference. `var()` inside an SVG presentation attribute
|
|
219
|
+
* is not reliably supported (`<JunLogo>` carries the same note about
|
|
220
|
+
* `stop-color`), and a favicon has to answer BOTH colour schemes from one file
|
|
221
|
+
* — which means one set of shapes and two sets of rules. Classes are the only
|
|
222
|
+
* spelling that satisfies both.
|
|
223
|
+
*
|
|
224
|
+
* `id` prefixes the gradient ids. Two marks in one document with the same
|
|
225
|
+
* gradient id resolve to whichever came first; the favicon is alone in its
|
|
226
|
+
* file, but the app-icon path renders two (a maskable and a plain) and hit it.
|
|
227
|
+
*/
|
|
228
|
+
export declare function junMarkShapes(mark: JunMarkName, id?: string): string;
|
|
229
|
+
/**
|
|
230
|
+
* A complete, self-contained favicon.
|
|
231
|
+
*
|
|
232
|
+
* ONE file that answers both colour schemes, via an internal `@media
|
|
233
|
+
* (prefers-color-scheme: dark)` — supported by every browser that supports SVG
|
|
234
|
+
* favicons at all. The alternative is two `<link>`s with `media` attributes,
|
|
235
|
+
* which Safari ignores.
|
|
236
|
+
*
|
|
237
|
+
* The mark is inset by `pad` user units so a monoline mark is not clipped by
|
|
238
|
+
* the tab's own rounding, and the sun — which fills its box edge to edge by
|
|
239
|
+
* design — gets `pad: 0`.
|
|
240
|
+
*/
|
|
241
|
+
export declare function junFaviconSvg(mark: JunMarkName, light: JunMarkColors, dark: JunMarkColors): string;
|
|
242
|
+
/** `junFaviconSvg` as a `data:` URL, ready for `<link rel="icon" href>`. */
|
|
243
|
+
export declare function junFaviconDataUrl(mark: JunMarkName, light: JunMarkColors, dark: JunMarkColors): string;
|
|
244
|
+
/**
|
|
245
|
+
* A single-scheme mark on an optional solid tile — the shape an app icon takes.
|
|
246
|
+
*
|
|
247
|
+
* Used for the SVG any-size manifest icon and as the reference the PNG
|
|
248
|
+
* rasteriser is checked against.
|
|
249
|
+
*/
|
|
250
|
+
export declare function junIconSvg(mark: JunMarkName, colors: JunMarkColors, opts?: {
|
|
251
|
+
background?: string | null;
|
|
252
|
+
scale?: number;
|
|
253
|
+
radius?: number;
|
|
254
|
+
}): string;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
export const JUN_MARK_VIEWBOX = 48;
|
|
2
|
+
export const JUN_MARK_NAMES = ["sprout", "node", "page", "sun"];
|
|
3
|
+
export const JUN_MARKS = {
|
|
4
|
+
// The j/bang tree. The stem is centred on x=24 so the mark is optically
|
|
5
|
+
// centred in the box at every size, and the shoot leaves it at the same
|
|
6
|
+
// angle the hook exits — the two arms balance instead of one out-weighing
|
|
7
|
+
// the other, which is what made the old draw lean right.
|
|
8
|
+
sprout: {
|
|
9
|
+
paths: [
|
|
10
|
+
{ d: "M24 18v12.2c0 7.4-3.6 11.1-9.8 9", w: 3.4 },
|
|
11
|
+
{ d: "M24 25.4 32.6 18.6", w: 3.4 }
|
|
12
|
+
],
|
|
13
|
+
dots: [
|
|
14
|
+
{ cx: 24, cy: 9.6, r: 3.4 },
|
|
15
|
+
{ cx: 35.4, cy: 16.4, r: 2.8 },
|
|
16
|
+
{ cx: 11.2, cy: 38.2, r: 2.8 }
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
// The graph. Edges stop SHORT of each node and tuck under it, so the joins
|
|
20
|
+
// stay clean when the stroke is only a couple of device pixels wide.
|
|
21
|
+
node: {
|
|
22
|
+
paths: [
|
|
23
|
+
{ d: "M31.5 13.5V24.5", w: 3.2 },
|
|
24
|
+
{ d: "M29.2 28.6 18.9 35.2", w: 3.2 }
|
|
25
|
+
],
|
|
26
|
+
dots: [
|
|
27
|
+
{ cx: 31.5, cy: 10.8, r: 3.5 },
|
|
28
|
+
{ cx: 31.5, cy: 27.2, r: 3.5 },
|
|
29
|
+
{ cx: 16.6, cy: 36.6, r: 3.5 }
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
// The document, with the bang set inside it. The old three-stroke mini-tree
|
|
33
|
+
// in there turned to mush below ~20px; one stem and one dot survive it.
|
|
34
|
+
page: {
|
|
35
|
+
paths: [
|
|
36
|
+
{ d: "M13 6h14l8 8v28H13z", w: 3, join: true },
|
|
37
|
+
{ d: "M27 6v8h8", w: 3, join: true },
|
|
38
|
+
{ d: "M24 18v8.6", w: 3.2 }
|
|
39
|
+
],
|
|
40
|
+
dots: [
|
|
41
|
+
{ cx: 24, cy: 31.8, r: 2.2 }
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export const JUN_SUN = {
|
|
46
|
+
/** Body gradient, corner to corner of the 48-unit box. */
|
|
47
|
+
body: { r: 24, cx: 24, cy: 24 },
|
|
48
|
+
/** The white/contrasting core. */
|
|
49
|
+
core: { r: 12, cx: 24, cy: 24 },
|
|
50
|
+
/** The core's glow, pinned below-right and clipped by the core. */
|
|
51
|
+
glow: { cx: 45, cy: 45, r: 46.67, clipR: 12 },
|
|
52
|
+
/**
|
|
53
|
+
* The core's soft ring — the blob's `box-shadow`, drawn as GEOMETRY rather
|
|
54
|
+
* than as a CSS `drop-shadow`, because a filter rasterises the subtree it
|
|
55
|
+
* applies to and a raster taken inside a composited layer is reused at that
|
|
56
|
+
* layer's scale.
|
|
57
|
+
*/
|
|
58
|
+
halo: { r: 17, cx: 24, cy: 24, color: "#000000", inner: 0.22, mid: 0.1 }
|
|
59
|
+
};
|
|
60
|
+
export const JUN_MARK_MONO = {
|
|
61
|
+
light: { ink: "#18181b", sunFrom: "#24242a", sunTo: "#0f0f12", sunCore: "#ffffff", sunGlow: "#18181b" },
|
|
62
|
+
dark: { ink: "#fafafa", sunFrom: "#fafafa", sunTo: "#e4e4e7", sunCore: "#101013", sunGlow: "#f4f4f5" }
|
|
63
|
+
};
|
|
64
|
+
const HEX_RE = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
65
|
+
function expand(hex) {
|
|
66
|
+
const h = hex.replace("#", "");
|
|
67
|
+
const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
|
|
68
|
+
return Number.parseInt(full, 16);
|
|
69
|
+
}
|
|
70
|
+
export function junShade(hex, amount) {
|
|
71
|
+
const n = expand(hex);
|
|
72
|
+
const to = amount > 0 ? 255 : 0;
|
|
73
|
+
const t = Math.abs(amount);
|
|
74
|
+
const mix = (v) => Math.round(v + (to - v) * t);
|
|
75
|
+
const r = mix(n >> 16 & 255);
|
|
76
|
+
const g = mix(n >> 8 & 255);
|
|
77
|
+
const b = mix(n & 255);
|
|
78
|
+
return `#${[r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("")}`;
|
|
79
|
+
}
|
|
80
|
+
export function junHexToRgb(hex) {
|
|
81
|
+
const n = expand(hex);
|
|
82
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
83
|
+
}
|
|
84
|
+
export function junLuminance(hex) {
|
|
85
|
+
const n = expand(hex);
|
|
86
|
+
return ((n >> 16 & 255) * 0.299 + (n >> 8 & 255) * 0.587 + (n & 255) * 0.114) / 255;
|
|
87
|
+
}
|
|
88
|
+
export const JUN_ACCENTS = {
|
|
89
|
+
sun: {
|
|
90
|
+
light: "#e08a00",
|
|
91
|
+
dark: "#ffb800",
|
|
92
|
+
orb: {
|
|
93
|
+
light: { from: "#ffb800", to: "#ff9f00", glow: "#ff9f00", core: "#ffffff" },
|
|
94
|
+
dark: { from: "#ffb800", to: "#ff9f00", glow: "#ff9f00", core: "#ffffff" }
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
blue: { light: "#2563eb", dark: "#60a5fa" },
|
|
98
|
+
emerald: { light: "#059669", dark: "#34d399" },
|
|
99
|
+
violet: { light: "#7c3aed", dark: "#a78bfa" },
|
|
100
|
+
amber: { light: "#d97706", dark: "#fbbf24" },
|
|
101
|
+
rose: { light: "#e11d48", dark: "#fb7185" },
|
|
102
|
+
teal: { light: "#0d9488", dark: "#2dd4bf" }
|
|
103
|
+
};
|
|
104
|
+
export function junMarkColorsFor(cfg) {
|
|
105
|
+
const custom = (v) => typeof v === "string" && HEX_RE.test(v) ? v : void 0;
|
|
106
|
+
const customLight = custom(cfg.themeAccentCustomLight);
|
|
107
|
+
const customDark = custom(cfg.themeAccentCustomDark);
|
|
108
|
+
const accent = typeof cfg.themeAccent === "string" ? cfg.themeAccent : void 0;
|
|
109
|
+
const preset = accent && accent !== "mono" ? JUN_ACCENTS[accent] : void 0;
|
|
110
|
+
return {
|
|
111
|
+
light: junMarkColors("light", customLight ?? preset?.light, customLight ? void 0 : preset?.orb?.light),
|
|
112
|
+
dark: junMarkColors("dark", customDark ?? preset?.dark, customDark ? void 0 : preset?.orb?.dark)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function junMarkName(value, fallback = "sun") {
|
|
116
|
+
return typeof value === "string" && JUN_MARK_NAMES.includes(value) ? value : fallback;
|
|
117
|
+
}
|
|
118
|
+
export function junSunColors(hex, orb) {
|
|
119
|
+
if (orb) {
|
|
120
|
+
return {
|
|
121
|
+
from: orb.from,
|
|
122
|
+
to: orb.to,
|
|
123
|
+
core: orb.core ?? (junLuminance(orb.from) > 0.62 ? "#101013" : "#ffffff"),
|
|
124
|
+
glow: orb.glow
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (!hex || !HEX_RE.test(hex)) return null;
|
|
128
|
+
return {
|
|
129
|
+
from: junShade(hex, 0.12),
|
|
130
|
+
to: junShade(hex, -0.08),
|
|
131
|
+
core: junLuminance(hex) > 0.62 ? "#101013" : "#ffffff",
|
|
132
|
+
glow: hex
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export function junMarkColors(scheme, accentHex, orb) {
|
|
136
|
+
const mono = JUN_MARK_MONO[scheme];
|
|
137
|
+
const sun = junSunColors(accentHex, orb);
|
|
138
|
+
if (!sun) return mono;
|
|
139
|
+
return { ink: mono.ink, sunFrom: sun.from, sunTo: sun.to, sunCore: sun.core, sunGlow: sun.glow };
|
|
140
|
+
}
|
|
141
|
+
function escapeAttr(s) {
|
|
142
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
|
143
|
+
}
|
|
144
|
+
export function junMarkShapes(mark, id = "j") {
|
|
145
|
+
if (mark === "sun") {
|
|
146
|
+
const { body, core, glow, halo } = JUN_SUN;
|
|
147
|
+
return `<defs><linearGradient id="${id}b" x1="0" y1="0" x2="1" y2="1"><stop offset="0" class="jm-b0"/><stop offset="1" class="jm-b1"/></linearGradient><radialGradient id="${id}h" gradientUnits="userSpaceOnUse" cx="${halo.cx}" cy="${halo.cy}" r="${halo.r}"><stop offset="${(core.r / halo.r).toFixed(4)}" stop-color="${halo.color}" stop-opacity="${halo.inner}"/><stop offset="0.84" stop-color="${halo.color}" stop-opacity="${halo.mid}"/><stop offset="1" stop-color="${halo.color}" stop-opacity="0"/></radialGradient><radialGradient id="${id}g" gradientUnits="userSpaceOnUse" cx="${glow.cx}" cy="${glow.cy}" r="${glow.r}"><stop offset="0" class="jm-g"/><stop offset="1" class="jm-g" stop-opacity="0"/></radialGradient></defs><circle cx="${body.cx}" cy="${body.cy}" r="${body.r}" fill="url(#${id}b)"/><circle cx="${halo.cx}" cy="${halo.cy}" r="${halo.r}" fill="url(#${id}h)"/><circle cx="${core.cx}" cy="${core.cy}" r="${core.r}" class="jm-c"/><circle cx="${core.cx}" cy="${core.cy}" r="${core.r}" fill="url(#${id}g)"/>`;
|
|
148
|
+
}
|
|
149
|
+
const geom = JUN_MARKS[mark] ?? JUN_MARKS.sprout;
|
|
150
|
+
return geom.paths.map((p) => `<path d="${escapeAttr(p.d)}" class="jm-s" stroke-width="${p.w}"${p.join ? "" : ' stroke-linecap="round"'} stroke-linejoin="round" fill="none"/>`).join("") + geom.dots.map((c) => `<circle cx="${c.cx}" cy="${c.cy}" r="${c.r}" class="jm-k"/>`).join("");
|
|
151
|
+
}
|
|
152
|
+
function markRules(c) {
|
|
153
|
+
return `.jm-b0{stop-color:${c.sunFrom}}.jm-b1{stop-color:${c.sunTo}}.jm-c{fill:${c.sunCore}}.jm-g{stop-color:${c.sunGlow}}.jm-s{stroke:${c.ink}}.jm-k{fill:${c.ink}}`;
|
|
154
|
+
}
|
|
155
|
+
export function junFaviconSvg(mark, light, dark) {
|
|
156
|
+
const vb = JUN_MARK_VIEWBOX;
|
|
157
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${vb} ${vb}"><style>${markRules(light)}@media(prefers-color-scheme:dark){${markRules(dark)}}</style>` + junMarkShapes(mark) + `</svg>`;
|
|
158
|
+
}
|
|
159
|
+
export function junFaviconDataUrl(mark, light, dark) {
|
|
160
|
+
return `data:image/svg+xml,${encodeURIComponent(junFaviconSvg(mark, light, dark))}`;
|
|
161
|
+
}
|
|
162
|
+
export function junIconSvg(mark, colors, opts = {}) {
|
|
163
|
+
const vb = JUN_MARK_VIEWBOX;
|
|
164
|
+
const scale = opts.scale ?? 1;
|
|
165
|
+
const inset = vb * (1 - scale) / 2;
|
|
166
|
+
const bg = opts.background ? `<rect width="${vb}" height="${vb}"${opts.radius ? ` rx="${opts.radius}"` : ""} fill="${escapeAttr(opts.background)}"/>` : "";
|
|
167
|
+
const body = scale === 1 ? junMarkShapes(mark) : `<g transform="translate(${inset.toFixed(3)} ${inset.toFixed(3)}) scale(${scale})">${junMarkShapes(mark)}</g>`;
|
|
168
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${vb} ${vb}"><style>${markRules(colors)}</style>${bg}${body}</svg>`;
|
|
169
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abraca/junis",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.85.0",
|
|
4
4
|
"description": "Website-builder Nuxt module for the Abracadabra CRDT platform — page-type renderers, presence chrome, studio editing and SSR, all driven by documents",
|
|
5
5
|
"repository": "abracadabra/jun-is",
|
|
6
6
|
"license": "MIT",
|