@steppy/player 0.5.0 → 0.6.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.
@@ -11,6 +11,12 @@ export declare function renderCounter(ctx: TemplateContext): TemplateResult;
11
11
  export declare function renderPrev(ctx: TemplateContext): TemplateResult;
12
12
  export declare function renderNext(ctx: TemplateContext): TemplateResult;
13
13
  export declare function renderRestart(ctx: TemplateContext): TemplateResult;
14
+ /**
15
+ * A locale's name in its own language ("Français", "Nederlands"), the way the
16
+ * static pages' picker labels it. Falls back to the code itself when the
17
+ * runtime cannot name it (an invalid tag, or a tag it does not know).
18
+ */
19
+ export declare function localeLabel(locale: string): string;
14
20
  export declare function renderLocaleSelect(ctx: TemplateContext): TemplateResult | typeof nothing;
15
21
  export declare function renderLayoutSelect(ctx: TemplateContext): TemplateResult | typeof nothing;
16
22
  /** Segmented [Sidebar | Overlay | Inline] control (active = dark fill). */
@@ -4,8 +4,10 @@
4
4
  */
5
5
  import type { TourSource } from './loader.js';
6
6
  import type { TourStringOverrides } from './strings.js';
7
+ import type { TourAppearance, TourTheme } from './theme.js';
7
8
  export type { TourSource } from './loader.js';
8
9
  export type { TourStringOverrides } from './strings.js';
10
+ export type { TourAppearance, TourTheme } from './theme.js';
9
11
  export interface TourStartOptions {
10
12
  /** Route parameters for the tour's entry (``/invoices/:invoiceId``). */
11
13
  params?: Record<string, string | number>;
@@ -44,6 +46,10 @@ export interface TourHostApi {
44
46
  source: TourSource | null;
45
47
  navigate: TourNavigate | null;
46
48
  strings: TourStringOverrides | undefined;
49
+ /** ``--steppy-tour-*`` values set inline on the element; they win over the page's CSS. */
50
+ theme: TourTheme | undefined;
51
+ /** Default palette: ``dark`` (default), ``light``, or ``auto`` (follows the colour scheme). */
52
+ appearance: TourAppearance;
47
53
  /** Start a tour. Resolves true once it started; never rejects. */
48
54
  start(tourId: string, options?: TourStartOptions): Promise<boolean>;
49
55
  stop(reason?: string): void;
@@ -16,6 +16,7 @@ import { type DomAdapter } from './dom.js';
16
16
  import { type TourEventDetailMap } from './events.js';
17
17
  import { type TourSource } from './loader.js';
18
18
  import { type TourStringOverrides } from './strings.js';
19
+ import { type TourAppearance, type TourTheme } from './theme.js';
19
20
  export interface SteppyTourHost {
20
21
  addEventListener<K extends keyof TourEventDetailMap>(type: K, listener: (this: SteppyTourHost, ev: CustomEvent<TourEventDetailMap[K]>) => void, options?: boolean | AddEventListenerOptions): void;
21
22
  addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
@@ -62,6 +63,13 @@ export declare class SteppyTourHost extends LitElement implements TourHostApi {
62
63
  strings: {
63
64
  attribute: boolean;
64
65
  };
66
+ theme: {
67
+ attribute: boolean;
68
+ };
69
+ appearance: {
70
+ type: StringConstructor;
71
+ reflect: boolean;
72
+ };
65
73
  };
66
74
  /** Test seam: geometry and timing. */
67
75
  static dom: DomAdapter;
@@ -76,6 +84,8 @@ export declare class SteppyTourHost extends LitElement implements TourHostApi {
76
84
  source: TourSource | null;
77
85
  navigate: TourNavigate | null;
78
86
  strings: TourStringOverrides | undefined;
87
+ theme: TourTheme | undefined;
88
+ appearance: TourAppearance;
79
89
  private _s;
80
90
  private _queue;
81
91
  private _dispatching;
@@ -93,6 +103,8 @@ export declare class SteppyTourHost extends LitElement implements TourHostApi {
93
103
  private _focusPending;
94
104
  private _appFocus;
95
105
  private _swapSeq;
106
+ /** The custom properties ``theme`` wrote last, so a changed theme removes the ones it dropped. */
107
+ private _themed;
96
108
  /** While a tour runs: an app that switches language through ``<html lang>`` alone. */
97
109
  private _lang;
98
110
  private _policy;
@@ -109,6 +121,8 @@ export declare class SteppyTourHost extends LitElement implements TourHostApi {
109
121
  protected updated(changed: PropertyValues<this>): void;
110
122
  protected firstUpdated(): void;
111
123
  protected render(): import("lit-html").TemplateResult | typeof nothing;
124
+ /** Inline custom properties win over the page's ``:root`` and element rules. */
125
+ private _applyTheme;
112
126
  private _start;
113
127
  private _fail;
114
128
  private _tryResume;
@@ -7,6 +7,7 @@
7
7
  */
8
8
  export { SteppyTourHost, defineTourHost } from './host.js';
9
9
  export type { TourHostApi, TourNavigate, TourNavigateContext, TourPosition, TourSource, TourStartOptions, TourStringOverrides } from './api.js';
10
+ export { TOUR_APPEARANCES, TOUR_THEME_KEYS, themeProperty, type TourAppearance, type TourTheme, type TourThemeKey } from './theme.js';
10
11
  export type { TourEventDetailMap, TourEventMeta, TourStepPosition } from './events.js';
11
12
  export type { DismissVia, StepReason, TourErrorDetail, TourSourceKind } from './engine.js';
12
13
  export { ADVANCE_KINDS, PLACEMENTS, TOUR_ERROR_REASONS, TOUR_EVENTS, TOUR_PARTS, TOUR_SCHEMA_VERSION, type AdvanceKind, type Placement, type TourErrorReason, type TourEventName, type TourPart, } from './contract.js';
@@ -1,13 +1,17 @@
1
1
  /**
2
- * Overlay styles. Theming goes through public ``--steppy-*`` custom
3
- * properties, read into private ``--_pw-*`` ones on ``:host`` and never
4
- * declared themselves — so a page sets them on ``:root`` or on the element.
5
- * Geometry comes from properties the tracker writes through CSSOM.
2
+ * Overlay styles. Theming goes through public ``--steppy-tour-*`` custom
3
+ * properties (the keys of ``theme.ts``), read into private ``--_pw-*`` ones on
4
+ * ``:host`` and never declared themselves — so a page sets them on ``:root``
5
+ * or on the element, and the host's ``theme`` property sets them inline.
6
+ * ``appearance="light"`` (or ``"auto"`` under a light colour scheme) swaps the
7
+ * defaults, never a value the page set. Geometry comes from properties the
8
+ * tracker writes through CSSOM.
6
9
  *
7
- * Defaults meet WCAG AA (guard: ``test/tour/small-modules.test.ts``). The bubble
8
- * inherits the app's font unless ``--steppy-font-family`` is set. The
9
- * bubble's inner layout uses logical properties, so it mirrors under the
10
- * layer's ``dir`` (an Arabic or Hebrew tour); its placement around the target
11
- * stays physical.
10
+ * Defaults meet WCAG AA in both appearances (guard: ``test/tour/small-modules.test.ts``).
11
+ * The bubble inherits the app's font unless ``--steppy-tour-font-family`` (or
12
+ * ``--steppy-font-family``) is set. The bubble's inner layout uses logical
13
+ * properties, so it mirrors under the layer's ``dir`` (an Arabic or Hebrew
14
+ * tour); its placement around the target stays physical.
12
15
  */
13
- export declare const tourStyles: import("lit").CSSResult;
16
+ import { type CSSResult } from 'lit';
17
+ export declare const tourStyles: CSSResult;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The overlay's theme surface: the public ``--steppy-tour-*`` custom
3
+ * properties, and the ``theme`` object that writes them from code.
4
+ *
5
+ * One key list drives the stylesheet (``styles.ts``), the host's ``theme``
6
+ * property and the docs (guard: ``test/tour/theme.test.ts``). Values come from
7
+ * the app only — its stylesheet or the ``theme`` property — never from a tour
8
+ * file, so tour data still cannot reach a style.
9
+ */
10
+ export declare const TOUR_THEME_KEYS: readonly ["bubbleBg", "bubbleFg", "muted", "accent", "accentFg", "focus", "scrim", "link", "border", "radius", "width", "padding", "shadow", "fontFamily", "fontSize", "lineHeight", "titleSize", "titleWeight", "buttonRadius", "buttonPadding", "buttonWeight", "ringWidth", "spotlightRadius"];
11
+ export type TourThemeKey = (typeof TOUR_THEME_KEYS)[number];
12
+ /** Any subset of the keys, as CSS values: ``{ accent: '#0b5cad', width: '360px' }``. */
13
+ export type TourTheme = Partial<Record<TourThemeKey, string>>;
14
+ /** ``dark`` is the default; ``auto`` follows ``prefers-color-scheme``. */
15
+ export declare const TOUR_APPEARANCES: readonly ["dark", "light", "auto"];
16
+ export type TourAppearance = (typeof TOUR_APPEARANCES)[number];
17
+ export declare const kebab: (key: string) => string;
18
+ /** ``accentFg`` → ``--steppy-tour-accent-fg``. */
19
+ export declare const themeProperty: (key: TourThemeKey) => string;
20
+ /** The private property the stylesheet reads (``--_pw-accent-fg``). */
21
+ export declare const privateProperty: (key: TourThemeKey) => string;
22
+ /** Custom-property declarations for a theme; unknown keys and empty values are dropped. */
23
+ export declare function themeDeclarations(theme: TourTheme | null | undefined): Map<string, string>;
@@ -51,7 +51,44 @@ export declare const TOUR_DEFAULTS: {
51
51
  readonly accentFg: "#ffffff";
52
52
  readonly focus: "#f09a6a";
53
53
  readonly scrim: "rgba(31, 29, 26, 0.45)";
54
+ readonly border: "none";
54
55
  readonly radius: "6px";
56
+ readonly width: "320px";
57
+ readonly padding: "8px 12px";
58
+ readonly shadow: "0 4px 12px rgba(0, 0, 0, 0.2)";
59
+ readonly fontFamily: "inherit";
60
+ readonly fontSize: "14px";
61
+ readonly lineHeight: "1.4";
62
+ readonly titleSize: "1em";
63
+ readonly titleWeight: "600";
64
+ readonly buttonRadius: "4px";
65
+ readonly buttonPadding: "4px 10px";
66
+ readonly buttonWeight: "inherit";
67
+ readonly ringWidth: "2px";
68
+ };
69
+ /** ``appearance="light"``: a light bubble, same accent; AA-checked like the dark one. */
70
+ export declare const TOUR_LIGHT: {
71
+ readonly bubbleBg: "#ffffff";
72
+ readonly bubbleFg: "#1f1d1a";
73
+ readonly muted: "#5b6b64";
74
+ readonly focus: "#a8410e";
75
+ readonly border: "1px solid #e1ddd1";
76
+ readonly accent: "#a8410e";
77
+ readonly accentFg: "#ffffff";
78
+ readonly scrim: "rgba(31, 29, 26, 0.45)";
79
+ readonly radius: "6px";
80
+ readonly width: "320px";
81
+ readonly padding: "8px 12px";
82
+ readonly shadow: "0 4px 12px rgba(0, 0, 0, 0.2)";
83
+ readonly fontFamily: "inherit";
84
+ readonly fontSize: "14px";
85
+ readonly lineHeight: "1.4";
86
+ readonly titleSize: "1em";
87
+ readonly titleWeight: "600";
88
+ readonly buttonRadius: "4px";
89
+ readonly buttonPadding: "4px 10px";
90
+ readonly buttonWeight: "inherit";
91
+ readonly ringWidth: "2px";
55
92
  };
56
93
  /** A token value inside a ``css`` template (inserted verbatim, never data). */
57
94
  export declare const cssValue: (value: string | number) => CSSResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steppy/player",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Steppy players — the interactive guide (Lit web component + manifest validator) and the in-app tour overlay",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {