@c9up/nebula 0.2.0 → 0.2.2

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.
Files changed (50) hide show
  1. package/README.md +11 -9
  2. package/dist/atoms/AccessibleIcon.d.ts +24 -0
  3. package/dist/atoms/AccessibleIcon.js +27 -0
  4. package/dist/atoms/VisuallyHidden.d.ts +30 -0
  5. package/dist/atoms/VisuallyHidden.js +35 -0
  6. package/dist/atoms/index.d.ts +2 -0
  7. package/dist/atoms/index.js +2 -0
  8. package/dist/configure.d.ts +6 -0
  9. package/dist/configure.js +4 -22
  10. package/dist/index.d.ts +7 -4
  11. package/dist/index.js +7 -4
  12. package/dist/lib/id.d.ts +13 -29
  13. package/dist/lib/id.js +13 -39
  14. package/dist/molecules/Toolbar.d.ts +50 -0
  15. package/dist/molecules/Toolbar.js +70 -0
  16. package/dist/molecules/index.d.ts +7 -5
  17. package/dist/molecules/index.js +7 -5
  18. package/dist/organisms/Toaster.d.ts +78 -10
  19. package/dist/organisms/Toaster.js +146 -20
  20. package/dist/organisms/index.d.ts +1 -1
  21. package/dist/primitives/direction.d.ts +38 -0
  22. package/dist/primitives/direction.js +57 -0
  23. package/dist/primitives/floating.js +1 -12
  24. package/dist/primitives/focusable.d.ts +10 -0
  25. package/dist/primitives/focusable.js +10 -1
  26. package/dist/primitives/index.d.ts +2 -1
  27. package/dist/primitives/index.js +2 -1
  28. package/dist/primitives/rovingFocus.js +14 -7
  29. package/dist/stubs.d.ts +13 -0
  30. package/dist/stubs.js +14 -0
  31. package/nebula.css +1 -1
  32. package/package.json +4 -3
  33. package/registry.json +63 -0
  34. package/src/atoms/AccessibleIcon.ts +39 -0
  35. package/src/atoms/VisuallyHidden.ts +45 -0
  36. package/src/atoms/index.ts +8 -0
  37. package/src/configure.ts +10 -23
  38. package/src/index.ts +7 -4
  39. package/src/lib/id.ts +11 -39
  40. package/src/molecules/Toolbar.ts +100 -0
  41. package/src/molecules/index.ts +14 -5
  42. package/src/organisms/Toaster.ts +207 -33
  43. package/src/organisms/index.ts +2 -0
  44. package/src/primitives/direction.ts +61 -0
  45. package/src/primitives/floating.ts +2 -12
  46. package/src/primitives/focusable.ts +10 -1
  47. package/src/primitives/index.ts +7 -0
  48. package/src/primitives/rovingFocus.ts +18 -5
  49. package/src/stubs.ts +16 -0
  50. package/stubs/config/nebula.stub +21 -0
@@ -1,9 +1,23 @@
1
1
  /**
2
2
  * Toaster — transient notifications.
3
3
  *
4
- * shadcn delegates this to `sonner`. nebula keeps it in-house, and the shape
5
- * is the same: one region mounted once near the app root, and a `toast()`
6
- * function callable from anywhere with no reference to it.
4
+ * shadcn ships two: `sonner`, which wraps a third-party library, and `toast`,
5
+ * its own, built on Base UI. nebula keeps it in-house with zero dependencies
6
+ * and follows the SECOND — the shape is the same: one region mounted once near
7
+ * the app root, and a `toast` object callable from anywhere with no reference
8
+ * to it.
9
+ *
10
+ * NAMED DEVIATIONS from Base UI's manager, all deliberate:
11
+ *
12
+ * - `show` / `dismiss` / `variant` / `duration` rather than `add` / `close` /
13
+ * `type` / `timeout`. `variant` is what every other nebula component calls
14
+ * this (Button, Alert, Badge), and renaming it here alone would make the
15
+ * package less consistent with itself than with Base UI.
16
+ * - `variant` keeps `warning`, which Base UI's `type` does not have.
17
+ * - No `priority` (display ordering), `data` (typed payload for a React render
18
+ * prop — a `Child` already covers it) or `positionerProps` (anchored toasts).
19
+ * - No `updateKey`. It exists to make React replay an animation without
20
+ * remounting; `update` here replaces the entry, and aurora re-renders it.
7
21
  *
8
22
  * That decoupling is the whole design. A queue in module state, a signal the
9
23
  * region subscribes to, and `toast.error(…)` works from a route handler's
@@ -25,50 +39,100 @@
25
39
  import { component, html, signal } from "@c9up/aurora";
26
40
  import type { Child } from "../lib/children.js";
27
41
  import { cn } from "../lib/cn.js";
28
- import { XIcon } from "../lib/icons.js";
42
+ import { LoaderIcon, XIcon } from "../lib/icons.js";
29
43
  import { fadeInOut } from "../lib/motion.js";
30
44
  import { type Reactive, read } from "../lib/props.js";
31
45
 
32
- export type ToastVariant = "default" | "success" | "error" | "warning";
46
+ export type ToastVariant =
47
+ | "default"
48
+ | "success"
49
+ | "error"
50
+ | "warning"
51
+ | "loading";
52
+
53
+ /**
54
+ * A toast's identity. A number when `show` minted it, a string when the caller
55
+ * supplied one — which is what makes `update` and deduplication possible, and
56
+ * how {@link toast.promise} turns one toast from loading into its outcome.
57
+ */
58
+ export type ToastId = number | string;
33
59
 
34
60
  export interface ToastOptions {
35
61
  title: Child;
36
62
  description?: Child;
37
63
  variant?: ToastVariant;
38
- /** Milliseconds on screen. `0` keeps it until dismissed. */
64
+ /**
65
+ * Milliseconds on screen. `0` keeps it until dismissed.
66
+ *
67
+ * Left out, it comes from the variant: an error stays twice as long because
68
+ * the user has to read it and often act on it, and a `loading` toast does not
69
+ * leave on its own at all — it is waiting for an outcome.
70
+ */
39
71
  duration?: number;
40
72
  action?: { label: string; onClick: () => void };
73
+ /**
74
+ * A stable id. Showing a toast under an id that is already on screen UPDATES
75
+ * it instead of stacking another — so "you are offline", raised on every
76
+ * failed request, is one toast rather than nine.
77
+ */
78
+ id?: string;
79
+ /** Called once the toast leaves, however it left. */
80
+ onClose?: () => void;
41
81
  }
42
82
 
43
- interface ActiveToast extends ToastOptions {
44
- readonly id: number;
83
+ interface ActiveToast extends Omit<ToastOptions, "id"> {
84
+ readonly id: ToastId;
45
85
  readonly variant: ToastVariant;
46
86
  }
47
87
 
48
88
  const DEFAULT_DURATION_MS = 5000;
49
89
 
90
+ /** How long a variant stays when the caller did not say. */
91
+ function defaultDuration(variant: ToastVariant): number {
92
+ if (variant === "loading") return 0;
93
+ return variant === "error" ? DEFAULT_DURATION_MS * 2 : DEFAULT_DURATION_MS;
94
+ }
95
+
50
96
  const queue = signal<readonly ActiveToast[]>([]);
51
- const timers = new Map<number, ReturnType<typeof setTimeout>>();
97
+ const timers = new Map<ToastId, ReturnType<typeof setTimeout>>();
52
98
  /** When each toast is due to disappear, as an epoch timestamp. */
53
- const deadlines = new Map<number, number>();
99
+ const deadlines = new Map<ToastId, number>();
54
100
  /** Time each toast had left when the pointer entered the region. */
55
- const remainders = new Map<number, number>();
101
+ const remainders = new Map<ToastId, number>();
56
102
  let nextId = 0;
57
103
 
58
- function dismiss(id: number): void {
104
+ function dismiss(id: ToastId): void {
105
+ const leaving = queue().find((entry) => entry.id === id);
59
106
  clearTimer(id);
60
107
  deadlines.delete(id);
61
108
  remainders.delete(id);
62
109
  queue(queue().filter((entry) => entry.id !== id));
110
+ notifyClosed(leaving);
111
+ }
112
+
113
+ /**
114
+ * Run a toast's `onClose`, without letting it take the caller down.
115
+ *
116
+ * The callback belongs to application code and runs from a timer, a click and
117
+ * `clear()` alike. One that throws would otherwise break whichever of those
118
+ * happened to be running — a dismissal that leaves the queue half-updated.
119
+ */
120
+ function notifyClosed(entry: ActiveToast | undefined): void {
121
+ if (entry?.onClose === undefined) return;
122
+ try {
123
+ entry.onClose();
124
+ } catch (error) {
125
+ console.error("[nebula] a toast onClose callback threw", error);
126
+ }
63
127
  }
64
128
 
65
- function clearTimer(id: number): void {
129
+ function clearTimer(id: ToastId): void {
66
130
  const timer = timers.get(id);
67
131
  if (timer !== undefined) clearTimeout(timer);
68
132
  timers.delete(id);
69
133
  }
70
134
 
71
- function schedule(id: number, duration: number): void {
135
+ function schedule(id: ToastId, duration: number): void {
72
136
  // A duration of zero means "stays until dismissed", so no timer and no
73
137
  // deadline — which is also what keeps pause/resume from resurrecting one.
74
138
  if (duration <= 0) return;
@@ -103,19 +167,79 @@ function resumeAll(minimumMs: number): void {
103
167
  remainders.clear();
104
168
  }
105
169
 
106
- function show(options: ToastOptions): number {
107
- nextId += 1;
108
- const id = nextId;
109
- const entry: ActiveToast = {
110
- ...options,
111
- id,
112
- variant: options.variant ?? "default",
113
- };
170
+ function show(options: ToastOptions): ToastId {
171
+ // A supplied id that is already on screen updates rather than stacks.
172
+ if (options.id !== undefined && has(options.id)) {
173
+ update(options.id, options);
174
+ return options.id;
175
+ }
176
+ let id: ToastId;
177
+ if (options.id === undefined) {
178
+ nextId += 1;
179
+ id = nextId;
180
+ } else {
181
+ id = options.id;
182
+ }
183
+ const variant = options.variant ?? "default";
184
+ const entry: ActiveToast = { ...options, id, variant };
114
185
  queue([...queue(), entry]);
115
- schedule(id, options.duration ?? DEFAULT_DURATION_MS);
186
+ schedule(id, options.duration ?? defaultDuration(variant));
116
187
  return id;
117
188
  }
118
189
 
190
+ function has(id: ToastId): boolean {
191
+ return queue().some((entry) => entry.id === id);
192
+ }
193
+
194
+ /**
195
+ * Change a toast that is already on screen. No-op if it has gone.
196
+ *
197
+ * The countdown is recomputed, because that is the part a caller would not
198
+ * think to ask for and always wants: a `loading` toast has no timer at all, so
199
+ * turning it into a success without rescheduling would leave it on screen for
200
+ * good. Which is exactly what {@link toast.promise} does to it.
201
+ */
202
+ function update(id: ToastId, patch: Partial<ToastOptions>): void {
203
+ const current = queue().find((entry) => entry.id === id);
204
+ if (current === undefined) return;
205
+ const variant = patch.variant ?? current.variant;
206
+ const next: ActiveToast = { ...current, ...patch, id, variant };
207
+ queue(queue().map((entry) => (entry.id === id ? next : entry)));
208
+ clearTimer(id);
209
+ deadlines.delete(id);
210
+ remainders.delete(id);
211
+ schedule(id, patch.duration ?? next.duration ?? defaultDuration(variant));
212
+ }
213
+
214
+ /** What a `promise` stage says: just a title, or the whole toast. */
215
+ export type ToastMessage = Child | Omit<ToastOptions, "id" | "variant">;
216
+
217
+ function optionsOf(message: ToastMessage): Omit<ToastOptions, "id"> {
218
+ // A plain object with a `title` is the options form; anything else — a
219
+ // string, a number, a template — is the title itself. Checked on `title`
220
+ // rather than on the shape in general, because a template result IS an
221
+ // object and would otherwise be mistaken for options.
222
+ if (
223
+ typeof message === "object" &&
224
+ message !== null &&
225
+ "title" in message &&
226
+ !Array.isArray(message)
227
+ ) {
228
+ return message;
229
+ }
230
+ return { title: message };
231
+ }
232
+
233
+ function resolveMessage<T>(
234
+ message: ToastMessage | ((value: T) => ToastMessage),
235
+ value: T,
236
+ ): Omit<ToastOptions, "id"> {
237
+ if (typeof message === "function") {
238
+ return optionsOf((message as (v: T) => ToastMessage)(value));
239
+ }
240
+ return optionsOf(message);
241
+ }
242
+
119
243
  /**
120
244
  * Raise a toast. Returns its id, which `dismiss` accepts.
121
245
  *
@@ -123,31 +247,76 @@ function show(options: ToastOptions): number {
123
247
  */
124
248
  export const toast = {
125
249
  show,
250
+ update,
126
251
  dismiss,
127
- success: (title: Child, description?: Child): number =>
252
+ success: (title: Child, description?: Child): ToastId =>
128
253
  show({ title, description, variant: "success" }),
129
- error: (title: Child, description?: Child): number =>
130
- // Errors stay twice as long: the user has to read them, and often act.
131
- show({
132
- title,
133
- description,
134
- variant: "error",
135
- duration: DEFAULT_DURATION_MS * 2,
136
- }),
137
- warning: (title: Child, description?: Child): number =>
254
+ error: (title: Child, description?: Child): ToastId =>
255
+ show({ title, description, variant: "error" }),
256
+ warning: (title: Child, description?: Child): ToastId =>
138
257
  show({ title, description, variant: "warning" }),
258
+ loading: (title: Child, description?: Child): ToastId =>
259
+ show({ title, description, variant: "loading" }),
260
+ /**
261
+ * One toast for the whole life of an async call: waiting, then the outcome.
262
+ *
263
+ * ```ts
264
+ * await toast.promise(save(form), {
265
+ * loading: 'Saving…',
266
+ * success: (saved) => `Saved ${saved.name}`,
267
+ * error: (reason) => ({ title: 'Could not save', description: String(reason) }),
268
+ * })
269
+ * ```
270
+ *
271
+ * Returns the SAME promise it was given, rejection included. It reports, it
272
+ * does not handle: swallowing the rejection here would turn a failed call
273
+ * into a red toast and nothing else, with the caller's own error path never
274
+ * running.
275
+ */
276
+ promise<T>(
277
+ work: Promise<T>,
278
+ messages: {
279
+ loading: ToastMessage;
280
+ success: ToastMessage | ((value: T) => ToastMessage);
281
+ error: ToastMessage | ((reason: unknown) => ToastMessage);
282
+ },
283
+ ): Promise<T> {
284
+ const id = show({ ...optionsOf(messages.loading), variant: "loading" });
285
+ // A separate chain, whose own rejection IS handled — so reporting the
286
+ // failure never adds an unhandled rejection of its own.
287
+ work.then(
288
+ (value) => {
289
+ update(id, {
290
+ ...resolveMessage(messages.success, value),
291
+ variant: "success",
292
+ });
293
+ },
294
+ (reason: unknown) => {
295
+ update(id, {
296
+ ...resolveMessage(messages.error, reason),
297
+ variant: "error",
298
+ });
299
+ },
300
+ );
301
+ return work;
302
+ },
139
303
  /** Clear everything — on navigation, say. */
140
304
  clear(): void {
141
305
  for (const timer of timers.values()) clearTimeout(timer);
142
306
  timers.clear();
143
307
  deadlines.clear();
144
308
  remainders.clear();
309
+ const leaving = queue();
145
310
  queue([]);
311
+ // After the queue is empty, so a callback that raises a toast of its own
312
+ // is not swept away by the clear that called it.
313
+ for (const entry of leaving) notifyClosed(entry);
146
314
  },
147
315
  };
148
316
 
149
317
  const variantClasses: Record<ToastVariant, string> = {
150
318
  default: "bg-popover text-popover-foreground border",
319
+ loading: "bg-popover text-muted-foreground border",
151
320
  success:
152
321
  "bg-popover text-popover-foreground border-l-4 border-l-primary border",
153
322
  error: "bg-popover text-destructive border-l-4 border-l-destructive border",
@@ -216,6 +385,11 @@ function renderToast(entry: ActiveToast): Child {
216
385
  fadeInOut,
217
386
  )}"
218
387
  >
388
+ ${
389
+ entry.variant === "loading"
390
+ ? LoaderIcon({ class: "size-4 mt-0.5 shrink-0 animate-spin" })
391
+ : null
392
+ }
219
393
  <div class="flex-1 text-sm">
220
394
  <div class="font-medium">${entry.title}</div>
221
395
  ${
@@ -388,6 +388,8 @@ export {
388
388
  export {
389
389
  Toaster,
390
390
  type ToasterProps,
391
+ type ToastId,
392
+ type ToastMessage,
391
393
  type ToastOptions,
392
394
  type ToastVariant,
393
395
  toast,
@@ -0,0 +1,61 @@
1
+ /// <reference lib="dom" />
2
+ /**
3
+ * Reading direction — the one place that answers "which way is forward?".
4
+ *
5
+ * Radix ships a `DirectionProvider` and threads the answer through React
6
+ * context. Aurora has a context, but a provider would be the wrong mechanism
7
+ * here: the direction is already on the page. `<html dir="rtl">`, a `dir`
8
+ * attribute on one panel, a stylesheet setting `direction` — all of them are
9
+ * answered by the computed style, and none of them requires the application to
10
+ * remember to wrap anything. A provider would be a second source of truth that
11
+ * silently disagrees with the first.
12
+ *
13
+ * The distinction that matters to callers is PHYSICAL versus LOGICAL. An arrow
14
+ * key is physical: ArrowRight means the key to the right, always. "The next
15
+ * item" is logical, and in a right-to-left list the next item is to the LEFT.
16
+ * `forward()` converts one into the other, and is the whole of this module's
17
+ * job.
18
+ */
19
+
20
+ export type Direction = "ltr" | "rtl";
21
+
22
+ /**
23
+ * The direction this element is laid out in.
24
+ *
25
+ * The computed style rather than the `dir` attribute, so an element inheriting
26
+ * from `<html dir="rtl">` answers correctly without every anchor carrying the
27
+ * attribute itself. `ltr` wherever there is no layout to ask — a server
28
+ * render, a jsdom without styles — which is also the correct default.
29
+ */
30
+ export function directionOf(element: Element | null | undefined): Direction {
31
+ if (element === null || element === undefined) return "ltr";
32
+ if (typeof getComputedStyle !== "function") return "ltr";
33
+ try {
34
+ return getComputedStyle(element).direction === "rtl" ? "rtl" : "ltr";
35
+ } catch {
36
+ // A detached node in some environments. Not a reason to fail a keypress.
37
+ return "ltr";
38
+ }
39
+ }
40
+
41
+ /** Shorthand for the check that reads better at a call site than `=== "rtl"`. */
42
+ export function isRightToLeft(element: Element | null | undefined): boolean {
43
+ return directionOf(element) === "rtl";
44
+ }
45
+
46
+ /**
47
+ * Which way a horizontal arrow key actually moves.
48
+ *
49
+ * `+1` for the next item, `-1` for the previous. ArrowRight is `+1` in a
50
+ * left-to-right widget and `-1` in a right-to-left one — that mirroring is the
51
+ * entire reason this exists, and getting it wrong makes every menu, tab list
52
+ * and toolbar navigate backwards for half the world's readers.
53
+ */
54
+ export function forward(
55
+ key: "ArrowLeft" | "ArrowRight",
56
+ element: Element | null | undefined,
57
+ ): -1 | 1 {
58
+ const rightIsForward = !isRightToLeft(element);
59
+ if (key === "ArrowRight") return rightIsForward ? 1 : -1;
60
+ return rightIsForward ? -1 : 1;
61
+ }
@@ -25,6 +25,8 @@
25
25
  * has to find an offset parent, and gets it wrong the moment one appears.
26
26
  */
27
27
 
28
+ import { isRightToLeft } from "./direction.js";
29
+
28
30
  export type Side = "top" | "right" | "bottom" | "left";
29
31
  export type Align = "start" | "center" | "end";
30
32
  export type Placement = Side | `${Side}-${Align}`;
@@ -456,18 +458,6 @@ export function autoPosition(
456
458
  };
457
459
  }
458
460
 
459
- /**
460
- * Is this element laid out right to left?
461
- *
462
- * The computed style rather than the `dir` attribute, so an element inheriting
463
- * the direction from `<html dir="rtl">` is answered correctly without every
464
- * anchor having to carry the attribute itself.
465
- */
466
- function isRightToLeft(element: HTMLElement): boolean {
467
- if (typeof getComputedStyle !== "function") return false;
468
- return getComputedStyle(element).direction === "rtl";
469
- }
470
-
471
461
  /**
472
462
  * Watch elements for size changes, where the platform supports it.
473
463
  *
@@ -13,7 +13,16 @@
13
13
  * styles rather than trusting the markup.
14
14
  */
15
15
 
16
- const FOCUSABLE_SELECTOR = [
16
+ /**
17
+ * The standard tabbable set.
18
+ *
19
+ * Exported because a composite widget that navigates "whatever controls are in
20
+ * here" — a toolbar — needs the same definition, and a second copy next door
21
+ * is how the two drift into disagreeing about `summary` or `contenteditable`.
22
+ * It is a selector, not an answer: `isFocusable` below is still what decides,
23
+ * because a selector cannot see `display: none` or a collapsed `<details>`.
24
+ */
25
+ export const FOCUSABLE_SELECTOR = [
17
26
  "a[href]",
18
27
  "area[href]",
19
28
  "button:not([disabled])",
@@ -18,6 +18,12 @@ export {
18
18
  type ControllableOptions,
19
19
  controllable,
20
20
  } from "./controllable.js";
21
+ export {
22
+ type Direction,
23
+ directionOf,
24
+ forward,
25
+ isRightToLeft,
26
+ } from "./direction.js";
21
27
  export {
22
28
  type DismissableLayer,
23
29
  type DismissableOptions,
@@ -43,6 +49,7 @@ export {
43
49
  floatingSurface,
44
50
  } from "./floatingSurface.js";
45
51
  export {
52
+ FOCUSABLE_SELECTOR,
46
53
  firstFocusable,
47
54
  focusableWithin,
48
55
  focusSilently,
@@ -19,6 +19,7 @@
19
19
  * which is not a budget worth optimising against correctness.
20
20
  */
21
21
 
22
+ import { forward } from "./direction.js";
22
23
  import { focusSilently, isVisible } from "./focusable.js";
23
24
 
24
25
  export type Orientation = "vertical" | "horizontal" | "both";
@@ -132,7 +133,7 @@ export function rovingFocus(options: RovingFocusOptions): RovingFocus {
132
133
  // A modifier means the user is talking to the browser, not the widget.
133
134
  if (event.altKey || event.ctrlKey || event.metaKey) return;
134
135
 
135
- const direction = directionFor(event.key, orientation);
136
+ const direction = directionFor(event.key, orientation, container);
136
137
  if (direction !== 0) {
137
138
  event.preventDefault();
138
139
  move(direction);
@@ -177,15 +178,27 @@ export function rovingFocus(options: RovingFocusOptions): RovingFocus {
177
178
  };
178
179
  }
179
180
 
180
- /** `-1` for previous, `+1` for next, `0` when the key is not ours. */
181
- function directionFor(key: string, orientation: Orientation): number {
181
+ /**
182
+ * `-1` for previous, `+1` for next, `0` when the key is not ours.
183
+ *
184
+ * The horizontal pair is mirrored in a right-to-left group: ArrowRight means
185
+ * the key to the right, and in an RTL list the item to the right is the
186
+ * PREVIOUS one. Vertical never mirrors — `dir` does not turn a page upside
187
+ * down.
188
+ */
189
+ function directionFor(
190
+ key: string,
191
+ orientation: Orientation,
192
+ container: HTMLElement,
193
+ ): number {
182
194
  const vertical = orientation === "vertical" || orientation === "both";
183
195
  const horizontal = orientation === "horizontal" || orientation === "both";
184
196
 
185
197
  if (vertical && key === "ArrowDown") return 1;
186
198
  if (vertical && key === "ArrowUp") return -1;
187
- if (horizontal && key === "ArrowRight") return 1;
188
- if (horizontal && key === "ArrowLeft") return -1;
199
+ if (horizontal && (key === "ArrowRight" || key === "ArrowLeft")) {
200
+ return forward(key, container);
201
+ }
189
202
  return 0;
190
203
  }
191
204
 
package/src/stubs.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Where this package's stubs live.
3
+ *
4
+ * Its own module, as upstream keeps it: a stub root is a path a package
5
+ * publishes, and a caller importing it should not have to import the
6
+ * configure hook to get it.
7
+ *
8
+ * `import.meta.dirname` rather than a URL — upstream reads it straight off
9
+ * `import.meta`, and deriving it from `import.meta.url` breaks wherever that
10
+ * is not a `file://` URL, which is what a test runner serving modules over
11
+ * HTTP hands you.
12
+ */
13
+
14
+ import { join } from "node:path";
15
+
16
+ export const stubsRoot = join(import.meta.dirname, "..", "stubs");
@@ -0,0 +1,21 @@
1
+ ---
2
+ to: config/nebula.ts
3
+ ---
4
+ import { defineConfig } from '@c9up/nebula'
5
+
6
+ /**
7
+ * nebula — component registry and style adapter.
8
+ *
9
+ * Changing `adapter` and re-running `ream configure @c9up/nebula` swaps the
10
+ * CSS engine. The components themselves are untouched: all three adapters
11
+ * consume the same class names.
12
+ */
13
+ export default defineConfig({
14
+ adapter: '{{ adapter }}',
15
+ paths: {
16
+ // Where `ream nebula:add` copies components. The atomic layers live under it.
17
+ components: 'resources/pages',
18
+ css: 'resources/css/app.css',
19
+ output: 'public/app.css',
20
+ },
21
+ })