@kongyo2/cards-css 0.2.1 → 0.3.1
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/README.md +8 -1
- package/dist/dom.js +2 -0
- package/dist/dom.js.map +1 -1
- package/dist/holo-card.js +150 -8
- package/dist/holo-card.js.map +1 -1
- package/dist/holo-cards.css +78 -70
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/palette.js +189 -0
- package/dist/palette.js.map +1 -0
- package/dist/spring.js +22 -10
- package/dist/spring.js.map +1 -1
- package/dist/ticker.js +3 -8
- package/dist/ticker.js.map +1 -1
- package/dist-types/dom.d.ts +2 -0
- package/dist-types/dom.d.ts.map +1 -1
- package/dist-types/holo-card.d.ts +21 -1
- package/dist-types/holo-card.d.ts.map +1 -1
- package/dist-types/index.d.ts +2 -1
- package/dist-types/index.d.ts.map +1 -1
- package/dist-types/palette.d.ts +10 -0
- package/dist-types/palette.d.ts.map +1 -0
- package/dist-types/spring.d.ts +3 -1
- package/dist-types/spring.d.ts.map +1 -1
- package/dist-types/ticker.d.ts +3 -2
- package/dist-types/ticker.d.ts.map +1 -1
- package/dist-types/types.d.ts +90 -1
- package/dist-types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dom.ts +2 -0
- package/src/holo-card.ts +194 -16
- package/src/index.ts +6 -0
- package/src/palette.ts +195 -0
- package/src/spring.ts +25 -10
- package/src/styles/base.css +47 -7
- package/src/styles/effects/cosmos.css +51 -41
- package/src/styles/effects/glitter.css +17 -11
- package/src/styles/effects/holo.css +1 -1
- package/src/styles/effects/reverse.css +8 -5
- package/src/ticker.ts +5 -14
- package/src/types.ts +95 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { CssVars, HoloCardOptions, HoloLayerOptions, VisualOptions } from "./types.js";
|
|
1
|
+
import type { CssVars, DepthOptions, GlareOptions, GyroscopeOptions, HoloCardOptions, HoloLayerOptions, PaletteOptions, VisualOptions } from "./types.js";
|
|
2
2
|
export declare class HoloCard {
|
|
3
3
|
readonly element: HTMLElement;
|
|
4
4
|
private readonly rotator;
|
|
5
5
|
private frontElement;
|
|
6
6
|
private layersElement;
|
|
7
7
|
private readonly options;
|
|
8
|
+
private gyroConfig;
|
|
8
9
|
private readonly springRotate;
|
|
9
10
|
private readonly springGlare;
|
|
10
11
|
private readonly springBackground;
|
|
@@ -42,6 +43,9 @@ export declare class HoloCard {
|
|
|
42
43
|
private unsubscribeOrientation;
|
|
43
44
|
constructor(element: HTMLElement, options?: HoloCardOptions);
|
|
44
45
|
private applyVisual;
|
|
46
|
+
private applyPalette;
|
|
47
|
+
private applyGlare;
|
|
48
|
+
private applyDepth;
|
|
45
49
|
private applyStaticStyles;
|
|
46
50
|
private enableInteractive;
|
|
47
51
|
private parallaxBackground;
|
|
@@ -78,6 +82,22 @@ export declare class HoloCard {
|
|
|
78
82
|
setVars(vars: CssVars): void;
|
|
79
83
|
/** Update fine-grained visual controls at runtime. */
|
|
80
84
|
setVisual(visual: VisualOptions): void;
|
|
85
|
+
/**
|
|
86
|
+
* Swap the foil colour palette / theme at runtime. This is a full replacement:
|
|
87
|
+
* any palette variable not present in `palette` reverts to its default.
|
|
88
|
+
*/
|
|
89
|
+
setPalette(palette: PaletteOptions): void;
|
|
90
|
+
/**
|
|
91
|
+
* Update the dynamic glare (reflected light) at runtime. The image / shape /
|
|
92
|
+
* blend are replaced wholesale — omit them to return to the effect's built-in
|
|
93
|
+
* glare. `opacity` is shared with `visual.glareOpacity` and only changes when
|
|
94
|
+
* provided.
|
|
95
|
+
*/
|
|
96
|
+
setGlare(glare: GlareOptions): void;
|
|
97
|
+
/** Toggle or tune the foil 3D depth / extrusion at runtime. */
|
|
98
|
+
setDepth(depth: boolean | DepthOptions): void;
|
|
99
|
+
/** Update the gyroscope physical-behaviour tuning at runtime. */
|
|
100
|
+
setGyroscope(gyroscope: boolean | GyroscopeOptions): void;
|
|
81
101
|
/**
|
|
82
102
|
* Insert an extra layer between the artwork and the foil at runtime, returning
|
|
83
103
|
* the created element. Requires the card to have a `.holo-card__front`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"holo-card.d.ts","sourceRoot":"","sources":["../src/holo-card.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"holo-card.d.ts","sourceRoot":"","sources":["../src/holo-card.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EAEd,aAAa,EACd,MAAM,YAAY,CAAC;AA+KpB,qBAAa,QAAQ;IACnB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAE9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkF;IAC1G,OAAO,CAAC,UAAU,CAAoB;IAEtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgB;IAC5C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAe;IAChD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAC7C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAe;IACjD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAe;IAC/C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiB;IAE7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAe;IAC9C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAE5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAA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|
4
4
|
export { buildHoloCardElement, buildLayerElement, applyVars, normalizeMask, CLASS, type ResolvedMask } from "./dom.js";
|
|
5
5
|
export { generateTextures, texturesToCssVariables, grainTexture, glitterTexture, TEXTURE_VARIABLES, DEFAULT_TEXTURE_SEED, type Textures, type TextureOptions, } from "./textures.js";
|
|
6
6
|
export { subscribeOrientation, requestOrientationPermission, resetBaseOrientation, type Orientation, type RelativeOrientation, } from "./orientation.js";
|
|
7
|
+
export { PALETTES, resolvePalette, paletteToCssVariables } from "./palette.js";
|
|
7
8
|
export { getActiveCard, setActiveCard, subscribeActiveCard } from "./active-registry.js";
|
|
8
9
|
export { Spring, type SpringValue, type SpringOpts, type SpringSetOpts, type SpringDynamics } from "./spring.js";
|
|
9
10
|
export { round, clamp, adjust } from "./math.js";
|
|
10
|
-
export type { HoloEffect, HoloCardOptions, CreateHoloCardOptions, HoloContent, CssVars, SpringTuning, PhysicsOptions, ShowcaseOptions, VisualOptions, MaskOptions, HoloLayerOptions, } from "./types.js";
|
|
11
|
+
export type { HoloEffect, HoloCardOptions, CreateHoloCardOptions, HoloContent, CssVars, SpringTuning, PhysicsOptions, ShowcaseOptions, VisualOptions, MaskOptions, HoloLayerOptions, PaletteOptions, PalettePreset, GlareOptions, GyroscopeOptions, DepthOptions, } from "./types.js";
|
|
11
12
|
export declare const createHoloCard: (options: CreateHoloCardOptions) => HoloCard;
|
|
12
13
|
export declare const attachHoloCard: (element: HTMLElement, options?: HoloCardOptions) => HoloCard;
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEzE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,O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AAiB,EACjB,oBAAoB,EACpB,KAAK,QAAQ,EACb,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AACjH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EACV,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,OAAO,EACP,YAAY,EACZ,cAAc,EACd,eAAe,EACf,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,cAAc,GAAI,SAAS,qBAAqB,KAAG,QAG/D,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,EAAE,UAAS,eAAoB,KAAG,QACrD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PaletteOptions, PalettePreset } from "./types.js";
|
|
2
|
+
/** Built-in foil colour schemes, keyed by {@link PalettePreset}. */
|
|
3
|
+
export declare const PALETTES: Record<PalettePreset, PaletteOptions>;
|
|
4
|
+
/** Merge a palette's `preset` base with its explicit overrides into a flat scheme. */
|
|
5
|
+
export declare const resolvePalette: (palette: PaletteOptions) => PaletteOptions;
|
|
6
|
+
/** Every CSS custom property the palette can own — used to clear stale values when swapping palettes. */
|
|
7
|
+
export declare const PALETTE_VARIABLES: string[];
|
|
8
|
+
/** Convert a (resolved or raw) palette into the CSS custom properties it drives. */
|
|
9
|
+
export declare const paletteToCssVariables: (palette: PaletteOptions) => Record<string, string>;
|
|
10
|
+
//# sourceMappingURL=palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../src/palette.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhE,oEAAoE;AACpE,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,aAAa,EAAE,cAAc,CA6H1D,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,cAKxD,CAAC;AAIF,yGAAyG;AACzG,eAAO,MAAM,iBAAiB,EAAE,MAAM,EAiBrC,CAAC;AAWF,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,GAAI,SAAS,cAAc,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAwBpF,CAAC"}
|
package/dist-types/spring.d.ts
CHANGED
|
@@ -29,13 +29,15 @@ export declare class Spring<T extends SpringValue> {
|
|
|
29
29
|
private cancelTask;
|
|
30
30
|
private task;
|
|
31
31
|
private lastTime;
|
|
32
|
-
private
|
|
32
|
+
private settlePromise;
|
|
33
|
+
private settleResolve;
|
|
33
34
|
private readonly subscribers;
|
|
34
35
|
constructor(value: T, opts?: SpringOpts);
|
|
35
36
|
get current(): T;
|
|
36
37
|
subscribe(fn: (value: T) => void): () => void;
|
|
37
38
|
private notify;
|
|
38
39
|
set(newValue: T, opts?: SpringSetOpts): Promise<void>;
|
|
40
|
+
private resolveSettle;
|
|
39
41
|
destroy(): void;
|
|
40
42
|
}
|
|
41
43
|
//# sourceMappingURL=spring.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spring.d.ts","sourceRoot":"","sources":["../src/spring.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"spring.d.ts","sourceRoot":"","sources":["../src/spring.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACzB;AAqED,qBAAa,MAAM,CAAC,CAAC,SAAS,WAAW;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,SAAS,CAAC;IAEjD,OAAO,CAAC,KAAK,CAAI;IACjB,OAAO,CAAC,SAAS,CAAI;IACrB,OAAO,CAAC,WAAW,CAAI;IACvB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,mBAAmB,CAAK;IAChC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,IAAI,CAA2B;IACvC,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,aAAa,CAA8B;IACnD,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwC;gBAExD,KAAK,EAAE,CAAC,EAAE,IAAI,GAAE,UAAe;IAU3C,IAAI,OAAO,IAAI,CAAC,CAEf;IAED,SAAS,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAI7C,OAAO,CAAC,MAAM;IAId,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA+DzD,OAAO,CAAC,aAAa;IAOrB,OAAO,IAAI,IAAI;CAOhB"}
|
package/dist-types/ticker.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare const now: () => number;
|
|
2
|
+
type Task = (time: number) => boolean;
|
|
2
3
|
export interface TaskHandle {
|
|
3
|
-
promise: Promise<void>;
|
|
4
4
|
abort: () => void;
|
|
5
5
|
}
|
|
6
|
-
export declare const loop: (callback:
|
|
6
|
+
export declare const loop: (callback: Task) => TaskHandle;
|
|
7
|
+
export {};
|
|
7
8
|
//# sourceMappingURL=ticker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ticker.d.ts","sourceRoot":"","sources":["../src/ticker.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,GAAG,QAAO,MAA+E,CAAC;
|
|
1
|
+
{"version":3,"file":"ticker.d.ts","sourceRoot":"","sources":["../src/ticker.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,GAAG,QAAO,MAA+E,CAAC;AAOvG,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAEtC,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAeD,eAAO,MAAM,IAAI,GAAI,UAAU,IAAI,KAAG,UAUrC,CAAC"}
|
package/dist-types/types.d.ts
CHANGED
|
@@ -58,6 +58,88 @@ export interface ShowcaseOptions {
|
|
|
58
58
|
/** Spring tuning while the showcase runs. */
|
|
59
59
|
spring?: SpringTuning;
|
|
60
60
|
}
|
|
61
|
+
/** Built-in foil colour schemes for {@link PaletteOptions.preset}. */
|
|
62
|
+
export type PalettePreset = "rainbow" | "gold" | "aurora" | "ruby" | "sapphire" | "mono";
|
|
63
|
+
/**
|
|
64
|
+
* Foil colour-palette / theming. Every field maps onto the foil CSS custom
|
|
65
|
+
* properties, so a palette can be supplied up front or swapped at runtime with
|
|
66
|
+
* `card.setPalette(...)`. Colours accept any CSS colour string.
|
|
67
|
+
*/
|
|
68
|
+
export interface PaletteOptions {
|
|
69
|
+
/** A built-in scheme used as the base; the explicit fields below override it. */
|
|
70
|
+
preset?: PalettePreset;
|
|
71
|
+
/** Holographic spectrum stops (`--sunpillar-1…6`). 1–6 colours; fewer are cycled to fill the ramp. */
|
|
72
|
+
sunpillars?: string[];
|
|
73
|
+
/** Rainbow stops for the `holo` foil sweep (`--red` / `--yellow` / `--green` / `--blue` / `--violet`). 1–5 colours, cycled. */
|
|
74
|
+
spectrum?: string[];
|
|
75
|
+
/** Ramp stops for the `cosmos` foil (`--cosmos-clr-1…6`). 1–6 colours, cycled. */
|
|
76
|
+
cosmos?: string[];
|
|
77
|
+
/** Card edge highlight colour (`--card-edge`). */
|
|
78
|
+
edge?: string;
|
|
79
|
+
/** Card back fill colour (`--card-back`). */
|
|
80
|
+
back?: string;
|
|
81
|
+
/** Card glow colour (`--card-glow`); equivalent to the top-level `glow` option. */
|
|
82
|
+
glow?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Custom dynamic glare (reflected light). Supply a full `image` for total
|
|
86
|
+
* control, or compose the built-in pointer-tracking radial gradient from
|
|
87
|
+
* `shape` / `extent` / `size` / `stops`. Applies across every effect and can be
|
|
88
|
+
* updated at runtime with `card.setGlare(...)`.
|
|
89
|
+
*/
|
|
90
|
+
export interface GlareOptions {
|
|
91
|
+
/**
|
|
92
|
+
* Full `background-image` for the glare layer, overriding the built-in
|
|
93
|
+
* gradient on every effect. `var(--pointer-x)` / `var(--pointer-y)` are
|
|
94
|
+
* available for pointer tracking.
|
|
95
|
+
*/
|
|
96
|
+
image?: string;
|
|
97
|
+
/** Radial-gradient shape when composing the gradient (default `circle`). */
|
|
98
|
+
shape?: "circle" | "ellipse";
|
|
99
|
+
/** Radial-gradient extent keyword, e.g. `farthest-corner` / `closest-side` (default `farthest-corner`). */
|
|
100
|
+
extent?: string;
|
|
101
|
+
/** Explicit gradient size — two values imply an ellipse (e.g. `60% 40%`), a single value a circle radius (e.g. `120px`); overrides `extent` when set. */
|
|
102
|
+
size?: string;
|
|
103
|
+
/** Colour stops, e.g. `["hsla(0,0%,100%,.8) 10%", "hsla(0,0%,0%,.5) 90%"]`. */
|
|
104
|
+
stops?: string[];
|
|
105
|
+
/** `mix-blend-mode` for the glare layer. */
|
|
106
|
+
blend?: string;
|
|
107
|
+
/** Glare opacity multiplier (mirrors `visual.glareOpacity`). */
|
|
108
|
+
opacity?: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Physical-behaviour tuning for the device-orientation (gyroscope) response.
|
|
112
|
+
* Passing `true` keeps the defaults; `false` disables gyroscope tilt.
|
|
113
|
+
*/
|
|
114
|
+
export interface GyroscopeOptions {
|
|
115
|
+
/** Master switch (default true); `false` matches `gyroscope: false`. */
|
|
116
|
+
enabled?: boolean;
|
|
117
|
+
/** Device tilt (deg) on the X axis (gamma) that reaches the full effect (default 16). Lower is more sensitive. */
|
|
118
|
+
rangeX?: number;
|
|
119
|
+
/** Device tilt (deg) on the Y axis (beta) that reaches the full effect (default 18). */
|
|
120
|
+
rangeY?: number;
|
|
121
|
+
/** Sensitivity multiplier applied to the raw tilt before clamping (default 1). */
|
|
122
|
+
sensitivity?: number;
|
|
123
|
+
/** Flip the horizontal response. */
|
|
124
|
+
invertX?: boolean;
|
|
125
|
+
/** Flip the vertical response. */
|
|
126
|
+
invertY?: boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Foil 3D depth / extrusion simulation. Lifts the foil stack above the artwork
|
|
130
|
+
* in true 3D so it parallaxes as the card tilts, with a tilt-reactive contact
|
|
131
|
+
* shadow. Passing `true` enables it with the defaults.
|
|
132
|
+
*/
|
|
133
|
+
export interface DepthOptions {
|
|
134
|
+
/** Foil extrusion height in px — how far the foil floats above the artwork (default 14). */
|
|
135
|
+
strength?: number;
|
|
136
|
+
/** Perspective in px for the card's 3D space; lower exaggerates the depth (default 600). */
|
|
137
|
+
perspective?: number;
|
|
138
|
+
/** Contact-shadow opacity beneath the lifted card, 0–1 (default 0.35). */
|
|
139
|
+
shadow?: number;
|
|
140
|
+
/** Multiplier turning each extra layer's `parallax` into Z-lift, so stacked layers extrude in depth (default 1). */
|
|
141
|
+
layerScale?: number;
|
|
142
|
+
}
|
|
61
143
|
/** Fine-grained visual / effect control. Numeric fields are multipliers (1 = unchanged). */
|
|
62
144
|
export interface VisualOptions {
|
|
63
145
|
/** Foil brightness multiplier. */
|
|
@@ -123,13 +205,20 @@ export interface HoloCardOptions {
|
|
|
123
205
|
effect?: HoloEffect;
|
|
124
206
|
interactive?: boolean;
|
|
125
207
|
activateOnClick?: boolean;
|
|
126
|
-
|
|
208
|
+
/** Device-orientation tilt: `true`/`false`, or an object for physical-behaviour tuning. */
|
|
209
|
+
gyroscope?: boolean | GyroscopeOptions;
|
|
127
210
|
showcase?: boolean | ShowcaseOptions;
|
|
128
211
|
glow?: string;
|
|
129
212
|
aspectRatio?: number;
|
|
130
213
|
textureSeed?: number;
|
|
131
214
|
mask?: string | MaskOptions;
|
|
132
215
|
foil?: string;
|
|
216
|
+
/** Foil colour palette / theming. */
|
|
217
|
+
palette?: PaletteOptions;
|
|
218
|
+
/** Custom dynamic glare (reflected light). */
|
|
219
|
+
glare?: GlareOptions;
|
|
220
|
+
/** Foil 3D depth / extrusion: `true` for the defaults, or an object to tune it. */
|
|
221
|
+
depth?: boolean | DepthOptions;
|
|
133
222
|
/** Interaction & physics adjustments. */
|
|
134
223
|
physics?: PhysicsOptions;
|
|
135
224
|
/** Fine-grained visual control. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE5E;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC,CAAC;AAE3D,sFAAsF;AACtF,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC;AAEtC,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sFAAsF;IACtF,WAAW,CAAC,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,MAAM,CAAC;IACd,qCAAqC;IACrC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,mFAAmF;IACnF,KAAK,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;IAC/B,yCAAyC;IACzC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,mCAAmC;IACnC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC5B,iFAAiF;IACjF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GACtD,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kongyo2/cards-css",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Framework-agnostic holographic trading-card effect (tilt, shine, glare, holo / reverse / cosmos / glitter) with procedurally code-generated textures.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/dom.ts
CHANGED
|
@@ -19,6 +19,8 @@ export const CLASS = {
|
|
|
19
19
|
loading: "holo-card--loading",
|
|
20
20
|
masked: "holo-card--masked",
|
|
21
21
|
maskCard: "holo-card--mask-card",
|
|
22
|
+
depth: "holo-card--depth",
|
|
23
|
+
customGlare: "holo-card--custom-glare",
|
|
22
24
|
overlayInteractive: "holo-card__overlay--interactive",
|
|
23
25
|
} as const;
|
|
24
26
|
|
package/src/holo-card.ts
CHANGED
|
@@ -4,7 +4,18 @@ import { CLASS, applyVars, buildLayerElement, cssUrl, normalizeMask } from "./do
|
|
|
4
4
|
import { getActiveCard, setActiveCard, subscribeActiveCard } from "./active-registry.js";
|
|
5
5
|
import { resetBaseOrientation, subscribeOrientation, type RelativeOrientation } from "./orientation.js";
|
|
6
6
|
import { generateTextures, texturesToCssVariables } from "./textures.js";
|
|
7
|
-
import
|
|
7
|
+
import { paletteToCssVariables, PALETTE_VARIABLES } from "./palette.js";
|
|
8
|
+
import type {
|
|
9
|
+
CssVars,
|
|
10
|
+
DepthOptions,
|
|
11
|
+
GlareOptions,
|
|
12
|
+
GyroscopeOptions,
|
|
13
|
+
HoloCardOptions,
|
|
14
|
+
HoloLayerOptions,
|
|
15
|
+
PaletteOptions,
|
|
16
|
+
ShowcaseOptions,
|
|
17
|
+
VisualOptions,
|
|
18
|
+
} from "./types.js";
|
|
8
19
|
|
|
9
20
|
const requestFrame = (cb: () => void): number =>
|
|
10
21
|
typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(cb) : setTimeout(cb, 16);
|
|
@@ -102,6 +113,73 @@ const resolveShowcase = (showcase: boolean | ShowcaseOptions | undefined): Resol
|
|
|
102
113
|
};
|
|
103
114
|
};
|
|
104
115
|
|
|
116
|
+
interface ResolvedGyroscope {
|
|
117
|
+
enabled: boolean;
|
|
118
|
+
rangeX: number;
|
|
119
|
+
rangeY: number;
|
|
120
|
+
sensitivity: number;
|
|
121
|
+
invertX: boolean;
|
|
122
|
+
invertY: boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const DEFAULT_GYRO_RANGE_X = 16;
|
|
126
|
+
const DEFAULT_GYRO_RANGE_Y = 18;
|
|
127
|
+
|
|
128
|
+
const resolveGyroscope = (gyroscope: boolean | GyroscopeOptions | undefined): ResolvedGyroscope => {
|
|
129
|
+
const opts: GyroscopeOptions = gyroscope && typeof gyroscope === "object" ? gyroscope : {};
|
|
130
|
+
const enabled = typeof gyroscope === "boolean" ? gyroscope : (opts.enabled ?? true);
|
|
131
|
+
return {
|
|
132
|
+
enabled,
|
|
133
|
+
rangeX: opts.rangeX ?? DEFAULT_GYRO_RANGE_X,
|
|
134
|
+
rangeY: opts.rangeY ?? DEFAULT_GYRO_RANGE_Y,
|
|
135
|
+
sensitivity: opts.sensitivity ?? 1,
|
|
136
|
+
invertX: opts.invertX ?? false,
|
|
137
|
+
invertY: opts.invertY ?? false,
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
interface ResolvedDepth {
|
|
142
|
+
enabled: boolean;
|
|
143
|
+
strength: number;
|
|
144
|
+
perspective: number;
|
|
145
|
+
shadow: number;
|
|
146
|
+
layerScale: number;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const resolveDepth = (depth: boolean | DepthOptions | undefined): ResolvedDepth => {
|
|
150
|
+
const opts: DepthOptions = depth && typeof depth === "object" ? depth : {};
|
|
151
|
+
return {
|
|
152
|
+
enabled: Boolean(depth),
|
|
153
|
+
strength: opts.strength ?? 14,
|
|
154
|
+
perspective: opts.perspective ?? 600,
|
|
155
|
+
shadow: opts.shadow ?? 0.35,
|
|
156
|
+
layerScale: opts.layerScale ?? 1,
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const DEFAULT_GLARE_STOPS = ["hsla(0, 0%, 100%, 0.8) 10%", "hsla(0, 0%, 100%, 0.65) 20%", "hsla(0, 0%, 0%, 0.5) 90%"];
|
|
161
|
+
|
|
162
|
+
const composeGlareImage = (glare: GlareOptions): string | undefined => {
|
|
163
|
+
if (glare.image) {
|
|
164
|
+
return glare.image;
|
|
165
|
+
}
|
|
166
|
+
if (
|
|
167
|
+
glare.shape === undefined &&
|
|
168
|
+
glare.extent === undefined &&
|
|
169
|
+
glare.size === undefined &&
|
|
170
|
+
glare.stops === undefined
|
|
171
|
+
) {
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
const sizeTokens = glare.size ? glare.size.trim().split(/\s+/) : [];
|
|
175
|
+
const shape = glare.shape ?? (sizeTokens.length > 1 ? "ellipse" : "circle");
|
|
176
|
+
const geometry = glare.size ? `${shape} ${glare.size}` : `${glare.extent ?? "farthest-corner"} ${shape}`;
|
|
177
|
+
const stops = (glare.stops?.length ? glare.stops : DEFAULT_GLARE_STOPS).join(", ");
|
|
178
|
+
return `radial-gradient(${geometry} at var(--pointer-x) var(--pointer-y), ${stops})`;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const DEPTH_VARS = ["--hc-depth", "--card-perspective", "--hc-depth-shadow", "--hc-depth-layer-scale"];
|
|
182
|
+
|
|
105
183
|
interface Vec2 {
|
|
106
184
|
x: number;
|
|
107
185
|
y: number;
|
|
@@ -118,9 +196,8 @@ export class HoloCard {
|
|
|
118
196
|
private readonly rotator: HTMLElement;
|
|
119
197
|
private frontElement: HTMLElement | null;
|
|
120
198
|
private layersElement: HTMLElement | null = null;
|
|
121
|
-
private readonly options: Required<
|
|
122
|
-
|
|
123
|
-
>;
|
|
199
|
+
private readonly options: Required<Pick<HoloCardOptions, "interactive" | "activateOnClick" | "showcase">>;
|
|
200
|
+
private gyroConfig: ResolvedGyroscope;
|
|
124
201
|
|
|
125
202
|
private readonly springRotate: Spring<Vec2>;
|
|
126
203
|
private readonly springGlare: Spring<Glare>;
|
|
@@ -177,9 +254,9 @@ export class HoloCard {
|
|
|
177
254
|
this.options = {
|
|
178
255
|
interactive: options.interactive ?? true,
|
|
179
256
|
activateOnClick: options.activateOnClick ?? false,
|
|
180
|
-
gyroscope: options.gyroscope ?? true,
|
|
181
257
|
showcase: options.showcase ?? false,
|
|
182
258
|
};
|
|
259
|
+
this.gyroConfig = resolveGyroscope(options.gyroscope);
|
|
183
260
|
this.showcaseRunning = Boolean(options.showcase);
|
|
184
261
|
this.showcaseConfig = resolveShowcase(options.showcase);
|
|
185
262
|
|
|
@@ -217,6 +294,7 @@ export class HoloCard {
|
|
|
217
294
|
} else if (!element.dataset.effect) {
|
|
218
295
|
element.dataset.effect = "none";
|
|
219
296
|
}
|
|
297
|
+
this.applyPalette(options.palette);
|
|
220
298
|
if (options.glow) {
|
|
221
299
|
element.style.setProperty("--card-glow", options.glow);
|
|
222
300
|
}
|
|
@@ -245,6 +323,8 @@ export class HoloCard {
|
|
|
245
323
|
element.style.setProperty("--foil", cssUrl(options.foil));
|
|
246
324
|
}
|
|
247
325
|
this.applyVisual(options.visual);
|
|
326
|
+
this.applyGlare(options.glare);
|
|
327
|
+
this.applyDepth(options.depth);
|
|
248
328
|
applyVars(element, options.vars);
|
|
249
329
|
|
|
250
330
|
if (!this.layersElement && options.layers?.length && this.frontElement) {
|
|
@@ -315,6 +395,58 @@ export class HoloCard {
|
|
|
315
395
|
}
|
|
316
396
|
}
|
|
317
397
|
|
|
398
|
+
private applyPalette(palette: PaletteOptions | undefined): void {
|
|
399
|
+
if (!palette) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
const style = this.element.style;
|
|
403
|
+
const vars = paletteToCssVariables(palette);
|
|
404
|
+
for (const name of PALETTE_VARIABLES) {
|
|
405
|
+
style.removeProperty(name);
|
|
406
|
+
}
|
|
407
|
+
for (const [name, value] of Object.entries(vars)) {
|
|
408
|
+
style.setProperty(name, value);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
private applyGlare(glare: GlareOptions | undefined): void {
|
|
413
|
+
if (!glare) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
const style = this.element.style;
|
|
417
|
+
style.removeProperty("--glare-image");
|
|
418
|
+
style.removeProperty("--glare-blend");
|
|
419
|
+
this.element.classList.remove(CLASS.customGlare);
|
|
420
|
+
if (typeof glare.opacity === "number") {
|
|
421
|
+
style.setProperty("--hc-glare-opacity", String(glare.opacity));
|
|
422
|
+
}
|
|
423
|
+
if (glare.blend !== undefined) {
|
|
424
|
+
style.setProperty("--glare-blend", glare.blend);
|
|
425
|
+
}
|
|
426
|
+
const image = composeGlareImage(glare);
|
|
427
|
+
if (image !== undefined) {
|
|
428
|
+
style.setProperty("--glare-image", image);
|
|
429
|
+
this.element.classList.add(CLASS.customGlare);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
private applyDepth(depth: boolean | DepthOptions | undefined): void {
|
|
434
|
+
const style = this.element.style;
|
|
435
|
+
const config = resolveDepth(depth);
|
|
436
|
+
if (!config.enabled) {
|
|
437
|
+
this.element.classList.remove(CLASS.depth);
|
|
438
|
+
for (const name of DEPTH_VARS) {
|
|
439
|
+
style.removeProperty(name);
|
|
440
|
+
}
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
this.element.classList.add(CLASS.depth);
|
|
444
|
+
style.setProperty("--hc-depth", `${config.strength}px`);
|
|
445
|
+
style.setProperty("--card-perspective", `${config.perspective}px`);
|
|
446
|
+
style.setProperty("--hc-depth-shadow", String(config.shadow));
|
|
447
|
+
style.setProperty("--hc-depth-layer-scale", String(config.layerScale));
|
|
448
|
+
}
|
|
449
|
+
|
|
318
450
|
private applyStaticStyles(seed: number | undefined): void {
|
|
319
451
|
const seedX = Math.random();
|
|
320
452
|
const seedY = Math.random();
|
|
@@ -531,7 +663,7 @@ export class HoloCard {
|
|
|
531
663
|
this.popover();
|
|
532
664
|
this.element.classList.add(CLASS.active);
|
|
533
665
|
this.element.style.setProperty("--card-active", "1");
|
|
534
|
-
if (this.
|
|
666
|
+
if (this.gyroConfig.enabled) {
|
|
535
667
|
this.startGyroscope();
|
|
536
668
|
}
|
|
537
669
|
} else {
|
|
@@ -607,20 +739,25 @@ export class HoloCard {
|
|
|
607
739
|
if (getActiveCard() !== this) {
|
|
608
740
|
return;
|
|
609
741
|
}
|
|
610
|
-
const
|
|
742
|
+
const gyro = this.gyroConfig;
|
|
743
|
+
const limit = { x: gyro.rangeX, y: gyro.rangeY };
|
|
744
|
+
const dirX = gyro.invertX ? -1 : 1;
|
|
745
|
+
const dirY = gyro.invertY ? -1 : 1;
|
|
611
746
|
const degrees = {
|
|
612
|
-
x: clamp(orientation.relative.gamma, -limit.x, limit.x),
|
|
613
|
-
y: clamp(orientation.relative.beta, -limit.y, limit.y),
|
|
747
|
+
x: clamp(orientation.relative.gamma * gyro.sensitivity * dirX, -limit.x, limit.x),
|
|
748
|
+
y: clamp(orientation.relative.beta * gyro.sensitivity * dirY, -limit.y, limit.y),
|
|
614
749
|
};
|
|
615
|
-
const
|
|
616
|
-
const
|
|
750
|
+
const fracX = limit.x === 0 ? 0 : degrees.x / limit.x;
|
|
751
|
+
const fracY = limit.y === 0 ? 0 : degrees.y / limit.y;
|
|
752
|
+
const gx = adjust(fracX, -1, 1, 0, 100);
|
|
753
|
+
const gy = adjust(fracY, -1, 1, 0, 100);
|
|
617
754
|
this.setInteracting(true);
|
|
618
755
|
this.updateSprings(
|
|
619
|
-
this.parallaxBackground(
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
756
|
+
this.parallaxBackground(adjust(fracX, -1, 1, 37, 63), adjust(fracY, -1, 1, 33, 67)),
|
|
757
|
+
{
|
|
758
|
+
x: round(fracX * DEFAULT_GYRO_RANGE_X * -1 * this.tiltScaleX),
|
|
759
|
+
y: round(fracY * DEFAULT_GYRO_RANGE_Y * this.tiltScaleY),
|
|
760
|
+
},
|
|
624
761
|
this.rangeGlare(gx, gy, 1),
|
|
625
762
|
{ x: gx, y: gy },
|
|
626
763
|
);
|
|
@@ -739,6 +876,47 @@ export class HoloCard {
|
|
|
739
876
|
this.applyVisual(visual);
|
|
740
877
|
}
|
|
741
878
|
|
|
879
|
+
/**
|
|
880
|
+
* Swap the foil colour palette / theme at runtime. This is a full replacement:
|
|
881
|
+
* any palette variable not present in `palette` reverts to its default.
|
|
882
|
+
*/
|
|
883
|
+
setPalette(palette: PaletteOptions): void {
|
|
884
|
+
this.applyPalette(palette);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Update the dynamic glare (reflected light) at runtime. The image / shape /
|
|
889
|
+
* blend are replaced wholesale — omit them to return to the effect's built-in
|
|
890
|
+
* glare. `opacity` is shared with `visual.glareOpacity` and only changes when
|
|
891
|
+
* provided.
|
|
892
|
+
*/
|
|
893
|
+
setGlare(glare: GlareOptions): void {
|
|
894
|
+
this.applyGlare(glare);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/** Toggle or tune the foil 3D depth / extrusion at runtime. */
|
|
898
|
+
setDepth(depth: boolean | DepthOptions): void {
|
|
899
|
+
this.applyDepth(depth);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/** Update the gyroscope physical-behaviour tuning at runtime. */
|
|
903
|
+
setGyroscope(gyroscope: boolean | GyroscopeOptions): void {
|
|
904
|
+
const wasEnabled = this.gyroConfig.enabled;
|
|
905
|
+
this.gyroConfig = resolveGyroscope(gyroscope);
|
|
906
|
+
if (getActiveCard() !== this) {
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
if (this.gyroConfig.enabled) {
|
|
910
|
+
if (!wasEnabled) {
|
|
911
|
+
resetBaseOrientation();
|
|
912
|
+
}
|
|
913
|
+
this.startGyroscope();
|
|
914
|
+
} else {
|
|
915
|
+
this.stopGyroscope();
|
|
916
|
+
this.interactEnd(0);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
742
920
|
/**
|
|
743
921
|
* Insert an extra layer between the artwork and the foil at runtime, returning
|
|
744
922
|
* the created element. Requires the card to have a `.holo-card__front`.
|
package/src/index.ts
CHANGED
|
@@ -21,6 +21,7 @@ export {
|
|
|
21
21
|
type Orientation,
|
|
22
22
|
type RelativeOrientation,
|
|
23
23
|
} from "./orientation.js";
|
|
24
|
+
export { PALETTES, resolvePalette, paletteToCssVariables } from "./palette.js";
|
|
24
25
|
export { getActiveCard, setActiveCard, subscribeActiveCard } from "./active-registry.js";
|
|
25
26
|
export { Spring, type SpringValue, type SpringOpts, type SpringSetOpts, type SpringDynamics } from "./spring.js";
|
|
26
27
|
export { round, clamp, adjust } from "./math.js";
|
|
@@ -36,6 +37,11 @@ export type {
|
|
|
36
37
|
VisualOptions,
|
|
37
38
|
MaskOptions,
|
|
38
39
|
HoloLayerOptions,
|
|
40
|
+
PaletteOptions,
|
|
41
|
+
PalettePreset,
|
|
42
|
+
GlareOptions,
|
|
43
|
+
GyroscopeOptions,
|
|
44
|
+
DepthOptions,
|
|
39
45
|
} from "./types.js";
|
|
40
46
|
|
|
41
47
|
export const createHoloCard = (options: CreateHoloCardOptions): HoloCard => {
|