@krizaka/ui 3.85.0 → 3.87.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/{chunk-FYPYJ6MW.js → chunk-GOGEYAYK.js} +25 -19
- package/dist/chunk-GOGEYAYK.js.map +1 -0
- package/dist/filter-bar.d.ts +3 -3
- package/dist/index.d.ts +13 -2
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/media-carousel.d.ts +10 -3
- package/dist/media-carousel.js +23 -14
- package/dist/media-carousel.js.map +1 -1
- package/dist/media-player.d.ts +16 -2
- package/dist/media-player.js +1 -1
- package/dist/pausable-loop.d.ts +27 -0
- package/dist/pausable-loop.js +68 -0
- package/dist/pausable-loop.js.map +1 -0
- package/dist/{player-lightbox-ETBQWDOT.js → player-lightbox-ASFOSUSD.js} +6 -3
- package/dist/{player-lightbox-ETBQWDOT.js.map → player-lightbox-ASFOSUSD.js.map} +1 -1
- package/dist/virtual.d.ts +3 -3
- package/package.json +18 -4
- package/registry/app-frame.json +1 -1
- package/registry/examples/media-gallery/carousel-loop.d.ts +4 -0
- package/registry/examples/media-gallery/carousel-loop.js +26 -0
- package/registry/examples/media-gallery/carousel-loop.tsx +24 -0
- package/registry/examples/media-gallery/carousel-single.d.ts +4 -0
- package/registry/examples/media-gallery/carousel-single.js +12 -0
- package/registry/examples/media-gallery/carousel-single.tsx +12 -0
- package/registry/examples/media-gallery/player-trigger.d.ts +4 -0
- package/registry/examples/media-gallery/player-trigger.js +20 -0
- package/registry/examples/media-gallery/player-trigger.tsx +19 -0
- package/registry/index.json +11 -10
- package/registry/map.json +1 -1
- package/registry/media-gallery.json +43 -7
- package/registry/nav-bar.json +1 -1
- package/registry/rail-nav.json +1 -1
- package/registry/shop.json +1 -1
- package/registry/site-footer.json +1 -1
- package/dist/chunk-FYPYJ6MW.js.map +0 -1
|
@@ -10,10 +10,11 @@ import {
|
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import { tv } from "tailwind-variants";
|
|
12
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
var PlayerLightbox = React.lazy(() => import("./player-lightbox-
|
|
13
|
+
var PlayerLightbox = React.lazy(() => import("./player-lightbox-ASFOSUSD.js"));
|
|
14
14
|
var mediaPlayer = tv({
|
|
15
15
|
slots: {
|
|
16
|
-
|
|
16
|
+
frame: "relative block w-full overflow-hidden rounded-xl border border-border-default bg-media p-0 text-fg-on-media",
|
|
17
|
+
poster: "group absolute inset-0 block h-full w-full focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",
|
|
17
18
|
image: "absolute inset-0 h-full w-full object-cover",
|
|
18
19
|
play: "absolute left-1/2 top-1/2 flex h-14 w-14 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-scrim-strong text-fg-on-media transition-colors group-hover:bg-scrim",
|
|
19
20
|
caption: "pointer-events-none absolute inset-x-0 bottom-0 bg-linear-to-t from-scrim-strong to-transparent p-3 pt-8 text-left text-xs font-semibold"
|
|
@@ -27,29 +28,34 @@ function MediaPlayer({
|
|
|
27
28
|
closeLabel = "Close",
|
|
28
29
|
posterAlt = "",
|
|
29
30
|
caption,
|
|
31
|
+
preview,
|
|
32
|
+
open: given,
|
|
33
|
+
trigger,
|
|
30
34
|
onOpenChange,
|
|
35
|
+
ratio: freeRatio,
|
|
31
36
|
className,
|
|
32
37
|
...player
|
|
33
38
|
}) {
|
|
34
|
-
const ratio = vertical ? "9 / 16" : "16 / 9";
|
|
35
|
-
const [
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
(next)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!next) poster.current?.focus();
|
|
42
|
-
},
|
|
43
|
-
[onOpenChange]
|
|
44
|
-
);
|
|
39
|
+
const ratio = freeRatio ?? (vertical ? "9 / 16" : "16 / 9");
|
|
40
|
+
const [inner, setInner] = React.useState(false);
|
|
41
|
+
const open = given ?? inner;
|
|
42
|
+
const setOpen = (next) => {
|
|
43
|
+
setInner(next);
|
|
44
|
+
onOpenChange?.(next);
|
|
45
|
+
};
|
|
45
46
|
if (mode === "inline") return /* @__PURE__ */ jsx(VideoPlayer, { ...player, aspectRatio: ratio, className });
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const name = playLabel ?? player.title;
|
|
48
|
+
const opener = trigger === void 0 ? /* @__PURE__ */ jsxs("div", { className: s.frame({ className }), style: { aspectRatio: ratio }, children: [
|
|
49
|
+
player.poster && /* @__PURE__ */ jsx("img", { src: player.poster, alt: posterAlt, loading: "lazy", decoding: "async", className: s.image() }),
|
|
50
|
+
preview,
|
|
51
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: s.poster(), "aria-label": caption ? `${caption}. ${name}` : name, onClick: () => setOpen(true), children: [
|
|
49
52
|
/* @__PURE__ */ jsx("span", { className: s.play(), "aria-hidden": true, children: /* @__PURE__ */ jsx(PlayGlyph, { className: "ml-1 h-6 w-6" }) }),
|
|
50
53
|
caption && /* @__PURE__ */ jsx("span", { className: s.caption(), children: caption })
|
|
51
|
-
] })
|
|
52
|
-
|
|
54
|
+
] })
|
|
55
|
+
] }) : trigger?.(() => setOpen(true));
|
|
56
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
57
|
+
opener,
|
|
58
|
+
open && /* @__PURE__ */ jsx(React.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(PlayerLightbox, { player, ratio, vertical, closeLabel, onClose: () => setOpen(false) }) })
|
|
53
59
|
] });
|
|
54
60
|
}
|
|
55
61
|
|
|
@@ -57,4 +63,4 @@ export {
|
|
|
57
63
|
mediaPlayer,
|
|
58
64
|
MediaPlayer
|
|
59
65
|
};
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
66
|
+
//# sourceMappingURL=chunk-GOGEYAYK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/media-gallery/media-player.tsx"],"sourcesContent":["// Client (a dialog, the video player). ONE designed media player: the same frame inline, in a lightbox, or vertical (9:16).\n// Inline it is the VideoPlayer of `@krizaka/ui/video-player`; as a lightbox a poster with a play button opens the player in a\n// dialog, started by that press, with sound. Nothing moves under the pointer: the poster's hover is a colour.\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { PlayGlyph } from \"../glyphs\";\nimport { VideoPlayer, type VideoPlayerProps } from \"../video-player\";\n\n// The dialog and the player of the lightbox load when the poster is pressed, not with the page.\nconst PlayerLightbox = React.lazy(() => import(\"./player-lightbox\"));\n\nexport const mediaPlayer = tv({\n slots: {\n frame: \"relative block w-full overflow-hidden rounded-xl border border-border-default bg-media p-0 text-fg-on-media\",\n poster:\n \"group absolute inset-0 block h-full w-full \" +\n \"focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring\",\n image: \"absolute inset-0 h-full w-full object-cover\",\n play:\n \"absolute left-1/2 top-1/2 flex h-14 w-14 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full \" +\n \"bg-scrim-strong text-fg-on-media transition-colors group-hover:bg-scrim\",\n caption: \"pointer-events-none absolute inset-x-0 bottom-0 bg-linear-to-t from-scrim-strong to-transparent p-3 pt-8 text-left text-xs font-semibold\",\n },\n});\nconst s = mediaPlayer();\n\nexport type MediaPlayerProps = Pick<\n VideoPlayerProps,\n \"src\" | \"poster\" | \"title\" | \"tracks\" | \"loadHls\" | \"labels\" | \"onPlay\" | \"onPause\" | \"onEnded\" | \"onError\"\n> & {\n /** `inline`: the player itself. `lightbox`: a poster that opens it in a dialog. Default `inline`. */\n mode?: \"inline\" | \"lightbox\";\n /** `9 / 16` frame and the narrow dialog for a vertical film; default `16 / 9`. */\n vertical?: boolean;\n /** Any frame ratio (`19 / 16`, `4 / 3`): wins over the frame of `vertical` (give both for a portrait ratio: `vertical ratio=\"3 / 4\"`). Default `16 / 9` (`9 / 16` when `vertical`). */\n ratio?: string;\n /** The poster's words in the lightbox (\"Play the film\"), passed translated. Required for `lightbox`. */\n playLabel?: string;\n /** The close button's words, passed translated. Default `Close`. */\n closeLabel?: string;\n /** What the poster shows, in words (the `alt` of its image); default is empty (decorative: `playLabel` names the button). */\n posterAlt?: string;\n /** A line over the foot of the poster (« Fig. 1a »). */\n caption?: string;\n /** Lightbox: drawn over the poster, under its press (the frame is `relative`): a `<PausableLoop>` of `@krizaka/ui/pausable-loop` previews the film with a muted loop. */\n preview?: React.ReactNode;\n /** Lightbox: opens or closes it from outside (controlled). With it, `onOpenChange` is how the lightbox asks to close. */\n open?: boolean;\n /** Lightbox: replaces the poster with your own opener (`(open) => <button onClick={open}>…`); `null` draws nothing, for a lightbox driven by `open` alone. */\n trigger?: ((open: () => void) => React.ReactNode) | null;\n /** Called when the lightbox opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /** Classes merged on the player or the poster. */\n className?: string;\n};\n\n/** A video in one frame: inline, in a lightbox (a press opens it with sound), 16:9 or vertical. */\nexport function MediaPlayer({\n mode = \"inline\",\n vertical = false,\n playLabel,\n closeLabel = \"Close\",\n posterAlt = \"\",\n caption,\n preview,\n open: given,\n trigger,\n onOpenChange,\n ratio: freeRatio,\n className,\n ...player\n}: MediaPlayerProps) {\n const ratio = freeRatio ?? (vertical ? \"9 / 16\" : \"16 / 9\");\n const [inner, setInner] = React.useState(false);\n const open = given ?? inner;\n const setOpen = (next: boolean) => {\n setInner(next);\n onOpenChange?.(next);\n };\n // The dialog hands the focus back to whatever opened it (the poster or the page's own trigger) when it closes.\n if (mode === \"inline\") return <VideoPlayer {...player} aspectRatio={ratio} className={className} />;\n const name = playLabel ?? player.title;\n // The default opener: the poster (and its loop) in a frame, one button named by `playLabel`; the pause is a sibling, never nested.\n const opener =\n trigger === undefined ? (\n <div className={s.frame({ className })} style={{ aspectRatio: ratio }}>\n {player.poster && <img src={player.poster} alt={posterAlt} loading=\"lazy\" decoding=\"async\" className={s.image()} />}\n {preview}\n <button type=\"button\" className={s.poster()} aria-label={caption ? `${caption}. ${name}` : name} onClick={() => setOpen(true)}>\n <span className={s.play()} aria-hidden>\n <PlayGlyph className=\"ml-1 h-6 w-6\" />\n </span>\n {caption && <span className={s.caption()}>{caption}</span>}\n </button>\n </div>\n ) : (\n trigger?.(() => setOpen(true))\n );\n return (\n <>\n {opener}\n {open && (\n <React.Suspense fallback={null}>\n <PlayerLightbox player={player} ratio={ratio} vertical={vertical} closeLabel={closeLabel} onClose={() => setOpen(false)} />\n </React.Suspense>\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAGA,YAAY,WAAW;AACvB,SAAS,UAAU;AA6Ea,SAmB5B,UAnB4B,KAQxB,YARwB;AAvEhC,IAAM,iBAAuB,WAAK,MAAM,OAAO,+BAAmB,CAAC;AAE5D,IAAM,cAAc,GAAG;AAAA,EAC5B,OAAO;AAAA,IACL,OAAO;AAAA,IACP,QACE;AAAA,IAEF,OAAO;AAAA,IACP,MACE;AAAA,IAEF,SAAS;AAAA,EACX;AACF,CAAC;AACD,IAAM,IAAI,YAAY;AAiCf,SAAS,YAAY;AAAA,EAC1B,OAAO;AAAA,EACP,WAAW;AAAA,EACX;AAAA,EACA,aAAa;AAAA,EACb,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA,GAAG;AACL,GAAqB;AACnB,QAAM,QAAQ,cAAc,WAAW,WAAW;AAClD,QAAM,CAAC,OAAO,QAAQ,IAAU,eAAS,KAAK;AAC9C,QAAM,OAAO,SAAS;AACtB,QAAM,UAAU,CAAC,SAAkB;AACjC,aAAS,IAAI;AACb,mBAAe,IAAI;AAAA,EACrB;AAEA,MAAI,SAAS,SAAU,QAAO,oBAAC,eAAa,GAAG,QAAQ,aAAa,OAAO,WAAsB;AACjG,QAAM,OAAO,aAAa,OAAO;AAEjC,QAAM,SACJ,YAAY,SACV,qBAAC,SAAI,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,GAAG,OAAO,EAAE,aAAa,MAAM,GACjE;AAAA,WAAO,UAAU,oBAAC,SAAI,KAAK,OAAO,QAAQ,KAAK,WAAW,SAAQ,QAAO,UAAS,SAAQ,WAAW,EAAE,MAAM,GAAG;AAAA,IAChH;AAAA,IACD,qBAAC,YAAO,MAAK,UAAS,WAAW,EAAE,OAAO,GAAG,cAAY,UAAU,GAAG,OAAO,KAAK,IAAI,KAAK,MAAM,SAAS,MAAM,QAAQ,IAAI,GAC1H;AAAA,0BAAC,UAAK,WAAW,EAAE,KAAK,GAAG,eAAW,MACpC,8BAAC,aAAU,WAAU,gBAAe,GACtC;AAAA,MACC,WAAW,oBAAC,UAAK,WAAW,EAAE,QAAQ,GAAI,mBAAQ;AAAA,OACrD;AAAA,KACF,IAEA,UAAU,MAAM,QAAQ,IAAI,CAAC;AAEjC,SACE,iCACG;AAAA;AAAA,IACA,QACC,oBAAO,gBAAN,EAAe,UAAU,MACxB,8BAAC,kBAAe,QAAgB,OAAc,UAAoB,YAAwB,SAAS,MAAM,QAAQ,KAAK,GAAG,GAC3H;AAAA,KAEJ;AAEJ;","names":[]}
|
package/dist/filter-bar.d.ts
CHANGED
|
@@ -82,12 +82,12 @@ declare function SavedViews({ views, current, modified, onSelect, onSave, onRena
|
|
|
82
82
|
declare const filterBar: tailwind_variants.TVReturnType<{
|
|
83
83
|
[key: string]: {
|
|
84
84
|
[key: string]: tailwind_variants.ClassValue | {
|
|
85
|
-
count?: tailwind_variants.ClassValue;
|
|
86
85
|
root?: tailwind_variants.ClassValue;
|
|
87
86
|
controls?: tailwind_variants.ClassValue;
|
|
88
87
|
active?: tailwind_variants.ClassValue;
|
|
89
88
|
clear?: tailwind_variants.ClassValue;
|
|
90
89
|
results?: tailwind_variants.ClassValue;
|
|
90
|
+
count?: tailwind_variants.ClassValue;
|
|
91
91
|
optionCount?: tailwind_variants.ClassValue;
|
|
92
92
|
trigger?: tailwind_variants.ClassValue;
|
|
93
93
|
};
|
|
@@ -95,12 +95,12 @@ declare const filterBar: tailwind_variants.TVReturnType<{
|
|
|
95
95
|
} | {
|
|
96
96
|
[x: string]: {
|
|
97
97
|
[x: string]: tailwind_variants.ClassValue | {
|
|
98
|
-
count?: tailwind_variants.ClassValue;
|
|
99
98
|
root?: tailwind_variants.ClassValue;
|
|
100
99
|
controls?: tailwind_variants.ClassValue;
|
|
101
100
|
active?: tailwind_variants.ClassValue;
|
|
102
101
|
clear?: tailwind_variants.ClassValue;
|
|
103
102
|
results?: tailwind_variants.ClassValue;
|
|
103
|
+
count?: tailwind_variants.ClassValue;
|
|
104
104
|
optionCount?: tailwind_variants.ClassValue;
|
|
105
105
|
trigger?: tailwind_variants.ClassValue;
|
|
106
106
|
};
|
|
@@ -117,12 +117,12 @@ declare const filterBar: tailwind_variants.TVReturnType<{
|
|
|
117
117
|
}, undefined, {
|
|
118
118
|
[key: string]: {
|
|
119
119
|
[key: string]: tailwind_variants.ClassValue | {
|
|
120
|
-
count?: tailwind_variants.ClassValue;
|
|
121
120
|
root?: tailwind_variants.ClassValue;
|
|
122
121
|
controls?: tailwind_variants.ClassValue;
|
|
123
122
|
active?: tailwind_variants.ClassValue;
|
|
124
123
|
clear?: tailwind_variants.ClassValue;
|
|
125
124
|
results?: tailwind_variants.ClassValue;
|
|
125
|
+
count?: tailwind_variants.ClassValue;
|
|
126
126
|
optionCount?: tailwind_variants.ClassValue;
|
|
127
127
|
trigger?: tailwind_variants.ClassValue;
|
|
128
128
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -68,6 +68,12 @@ interface ProductLockupProps {
|
|
|
68
68
|
name: string;
|
|
69
69
|
/** The endorsement under it — `brandOf(codeName).endorsement[locale]` of `@krizaka/org` (« by Krizaka » / « par Krizaka »). */
|
|
70
70
|
endorsement: string;
|
|
71
|
+
/**
|
|
72
|
+
* The code name line under the endorsement — « code name: yomizaka » / « nom de code : yomizaka », worded by the app from its
|
|
73
|
+
* messages. Pass it on a development deployment only, so a person can tell the host (`yomizaka`) from the screen (« Verikora »);
|
|
74
|
+
* leave it out in production. The library holds no words.
|
|
75
|
+
*/
|
|
76
|
+
codeName?: string;
|
|
71
77
|
/**
|
|
72
78
|
* The mark's size in px; the words follow it (`sm` under 40 px, `md` from 40, `lg` from 64).
|
|
73
79
|
* @default 32
|
|
@@ -79,7 +85,12 @@ interface ProductLockupProps {
|
|
|
79
85
|
layout?: "stacked" | "inline";
|
|
80
86
|
className?: string;
|
|
81
87
|
}
|
|
82
|
-
|
|
88
|
+
/** The small code-name line of a lockup: for the bars that draw their own lockup markup, so the line looks the same everywhere. */
|
|
89
|
+
declare function CodeNameLine({ children, className }: Readonly<{
|
|
90
|
+
children: string;
|
|
91
|
+
className?: string;
|
|
92
|
+
}>): React.JSX.Element;
|
|
93
|
+
declare function ProductLockup({ id, name, endorsement, codeName, size, animated, layout, className }: Readonly<ProductLockupProps>): React.JSX.Element;
|
|
83
94
|
|
|
84
95
|
/**
|
|
85
96
|
* The Wu-sama mark — the founder's byline mark, for the person and not the company (the company keeps `KrizakaLogo`).
|
|
@@ -90,5 +101,5 @@ declare function WuSamaMark({ size, title, className }: Omit<MarkProps, "animate
|
|
|
90
101
|
animated?: boolean;
|
|
91
102
|
}): React.JSX.Element;
|
|
92
103
|
|
|
93
|
-
export { AkinazaLogo, AkinazaLogo as FoliovivLogo, KridocLogo, KrizakaLogo, OrazakaLogo, ProductLockup, ProductLogo, OrazakaLogo as SovkoraLogo, YomizakaLogo as VerikoraLogo, WuSamaMark, YomizakaLogo, cx };
|
|
104
|
+
export { AkinazaLogo, CodeNameLine, AkinazaLogo as FoliovivLogo, KridocLogo, KrizakaLogo, OrazakaLogo, ProductLockup, ProductLogo, OrazakaLogo as SovkoraLogo, YomizakaLogo as VerikoraLogo, WuSamaMark, YomizakaLogo, cx };
|
|
94
105
|
export type { BrandId, MarkId, MarkProps, ProductLockupProps };
|
package/dist/index.js
CHANGED
|
@@ -78,13 +78,17 @@ function textSize(size) {
|
|
|
78
78
|
if (size >= 40) return "text-lg";
|
|
79
79
|
return "text-base";
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function CodeNameLine({ children, className }) {
|
|
82
|
+
return /* @__PURE__ */ jsx2("span", { className: cx("font-mono text-xs text-fg-secondary", className), "data-code-name": "", children });
|
|
83
|
+
}
|
|
84
|
+
function ProductLockup({ id, name, endorsement, codeName, size = 32, animated = true, layout = "stacked", className }) {
|
|
82
85
|
const text = textSize(size);
|
|
83
86
|
return /* @__PURE__ */ jsxs2("span", { className: cx("inline-flex items-center gap-2.5", className), "data-brand": id, children: [
|
|
84
87
|
id === "kachizaka" ? /* @__PURE__ */ jsx2(KridocLogo, { size, animated }) : /* @__PURE__ */ jsx2(ProductLogo, { id, size, animated }),
|
|
85
88
|
/* @__PURE__ */ jsxs2("span", { className: cx("flex leading-tight", layout === "stacked" ? "flex-col" : "items-baseline gap-1.5"), children: [
|
|
86
89
|
/* @__PURE__ */ jsx2("span", { className: cx("font-semibold tracking-tight text-fg", text), children: name }),
|
|
87
|
-
/* @__PURE__ */ jsx2("span", { className: "text-xs text-fg-secondary", children: endorsement })
|
|
90
|
+
/* @__PURE__ */ jsx2("span", { className: "text-xs text-fg-secondary", children: endorsement }),
|
|
91
|
+
codeName ? /* @__PURE__ */ jsx2(CodeNameLine, { children: codeName }) : null
|
|
88
92
|
] })
|
|
89
93
|
] });
|
|
90
94
|
}
|
|
@@ -132,6 +136,7 @@ function WuSamaMark({ size = 32, title, className }) {
|
|
|
132
136
|
}
|
|
133
137
|
export {
|
|
134
138
|
AkinazaLogo,
|
|
139
|
+
CodeNameLine,
|
|
135
140
|
AkinazaLogo as FoliovivLogo,
|
|
136
141
|
KridocLogo,
|
|
137
142
|
KrizakaLogo,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/marks/kridoc-geometry.ts","../src/marks/KridocLogo.tsx","../src/marks/ProductLockup.tsx","../src/marks/wu-sama-geometry.ts","../src/marks/WuSamaMark.tsx"],"sourcesContent":["import { KRIZAKA } from \"./krizaka-geometry\";\n\n/**\n * The Kridoc mark's geometry (the managed storage, code name kachizaka; krizaka-internal#2035). Same grammar as the family\n * (a 360×360 artwork at (20, 20), one stroke of 22, an open figure whose end breaks out as a node, a core, a dashed orbit\n * and a ring). Kridoc is a service of the company, so it wears the **Krizaka** colours — ink figure, blue node and core.\n * The figure is a page with its corner folded: the stroke stays open at the fold, where the node — the share link — sits;\n * the core is the seal on the page (kept, audited).\n */\nexport const KRIDOC = {\n viewBox: KRIZAKA.viewBox,\n croppedViewBox: KRIZAKA.croppedViewBox,\n offset: KRIZAKA.offset,\n /** The page: from the fold, down the right edge, along the bottom, up the left edge and across the top, stopping short of the fold. */\n page: \"M248,140 L248,268 L112,268 L112,92 L190,92\",\n /** The folded corner: the crease from the top edge to the right edge. */\n fold: \"M214,92 L214,124 L248,124\",\n /** Two lines of text on the page. */\n lines: [\"M140,170 L214,170\", \"M140,206 L196,206\"],\n stroke: KRIZAKA.stroke,\n ink: KRIZAKA.ink,\n blue: KRIZAKA.blue,\n node: { cx: 248, cy: 92, r: 19, inner: 6 },\n core: { cx: 196, cy: 240, r: 20, inner: 7 },\n highlight: KRIZAKA.highlight,\n glow: KRIZAKA.glow,\n orbit: KRIZAKA.orbit,\n ring: KRIZAKA.ring,\n} as const;\n","import { InkMark } from \"./InkMark\";\nimport { KRIDOC as G } from \"./kridoc-geometry\";\nimport type { MarkProps } from \"./shared\";\n\nconst CSS = `\n.kdm-spin { transform-origin: 200px 200px; animation: kdm-spin 30s linear infinite; }\n.kdm-pulse { transform-box: fill-box; transform-origin: center; animation: kdm-pulse 3.2s ease-in-out infinite; }\n@keyframes kdm-spin { to { transform: rotate(360deg); } }\n@keyframes kdm-pulse { 0%, 100% { opacity: .9; } 50% { opacity: 1; } }\n@media (prefers-reduced-motion: reduce) { .kdm-spin, .kdm-pulse { animation: none; } }\n`;\n\nfunction figure(ink: string) {\n return (\n <>\n <path d={G.page} stroke={ink} strokeWidth={G.stroke} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n <path d={G.fold} stroke={ink} strokeWidth={G.stroke} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n {G.lines.map((d) => (\n <path key={d} d={d} stroke={ink} strokeWidth={G.stroke * 0.6} strokeLinecap=\"round\" />\n ))}\n </>\n );\n}\n\n/**\n * The Kridoc mark (the managed storage, sold as « Kridoc by Krizaka »): an ink page with its corner folded, open at the\n * fold where a blue node — the share link — breaks out, and a blue seal on the page. Krizaka's colours: a service of the\n * company. The orbit turns, the node and the seal breathe. Below 48 px it crops to the emblem.\n */\nexport function KridocLogo(props: Readonly<MarkProps>) {\n return (\n <InkMark\n {...props}\n prefix=\"kdm\"\n css={CSS}\n geometry={G}\n figure={figure}\n />\n );\n}\n","import { cx } from \"../cx\";\nimport { KridocLogo } from \"./KridocLogo\";\nimport { type MarkId, ProductLogo } from \"./ProductLogo\";\n\nexport interface ProductLockupProps {\n /** The brand by its code name (`yomizaka`): it picks the mark only, never the words. */\n id: MarkId;\n /** The name shown — `displayName(codeName, setting)` of `@krizaka/org`, so the administrator's choice wins (« Verikora »). */\n name: string;\n /** The endorsement under it — `brandOf(codeName).endorsement[locale]` of `@krizaka/org` (« by Krizaka » / « par Krizaka »). */\n endorsement: string;\n /**\n * The mark's size in px; the words follow it (`sm` under 40 px, `md` from 40, `lg` from 64).\n * @default 32\n */\n size?: number;\n /** @default true */\n animated?: boolean;\n /** `inline` puts the endorsement beside the name (a footer line); `stacked` under it (a bar, a hero, an email header). @default \"stacked\" */\n layout?: \"stacked\" | \"inline\";\n className?: string;\n}\n\n/**\n * The « Verikora by Krizaka » lockup (krizaka-internal#2035): the product's mark, its name, and the company that endorses\n * it — for heroes, bars, footers, emails and store art. The words are data passed in (from `@krizaka/org` and the app's\n * `brand.displayName` setting), never typed here; the mark is decorative, the name is the text a screen reader reads.\n */\nfunction textSize(size: number): string {\n if (size >= 64) return \"text-2xl\";\n if (size >= 40) return \"text-lg\";\n return \"text-base\";\n}\n\nexport function ProductLockup({ id, name, endorsement, size = 32, animated = true, layout = \"stacked\", className }: Readonly<ProductLockupProps>) {\n const text = textSize(size);\n return (\n <span className={cx(\"inline-flex items-center gap-2.5\", className)} data-brand={id}>\n {id === \"kachizaka\" ? <KridocLogo size={size} animated={animated} /> : <ProductLogo id={id} size={size} animated={animated} />}\n <span className={cx(\"flex leading-tight\", layout === \"stacked\" ? \"flex-col\" : \"items-baseline gap-1.5\")}>\n <span className={cx(\"font-semibold tracking-tight text-fg\", text)}>{name}</span>\n <span className=\"text-xs text-fg-secondary\">{endorsement}</span>\n </span>\n </span>\n );\n}\n","import { marks } from \"@krizaka/tokens/native\";\n\n/**\n * The Wu-sama mark's geometry — the founder's byline mark.\n * It shares the Krizaka shield contour (pointy-top hexagonal shield with open vertex and lit node)\n * and brand colors, holding a W of five straight legs in Krizaka blue at its center.\n */\nexport const WU_SAMA = {\n viewBox: \"0 0 400 400\",\n croppedViewBox: \"86 82 228 228\",\n offset: 20,\n /** The shield: the Krizaka pointy-top hexagon (r 92 around 180,180), open at its upper-right edge. */\n shield: \"M259.7,134 L259.7,226 L180,272 L100.3,226 L100.3,134 L180,88 L212,106.5\",\n stroke: 22,\n ink: { x1: 70, y1: 290, x2: 290, y2: 70 },\n blue: { x1: 180, y1: 180, x2: 300, y2: 60, stops: marks.krizaka },\n /** The vertex where the shield opens: a lit node in Krizaka blue. */\n node: { cx: 259.7, cy: 134, r: 19, inner: 6 },\n /** The W: five straight legs in Krizaka blue. */\n w: \"M132,142 L154,216 L180,166 L206,216 L228,142\",\n wStroke: 18,\n highlight: \"#ddeaf4\",\n glow: { color: marks.krizaka[0]![1], opacity: 0.16 },\n orbit: { r: 160, dash: \"8 8\", width: 1.5 },\n ring: { r: 134, width: 1 },\n} as const;\n","import { InkDefs } from \"./InkMark\";\nimport { a11y, type MarkProps, neutral, useIds } from \"./shared\";\nimport { WU_SAMA as G } from \"./wu-sama-geometry\";\n\n/**\n * The Wu-sama mark — the founder's byline mark, for the person and not the company (the company keeps `KrizakaLogo`).\n * Oussama's nickname is Wu-sama: it shares Krizaka's hexagonal shield contour and color palette (ink shield, open\n * vertex with lit blue node), with the W rendered in Krizaka blue at the center. Below 48 px it crops to the emblem.\n */\nexport function WuSamaMark({ size = 32, title, className }: Omit<MarkProps, \"animated\"> & { animated?: boolean }) {\n const id = useIds(\"wsm\", [\"ink\", \"blue\", \"glow\"] as const);\n return (\n <svg width={size} height={size} viewBox={size < 48 ? G.croppedViewBox : G.viewBox} fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" className={className} {...a11y(title)}>\n <InkDefs ids={id} geometry={G} />\n {size >= 48 ? <circle cx=\"200\" cy=\"200\" r=\"190\" fill={`url(#${id.glow})`} /> : null}\n {size >= 48 ? (\n <>\n <circle cx=\"200\" cy=\"200\" r={G.orbit.r} stroke={neutral(\"--kz-border-strong\", 40)} strokeWidth={G.orbit.width} strokeDasharray={G.orbit.dash} opacity=\".6\" />\n <circle cx=\"200\" cy=\"200\" r={G.ring.r} stroke={neutral(\"--kz-border-default\", 30)} strokeWidth={G.ring.width} opacity=\".35\" />\n </>\n ) : null}\n <g transform={`translate(${G.offset} ${G.offset})`}>\n <path d={G.shield} stroke={`url(#${id.ink})`} strokeWidth={G.stroke} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n <circle cx={G.node.cx} cy={G.node.cy} r={G.node.r} fill={`url(#${id.blue})`} />\n <circle cx={G.node.cx} cy={G.node.cy} r={G.node.inner} fill={G.highlight} />\n <path d={G.w} stroke={`url(#${id.blue})`} strokeWidth={G.wStroke} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </g>\n </svg>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AASO,IAAM,SAAS;AAAA,EACpB,SAAS,QAAQ;AAAA,EACjB,gBAAgB,QAAQ;AAAA,EACxB,QAAQ,QAAQ;AAAA;AAAA,EAEhB,MAAM;AAAA;AAAA,EAEN,MAAM;AAAA;AAAA,EAEN,OAAO,CAA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AAQ,QAAQ,GAAG,IAAI,KAAK,aAAa,QAAE,SAAS,eAAc,SAAQ,gBAAe,SAAQ;AAAA,OACjH;AAAA,KACF;AAEJ;","names":["jsx","jsxs","Fragment","jsx","jsxs"]}
|
|
1
|
+
{"version":3,"sources":["../src/marks/kridoc-geometry.ts","../src/marks/KridocLogo.tsx","../src/marks/ProductLockup.tsx","../src/marks/wu-sama-geometry.ts","../src/marks/WuSamaMark.tsx"],"sourcesContent":["import { KRIZAKA } from \"./krizaka-geometry\";\n\n/**\n * The Kridoc mark's geometry (the managed storage, code name kachizaka; krizaka-internal#2035). Same grammar as the family\n * (a 360×360 artwork at (20, 20), one stroke of 22, an open figure whose end breaks out as a node, a core, a dashed orbit\n * and a ring). Kridoc is a service of the company, so it wears the **Krizaka** colours — ink figure, blue node and core.\n * The figure is a page with its corner folded: the stroke stays open at the fold, where the node — the share link — sits;\n * the core is the seal on the page (kept, audited).\n */\nexport const KRIDOC = {\n viewBox: KRIZAKA.viewBox,\n croppedViewBox: KRIZAKA.croppedViewBox,\n offset: KRIZAKA.offset,\n /** The page: from the fold, down the right edge, along the bottom, up the left edge and across the top, stopping short of the fold. */\n page: \"M248,140 L248,268 L112,268 L112,92 L190,92\",\n /** The folded corner: the crease from the top edge to the right edge. */\n fold: \"M214,92 L214,124 L248,124\",\n /** Two lines of text on the page. */\n lines: [\"M140,170 L214,170\", \"M140,206 L196,206\"],\n stroke: KRIZAKA.stroke,\n ink: KRIZAKA.ink,\n blue: KRIZAKA.blue,\n node: { cx: 248, cy: 92, r: 19, inner: 6 },\n core: { cx: 196, cy: 240, r: 20, inner: 7 },\n highlight: KRIZAKA.highlight,\n glow: KRIZAKA.glow,\n orbit: KRIZAKA.orbit,\n ring: KRIZAKA.ring,\n} as const;\n","import { InkMark } from \"./InkMark\";\nimport { KRIDOC as G } from \"./kridoc-geometry\";\nimport type { MarkProps } from \"./shared\";\n\nconst CSS = `\n.kdm-spin { transform-origin: 200px 200px; animation: kdm-spin 30s linear infinite; }\n.kdm-pulse { transform-box: fill-box; transform-origin: center; animation: kdm-pulse 3.2s ease-in-out infinite; }\n@keyframes kdm-spin { to { transform: rotate(360deg); } }\n@keyframes kdm-pulse { 0%, 100% { opacity: .9; } 50% { opacity: 1; } }\n@media (prefers-reduced-motion: reduce) { .kdm-spin, .kdm-pulse { animation: none; } }\n`;\n\nfunction figure(ink: string) {\n return (\n <>\n <path d={G.page} stroke={ink} strokeWidth={G.stroke} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n <path d={G.fold} stroke={ink} strokeWidth={G.stroke} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n {G.lines.map((d) => (\n <path key={d} d={d} stroke={ink} strokeWidth={G.stroke * 0.6} strokeLinecap=\"round\" />\n ))}\n </>\n );\n}\n\n/**\n * The Kridoc mark (the managed storage, sold as « Kridoc by Krizaka »): an ink page with its corner folded, open at the\n * fold where a blue node — the share link — breaks out, and a blue seal on the page. Krizaka's colours: a service of the\n * company. The orbit turns, the node and the seal breathe. Below 48 px it crops to the emblem.\n */\nexport function KridocLogo(props: Readonly<MarkProps>) {\n return (\n <InkMark\n {...props}\n prefix=\"kdm\"\n css={CSS}\n geometry={G}\n figure={figure}\n />\n );\n}\n","import { cx } from \"../cx\";\nimport { KridocLogo } from \"./KridocLogo\";\nimport { type MarkId, ProductLogo } from \"./ProductLogo\";\n\nexport interface ProductLockupProps {\n /** The brand by its code name (`yomizaka`): it picks the mark only, never the words. */\n id: MarkId;\n /** The name shown — `displayName(codeName, setting)` of `@krizaka/org`, so the administrator's choice wins (« Verikora »). */\n name: string;\n /** The endorsement under it — `brandOf(codeName).endorsement[locale]` of `@krizaka/org` (« by Krizaka » / « par Krizaka »). */\n endorsement: string;\n /**\n * The code name line under the endorsement — « code name: yomizaka » / « nom de code : yomizaka », worded by the app from its\n * messages. Pass it on a development deployment only, so a person can tell the host (`yomizaka`) from the screen (« Verikora »);\n * leave it out in production. The library holds no words.\n */\n codeName?: string;\n /**\n * The mark's size in px; the words follow it (`sm` under 40 px, `md` from 40, `lg` from 64).\n * @default 32\n */\n size?: number;\n /** @default true */\n animated?: boolean;\n /** `inline` puts the endorsement beside the name (a footer line); `stacked` under it (a bar, a hero, an email header). @default \"stacked\" */\n layout?: \"stacked\" | \"inline\";\n className?: string;\n}\n\n/**\n * The « Verikora by Krizaka » lockup (krizaka-internal#2035): the product's mark, its name, and the company that endorses\n * it — for heroes, bars, footers, emails and store art. The words are data passed in (from `@krizaka/org` and the app's\n * `brand.displayName` setting), never typed here; the mark is decorative, the name is the text a screen reader reads.\n */\nfunction textSize(size: number): string {\n if (size >= 64) return \"text-2xl\";\n if (size >= 40) return \"text-lg\";\n return \"text-base\";\n}\n\n/** The small code-name line of a lockup: for the bars that draw their own lockup markup, so the line looks the same everywhere. */\nexport function CodeNameLine({ children, className }: Readonly<{ children: string; className?: string }>) {\n return (\n <span className={cx(\"font-mono text-xs text-fg-secondary\", className)} data-code-name=\"\">\n {children}\n </span>\n );\n}\n\nexport function ProductLockup({ id, name, endorsement, codeName, size = 32, animated = true, layout = \"stacked\", className }: Readonly<ProductLockupProps>) {\n const text = textSize(size);\n return (\n <span className={cx(\"inline-flex items-center gap-2.5\", className)} data-brand={id}>\n {id === \"kachizaka\" ? <KridocLogo size={size} animated={animated} /> : <ProductLogo id={id} size={size} animated={animated} />}\n <span className={cx(\"flex leading-tight\", layout === \"stacked\" ? \"flex-col\" : \"items-baseline gap-1.5\")}>\n <span className={cx(\"font-semibold tracking-tight text-fg\", text)}>{name}</span>\n <span className=\"text-xs text-fg-secondary\">{endorsement}</span>\n {codeName ? <CodeNameLine>{codeName}</CodeNameLine> : null}\n </span>\n </span>\n );\n}\n","import { marks } from \"@krizaka/tokens/native\";\n\n/**\n * The Wu-sama mark's geometry — the founder's byline mark.\n * It shares the Krizaka shield contour (pointy-top hexagonal shield with open vertex and lit node)\n * and brand colors, holding a W of five straight legs in Krizaka blue at its center.\n */\nexport const WU_SAMA = {\n viewBox: \"0 0 400 400\",\n croppedViewBox: \"86 82 228 228\",\n offset: 20,\n /** The shield: the Krizaka pointy-top hexagon (r 92 around 180,180), open at its upper-right edge. */\n shield: \"M259.7,134 L259.7,226 L180,272 L100.3,226 L100.3,134 L180,88 L212,106.5\",\n stroke: 22,\n ink: { x1: 70, y1: 290, x2: 290, y2: 70 },\n blue: { x1: 180, y1: 180, x2: 300, y2: 60, stops: marks.krizaka },\n /** The vertex where the shield opens: a lit node in Krizaka blue. */\n node: { cx: 259.7, cy: 134, r: 19, inner: 6 },\n /** The W: five straight legs in Krizaka blue. */\n w: \"M132,142 L154,216 L180,166 L206,216 L228,142\",\n wStroke: 18,\n highlight: \"#ddeaf4\",\n glow: { color: marks.krizaka[0]![1], opacity: 0.16 },\n orbit: { r: 160, dash: \"8 8\", width: 1.5 },\n ring: { r: 134, width: 1 },\n} as const;\n","import { InkDefs } from \"./InkMark\";\nimport { a11y, type MarkProps, neutral, useIds } from \"./shared\";\nimport { WU_SAMA as G } from \"./wu-sama-geometry\";\n\n/**\n * The Wu-sama mark — the founder's byline mark, for the person and not the company (the company keeps `KrizakaLogo`).\n * Oussama's nickname is Wu-sama: it shares Krizaka's hexagonal shield contour and color palette (ink shield, open\n * vertex with lit blue node), with the W rendered in Krizaka blue at the center. Below 48 px it crops to the emblem.\n */\nexport function WuSamaMark({ size = 32, title, className }: Omit<MarkProps, \"animated\"> & { animated?: boolean }) {\n const id = useIds(\"wsm\", [\"ink\", \"blue\", \"glow\"] as const);\n return (\n <svg width={size} height={size} viewBox={size < 48 ? G.croppedViewBox : G.viewBox} fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" className={className} {...a11y(title)}>\n <InkDefs ids={id} geometry={G} />\n {size >= 48 ? <circle cx=\"200\" cy=\"200\" r=\"190\" fill={`url(#${id.glow})`} /> : null}\n {size >= 48 ? (\n <>\n <circle cx=\"200\" cy=\"200\" r={G.orbit.r} stroke={neutral(\"--kz-border-strong\", 40)} strokeWidth={G.orbit.width} strokeDasharray={G.orbit.dash} opacity=\".6\" />\n <circle cx=\"200\" cy=\"200\" r={G.ring.r} stroke={neutral(\"--kz-border-default\", 30)} strokeWidth={G.ring.width} opacity=\".35\" />\n </>\n ) : null}\n <g transform={`translate(${G.offset} ${G.offset})`}>\n <path d={G.shield} stroke={`url(#${id.ink})`} strokeWidth={G.stroke} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n <circle cx={G.node.cx} cy={G.node.cy} r={G.node.r} fill={`url(#${id.blue})`} />\n <circle cx={G.node.cx} cy={G.node.cy} r={G.node.inner} fill={G.highlight} />\n <path d={G.w} stroke={`url(#${id.blue})`} strokeWidth={G.wStroke} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </g>\n </svg>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AASO,IAAM,SAAS;AAAA,EACpB,SAAS,QAAQ;AAAA,EACjB,gBAAgB,QAAQ;AAAA,EACxB,QAAQ,QAAQ;AAAA;AAAA,EAEhB,MAAM;AAAA;AAAA,EAEN,MAAM;AAAA;AAAA,EAEN,OAAO,CAAC,qBAAqB,mBAAmB;AAAA,EAChD,QAAQ,QAAQ;AAAA,EAChB,KAAK,QAAQ;AAAA,EACb,MAAM,QAAQ;AAAA,EACd,MAAM,EAAE,IAAI,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,EAAE;AAAA,EACzC,MAAM,EAAE,IAAI,KAAK,IAAI,KAAK,GAAG,IAAI,OAAO,EAAE;AAAA,EAC1C,WAAW,QAAQ;AAAA,EACnB,MAAM,QAAQ;AAAA,EACd,OAAO,QAAQ;AAAA,EACf,MAAM,QAAQ;AAChB;;;ACdI,mBACE,KADF;AAVJ,IAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQZ,SAAS,OAAO,KAAa;AAC3B,SACE,iCACE;AAAA,wBAAC,UAAK,GAAG,OAAE,MAAM,QAAQ,KAAK,aAAa,OAAE,QAAQ,eAAc,SAAQ,gBAAe,SAAQ;AAAA,IAClG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AAC,YAAO,IAAG,OAAM,IAAG,OAAM,GAAG,QAAE,MAAM,GAAG,QAAQ,QAAQ,sBAAsB,EAAE,GAAG,aAAa,QAAE,MAAM,OAAO,iBAAiB,QAAE,MAAM,MAAM,SAAQ,MAAK;AAAA,MAC3J,gBAAAA,KAAC,YAAO,IAAG,OAAM,IAAG,OAAM,GAAG,QAAE,KAAK,GAAG,QAAQ,QAAQ,uBAAuB,EAAE,GAAG,aAAa,QAAE,KAAK,OAAO,SAAQ,OAAM;AAAA,OAC9H,IACE;AAAA,IACJ,gBAAAC,MAAC,OAAE,WAAW,aAAa,QAAE,MAAM,IAAI,QAAE,MAAM,KAC7C;AAAA,sBAAAD,KAAC,UAAK,GAAG,QAAE,QAAQ,QAAQ,QAAQ,GAAG,GAAG,KAAK,aAAa,QAAE,QAAQ,eAAc,SAAQ,gBAAe,SAAQ;AAAA,MAClH,gBAAAA,KAAC,YAAO,IAAI,QAAE,KAAK,IAAI,IAAI,QAAE,KAAK,IAAI,GAAG,QAAE,KAAK,GAAG,MAAM,QAAQ,GAAG,IAAI,KAAK;AAAA,MAC7E,gBAAAA,KAAC,YAAO,IAAI,QAAE,KAAK,IAAI,IAAI,QAAE,KAAK,IAAI,GAAG,QAAE,KAAK,OAAO,MAAM,QAAE,WAAW;AAAA,MAC1E,gBAAAA,KAAC,UAAK,GAAG,QAAE,GAAG,QAAQ,QAAQ,GAAG,IAAI,KAAK,aAAa,QAAE,SAAS,eAAc,SAAQ,gBAAe,SAAQ;AAAA,OACjH;AAAA,KACF;AAEJ;","names":["jsx","jsxs","Fragment","jsx","jsxs"]}
|
package/dist/media-carousel.d.ts
CHANGED
|
@@ -78,13 +78,13 @@ type CarouselSlide = {
|
|
|
78
78
|
alt: string;
|
|
79
79
|
/** « Fig. 1a »: one line over the foot of the slide. */
|
|
80
80
|
caption?: string;
|
|
81
|
-
/** A muted loop playing while the slide is the one in view. */
|
|
81
|
+
/** A muted loop playing while the slide is the one in view and on screen, after the page's `load`, with a visible pause; a still under reduced motion. On a `film` slide it previews the film. */
|
|
82
82
|
video?: {
|
|
83
83
|
webm?: string;
|
|
84
84
|
mp4?: string;
|
|
85
85
|
};
|
|
86
86
|
/** A film opened by a press, with sound, in the lightbox of the MediaPlayer. */
|
|
87
|
-
film?: Pick<MediaPlayerProps, "src" | "title" | "tracks" | "loadHls"> & {
|
|
87
|
+
film?: Pick<MediaPlayerProps, "src" | "title" | "tracks" | "loadHls" | "labels" | "ratio"> & {
|
|
88
88
|
playLabel: string;
|
|
89
89
|
vertical?: boolean;
|
|
90
90
|
};
|
|
@@ -105,9 +105,16 @@ type MediaCarouselProps = Omit<React.ComponentProps<"section">, "children"> & {
|
|
|
105
105
|
ratio?: string;
|
|
106
106
|
/** The words, passed translated; English by default. `slide` takes `{n}` and `{total}`. */
|
|
107
107
|
labels?: Partial<MediaCarouselLabels>;
|
|
108
|
+
/** The words of the lightbox player of every film (speed, captions, time…), passed translated; a slide's own `film.labels` wins. */
|
|
109
|
+
playerLabels?: MediaPlayerProps["labels"];
|
|
110
|
+
/** Draws a slide's `video`: `(video, { poster, inView }) => <PausableLoop sources={video} poster={poster} active={inView} />` (`@krizaka/ui/pausable-loop`, which brings the pause and play). Without it a slide stays a still, and this entry stays light. */
|
|
111
|
+
renderLoop?: (video: NonNullable<CarouselSlide["video"]>, context: {
|
|
112
|
+
poster: string;
|
|
113
|
+
inView: boolean;
|
|
114
|
+
}) => React.ReactNode;
|
|
108
115
|
};
|
|
109
116
|
/** A few realisations in one frame, one at a time: swipe, buttons or arrow keys on them; nothing advances by itself. */
|
|
110
|
-
declare function MediaCarousel({ slides, label, ratio, labels: given, className, ...props }: Readonly<MediaCarouselProps>): React.JSX.Element;
|
|
117
|
+
declare function MediaCarousel({ slides, label, ratio, labels: given, playerLabels, renderLoop, className, ...props }: Readonly<MediaCarouselProps>): React.JSX.Element;
|
|
111
118
|
|
|
112
119
|
export { MediaCarousel, mediaCarousel, mediaCarouselLabels };
|
|
113
120
|
export type { CarouselSlide, MediaCarouselLabels, MediaCarouselProps };
|
package/dist/media-carousel.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
MediaPlayer
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-GOGEYAYK.js";
|
|
5
5
|
import {
|
|
6
6
|
IconButton
|
|
7
7
|
} from "./chunk-QHVV2JGF.js";
|
|
@@ -44,7 +44,7 @@ function useActiveSlide(track, count) {
|
|
|
44
44
|
setActive(next);
|
|
45
45
|
return next;
|
|
46
46
|
};
|
|
47
|
-
return { active, go
|
|
47
|
+
return { active, go };
|
|
48
48
|
}
|
|
49
49
|
function useSwipe(turn) {
|
|
50
50
|
const from = React.useRef(null);
|
|
@@ -65,31 +65,40 @@ function useSwipe(turn) {
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
function keepFocus(toolbar, at, count) {
|
|
68
|
-
if (!toolbar?.contains(document.activeElement)
|
|
68
|
+
if (!toolbar?.contains(document.activeElement)) return;
|
|
69
69
|
const [previous, next] = toolbar.querySelectorAll("button");
|
|
70
70
|
if (at === 0) next?.focus();
|
|
71
71
|
if (at === count - 1) previous?.focus();
|
|
72
72
|
}
|
|
73
73
|
var ARROWS = { ArrowRight: 1, ArrowLeft: -1 };
|
|
74
|
-
function SlideMedia({ slide,
|
|
74
|
+
function SlideMedia({ slide, loop, ratio, closeLabel, playerLabels }) {
|
|
75
75
|
if (slide.film) {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
MediaPlayer,
|
|
78
|
+
{
|
|
79
|
+
...slide.film,
|
|
80
|
+
labels: slide.film.labels ?? playerLabels,
|
|
81
|
+
mode: "lightbox",
|
|
82
|
+
poster: slide.src,
|
|
83
|
+
posterAlt: slide.alt,
|
|
84
|
+
caption: slide.caption,
|
|
85
|
+
closeLabel,
|
|
86
|
+
preview: loop,
|
|
87
|
+
className: "h-full rounded-none border-0"
|
|
88
|
+
}
|
|
89
|
+
);
|
|
78
90
|
}
|
|
79
91
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
80
92
|
/* @__PURE__ */ jsx("img", { src: slide.src, alt: slide.alt, loading: "lazy", decoding: "async", draggable: false, className: s.media(), style: { aspectRatio: ratio } }),
|
|
81
|
-
|
|
82
|
-
slide.video.webm && /* @__PURE__ */ jsx("source", { src: slide.video.webm, type: "video/webm" }),
|
|
83
|
-
slide.video.mp4 && /* @__PURE__ */ jsx("source", { src: slide.video.mp4, type: "video/mp4" })
|
|
84
|
-
] }),
|
|
93
|
+
loop,
|
|
85
94
|
slide.caption && /* @__PURE__ */ jsx("figcaption", { className: s.caption(), children: slide.caption })
|
|
86
95
|
] });
|
|
87
96
|
}
|
|
88
|
-
function MediaCarousel({ slides, label, ratio = "16 / 10", labels: given, className, ...props }) {
|
|
97
|
+
function MediaCarousel({ slides, label, ratio = "16 / 10", labels: given, playerLabels, renderLoop, className, ...props }) {
|
|
89
98
|
const labels = { ...mediaCarouselLabels, ...given };
|
|
90
99
|
const track = React.useRef(null);
|
|
91
100
|
const toolbar = React.useRef(null);
|
|
92
|
-
const { active, go
|
|
101
|
+
const { active, go } = useActiveSlide(track, slides.length);
|
|
93
102
|
const turn = (delta) => keepFocus(toolbar.current, go(active + delta), slides.length);
|
|
94
103
|
const swipe = useSwipe(turn);
|
|
95
104
|
const keys = (event) => {
|
|
@@ -100,8 +109,8 @@ function MediaCarousel({ slides, label, ratio = "16 / 10", labels: given, classN
|
|
|
100
109
|
};
|
|
101
110
|
const name = (i) => labels.slide.replace("{n}", String(i + 1)).replace("{total}", String(slides.length));
|
|
102
111
|
return /* @__PURE__ */ jsxs("section", { "aria-roledescription": "carousel", "aria-label": label, className: s.root({ className }), ...props, children: [
|
|
103
|
-
/* @__PURE__ */ jsx("ul", { ref: track, className: s.track(), ...swipe, children: slides.map((slide, i) => /* @__PURE__ */ jsx("li", { "aria-roledescription": "slide", "aria-label": name(i), className: s.slide(), style: { aspectRatio: ratio }, "aria-hidden": i === active ? void 0 : true, inert: i === active ? void 0 : true, children: /* @__PURE__ */ jsx("figure", { className: "m-0 h-full w-full", children: /* @__PURE__ */ jsx(SlideMedia, { slide,
|
|
104
|
-
/* @__PURE__ */ jsxs("div", { className: s.bar(), children: [
|
|
112
|
+
/* @__PURE__ */ jsx("ul", { ref: track, className: s.track(), ...swipe, children: slides.map((slide, i) => /* @__PURE__ */ jsx("li", { "aria-roledescription": "slide", "aria-label": name(i), className: s.slide(), style: { aspectRatio: ratio }, "aria-hidden": i === active ? void 0 : true, inert: i === active ? void 0 : true, children: /* @__PURE__ */ jsx("figure", { className: "m-0 h-full w-full", children: /* @__PURE__ */ jsx(SlideMedia, { slide, loop: slide.video && renderLoop?.(slide.video, { poster: slide.src, inView: i === active }), ratio, closeLabel: labels.close, playerLabels }) }) }, slide.id)) }),
|
|
113
|
+
slides.length > 1 && /* @__PURE__ */ jsxs("div", { className: s.bar(), children: [
|
|
105
114
|
/* @__PURE__ */ jsxs("span", { className: s.count(), "aria-live": "polite", children: [
|
|
106
115
|
active + 1,
|
|
107
116
|
" / ",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/media-gallery/media-carousel.tsx"],"sourcesContent":["// Client (the slide in view, the reader's motion preference). A few realisations in one frame: a scroll-snap track moved by\n// a swipe, previous / next buttons in a toolbar that also takes the arrow keys, a « n / N » count. Nothing advances by itself and nothing moves under the pointer; a loop plays only on the\n// slide in view (a still under reduced motion); a slide with a film opens it in the MediaPlayer lightbox.\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { IconButton } from \"../button/button\";\nimport { ChevronGlyph } from \"../glyphs\";\nimport { usePrefersReducedMotion } from \"../media\";\nimport { MediaPlayer, type MediaPlayerProps } from \"./media-player\";\n\nexport const mediaCarousel = tv({\n slots: {\n root: \"relative isolate w-full\",\n track: \"m-0 flex list-none snap-x snap-mandatory gap-3 overflow-hidden p-0 touch-pan-y\",\n slide: \"relative m-0 w-full shrink-0 snap-center overflow-hidden rounded-xl border border-border-default bg-media\",\n media: \"absolute inset-0 h-full w-full object-cover\",\n caption: \"absolute inset-x-0 bottom-0 bg-linear-to-t from-scrim-strong to-transparent p-3 pt-8 text-xs font-semibold text-fg-on-media\",\n bar: \"mt-3 flex items-center justify-between gap-3\",\n count: \"text-xs tabular-nums text-fg-secondary\",\n buttons: \"flex gap-2\",\n },\n});\nconst s = mediaCarousel();\n\nexport type CarouselSlide = {\n /** A stable id. */\n id: string;\n /** The still, or the poster of a loop or a film. */\n src: string;\n /** What it shows, in words. */\n alt: string;\n /** « Fig. 1a »: one line over the foot of the slide. */\n caption?: string;\n /** A muted loop playing while the slide is the one in view. */\n video?: { webm?: string; mp4?: string };\n /** A film opened by a press, with sound, in the lightbox of the MediaPlayer. */\n film?: Pick<MediaPlayerProps, \"src\" | \"title\" | \"tracks\" | \"loadHls\"> & { playLabel: string; vertical?: boolean };\n};\n\nexport type MediaCarouselLabels = { previous: string; next: string; close: string; slide: string };\nexport const mediaCarouselLabels: MediaCarouselLabels = { previous: \"Previous\", next: \"Next\", close: \"Close\", slide: \"{n} of {total}\" };\n\nexport type MediaCarouselProps = Omit<React.ComponentProps<\"section\">, \"children\"> & {\n /** The slides, in order: 3 to 4 realisations. */\n slides: readonly CarouselSlide[];\n /** The carousel's accessible name, passed translated. */\n label: string;\n /** The frame ratio of every slide (width / height). Default `16 / 10`. */\n ratio?: string;\n /** The words, passed translated; English by default. `slide` takes `{n}` and `{total}`. */\n labels?: Partial<MediaCarouselLabels>;\n};\n\n/** How far a swipe travels, in CSS pixels, before it turns the slide. */\nconst SWIPE_DISTANCE = 40;\n\n/** The slide in view and the one way to change it: the track scrolls only from here, so it holds no scroll of its own to reach. */\nfunction useActiveSlide(track: React.RefObject<HTMLUListElement | null>, count: number) {\n const [active, setActive] = React.useState(0);\n const reduce = usePrefersReducedMotion();\n const go = (to: number) => {\n const el = track.current;\n if (!el) return active;\n const next = Math.min(count - 1, Math.max(0, to));\n el.scrollTo({ left: next * (el.scrollWidth / count), behavior: reduce ? \"auto\" : \"smooth\" });\n setActive(next);\n return next;\n };\n return { active, go, reduce };\n}\n\n/** A horizontal swipe on the track turns one slide; a vertical one stays the page's scroll (`touch-action: pan-y`). */\nfunction useSwipe(turn: (delta: 1 | -1) => void) {\n const from = React.useRef<number | null>(null);\n return {\n onPointerDown: (event: React.PointerEvent) => {\n from.current = event.clientX;\n },\n onPointerUp: (event: React.PointerEvent) => {\n const start = from.current;\n from.current = null;\n if (start === null) return;\n const distance = event.clientX - start;\n if (Math.abs(distance) >= SWIPE_DISTANCE) turn(distance < 0 ? 1 : -1);\n },\n onPointerCancel: () => {\n from.current = null;\n },\n };\n}\n\n/** At an end the button just used is disabled: the focus moves to the other one, never to the page. */\nfunction keepFocus(toolbar: HTMLElement | null, at: number, count: number) {\n if (!toolbar?.contains(document.activeElement) || count < 2) return;\n const [previous, next] = toolbar.querySelectorAll(\"button\");\n if (at === 0) next?.focus();\n if (at === count - 1) previous?.focus();\n}\n\n/** The arrow keys of the toolbar: right turns forward, left back. */\nconst ARROWS: Partial<Record<string, 1 | -1>> = { ArrowRight: 1, ArrowLeft: -1 };\n\nfunction SlideMedia({ slide, playing, ratio, closeLabel }: Readonly<{ slide: CarouselSlide; playing: boolean; ratio: string; closeLabel: string }>) {\n if (slide.film) {\n const { playLabel, vertical, ...film } = slide.film;\n return <MediaPlayer {...film} mode=\"lightbox\" poster={slide.src} posterAlt={slide.alt} playLabel={playLabel} vertical={vertical} caption={slide.caption} closeLabel={closeLabel} className=\"h-full rounded-none border-0\" />;\n }\n return (\n <>\n <img src={slide.src} alt={slide.alt} loading=\"lazy\" decoding=\"async\" draggable={false} className={s.media()} style={{ aspectRatio: ratio }} />\n {playing && slide.video && (\n <video className={s.media()} poster={slide.src} autoPlay muted loop playsInline aria-hidden tabIndex={-1}>\n {slide.video.webm && <source src={slide.video.webm} type=\"video/webm\" />}\n {slide.video.mp4 && <source src={slide.video.mp4} type=\"video/mp4\" />}\n </video>\n )}\n {slide.caption && <figcaption className={s.caption()}>{slide.caption}</figcaption>}\n </>\n );\n}\n\n/** A few realisations in one frame, one at a time: swipe, buttons or arrow keys on them; nothing advances by itself. */\nexport function MediaCarousel({ slides, label, ratio = \"16 / 10\", labels: given, className, ...props }: Readonly<MediaCarouselProps>) {\n const labels = { ...mediaCarouselLabels, ...given };\n const track = React.useRef<HTMLUListElement>(null);\n const toolbar = React.useRef<HTMLDivElement>(null);\n const { active, go, reduce } = useActiveSlide(track, slides.length);\n const turn = (delta: 1 | -1) => keepFocus(toolbar.current, go(active + delta), slides.length);\n const swipe = useSwipe(turn);\n const keys = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const delta = ARROWS[event.key];\n if (!delta) return;\n event.preventDefault();\n turn(delta);\n };\n const name = (i: number) => labels.slide.replace(\"{n}\", String(i + 1)).replace(\"{total}\", String(slides.length));\n return (\n <section aria-roledescription=\"carousel\" aria-label={label} className={s.root({ className })} {...props}>\n <ul ref={track} className={s.track()} {...swipe}>\n {slides.map((slide, i) => (\n <li key={slide.id} aria-roledescription=\"slide\" aria-label={name(i)} className={s.slide()} style={{ aspectRatio: ratio }} aria-hidden={i === active ? undefined : true} inert={i === active ? undefined : true}>\n <figure className=\"m-0 h-full w-full\">\n <SlideMedia slide={slide} playing={i === active && !reduce} ratio={ratio} closeLabel={labels.close} />\n </figure>\n </li>\n ))}\n </ul>\n <div className={s.bar()}>\n <span className={s.count()} aria-live=\"polite\">{active + 1} / {slides.length}</span>\n <div ref={toolbar} role=\"toolbar\" aria-orientation=\"horizontal\" className={s.buttons()} onKeyDown={keys}>\n <IconButton variant=\"secondary\" label={labels.previous} disabled={active === 0} onClick={() => turn(-1)}>\n <ChevronGlyph direction=\"left\" className=\"h-5 w-5\" />\n </IconButton>\n <IconButton variant=\"secondary\" label={labels.next} disabled={active === slides.length - 1} onClick={() => turn(1)}>\n <ChevronGlyph direction=\"right\" className=\"h-5 w-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AE,IAAI,GACpB;AAAA,2BAAC,UAAK,WAAW,EAAE,MAAM,GAAG,aAAU,UAAU;AAAA,iBAAS;AAAA,QAAE;AAAA,QAAI,OAAO;AAAA,SAAO;AAAA,MAC7E,qBAAC,SAAI,KAAK,SAAS,MAAK,WAAU,oBAAiB,cAAa,WAAW,EAAE,QAAQ,GAAG,WAAW,MACjG;AAAA,4BAAC,cAAW,SAAQ,aAAY,OAAO,OAAO,UAAU,UAAU,WAAW,GAAG,SAAS,MAAM,KAAK,EAAE,GACpG,8BAAC,gBAAa,WAAU,QAAO,WAAU,WAAU,GACrD;AAAA,QACA,oBAAC,cAAW,SAAQ,aAAY,OAAO,OAAO,MAAM,UAAU,WAAW,OAAO,SAAS,GAAG,SAAS,MAAM,KAAK,CAAC,GAC/G,8BAAC,gBAAa,WAAU,SAAQ,WAAU,WAAU,GACtD;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/media-gallery/media-carousel.tsx"],"sourcesContent":["// Client (the slide in view, the reader's motion preference). A few realisations in one frame: a scroll-snap track moved by\n// a swipe, previous / next buttons in a toolbar that also takes the arrow keys, a « n / N » count. Nothing advances by itself and nothing moves under the pointer; a loop plays only on the\n// slide in view (a still under reduced motion); a slide with a film opens it in the MediaPlayer lightbox.\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { IconButton } from \"../button/button\";\nimport { ChevronGlyph } from \"../glyphs\";\nimport { usePrefersReducedMotion } from \"../media\";\nimport { MediaPlayer, type MediaPlayerProps } from \"./media-player\";\n\nexport const mediaCarousel = tv({\n slots: {\n root: \"relative isolate w-full\",\n track: \"m-0 flex list-none snap-x snap-mandatory gap-3 overflow-hidden p-0 touch-pan-y\",\n slide: \"relative m-0 w-full shrink-0 snap-center overflow-hidden rounded-xl border border-border-default bg-media\",\n media: \"absolute inset-0 h-full w-full object-cover\",\n caption: \"absolute inset-x-0 bottom-0 bg-linear-to-t from-scrim-strong to-transparent p-3 pt-8 text-xs font-semibold text-fg-on-media\",\n bar: \"mt-3 flex items-center justify-between gap-3\",\n count: \"text-xs tabular-nums text-fg-secondary\",\n buttons: \"flex gap-2\",\n },\n});\nconst s = mediaCarousel();\n\nexport type CarouselSlide = {\n /** A stable id. */\n id: string;\n /** The still, or the poster of a loop or a film. */\n src: string;\n /** What it shows, in words. */\n alt: string;\n /** « Fig. 1a »: one line over the foot of the slide. */\n caption?: string;\n /** A muted loop playing while the slide is the one in view and on screen, after the page's `load`, with a visible pause; a still under reduced motion. On a `film` slide it previews the film. */\n video?: { webm?: string; mp4?: string };\n /** A film opened by a press, with sound, in the lightbox of the MediaPlayer. */\n film?: Pick<MediaPlayerProps, \"src\" | \"title\" | \"tracks\" | \"loadHls\" | \"labels\" | \"ratio\"> & { playLabel: string; vertical?: boolean };\n};\n\nexport type MediaCarouselLabels = { previous: string; next: string; close: string; slide: string };\nexport const mediaCarouselLabels: MediaCarouselLabels = { previous: \"Previous\", next: \"Next\", close: \"Close\", slide: \"{n} of {total}\" };\n\nexport type MediaCarouselProps = Omit<React.ComponentProps<\"section\">, \"children\"> & {\n /** The slides, in order: 3 to 4 realisations. */\n slides: readonly CarouselSlide[];\n /** The carousel's accessible name, passed translated. */\n label: string;\n /** The frame ratio of every slide (width / height). Default `16 / 10`. */\n ratio?: string;\n /** The words, passed translated; English by default. `slide` takes `{n}` and `{total}`. */\n labels?: Partial<MediaCarouselLabels>;\n /** The words of the lightbox player of every film (speed, captions, time…), passed translated; a slide's own `film.labels` wins. */\n playerLabels?: MediaPlayerProps[\"labels\"];\n /** Draws a slide's `video`: `(video, { poster, inView }) => <PausableLoop sources={video} poster={poster} active={inView} />` (`@krizaka/ui/pausable-loop`, which brings the pause and play). Without it a slide stays a still, and this entry stays light. */\n renderLoop?: (video: NonNullable<CarouselSlide[\"video\"]>, context: { poster: string; inView: boolean }) => React.ReactNode;\n};\n\n/** How far a swipe travels, in CSS pixels, before it turns the slide. */\nconst SWIPE_DISTANCE = 40;\n\n/** The slide in view and the one way to change it: the track scrolls only from here, so it holds no scroll of its own to reach. */\nfunction useActiveSlide(track: React.RefObject<HTMLUListElement | null>, count: number) {\n const [active, setActive] = React.useState(0);\n const reduce = usePrefersReducedMotion();\n const go = (to: number) => {\n const el = track.current;\n if (!el) return active;\n const next = Math.min(count - 1, Math.max(0, to));\n el.scrollTo({ left: next * (el.scrollWidth / count), behavior: reduce ? \"auto\" : \"smooth\" });\n setActive(next);\n return next;\n };\n return { active, go };\n}\n\n/** A horizontal swipe on the track turns one slide; a vertical one stays the page's scroll (`touch-action: pan-y`). */\nfunction useSwipe(turn: (delta: 1 | -1) => void) {\n const from = React.useRef<number | null>(null);\n return {\n onPointerDown: (event: React.PointerEvent) => {\n from.current = event.clientX;\n },\n onPointerUp: (event: React.PointerEvent) => {\n const start = from.current;\n from.current = null;\n if (start === null) return;\n const distance = event.clientX - start;\n if (Math.abs(distance) >= SWIPE_DISTANCE) turn(distance < 0 ? 1 : -1);\n },\n onPointerCancel: () => {\n from.current = null;\n },\n };\n}\n\n/** At an end the button just used is disabled: the focus moves to the other one, never to the page. */\nfunction keepFocus(toolbar: HTMLElement | null, at: number, count: number) {\n if (!toolbar?.contains(document.activeElement)) return;\n const [previous, next] = toolbar.querySelectorAll(\"button\");\n if (at === 0) next?.focus();\n if (at === count - 1) previous?.focus();\n}\n\n/** The arrow keys of the toolbar: right turns forward, left back. */\nconst ARROWS: Partial<Record<string, 1 | -1>> = { ArrowRight: 1, ArrowLeft: -1 };\n\ntype SlideMediaProps = Readonly<{ slide: CarouselSlide; loop: React.ReactNode; ratio: string; closeLabel: string; playerLabels?: MediaPlayerProps[\"labels\"] }>;\n\n/** A poster that opens its film, or a still; its loop, when `renderLoop` draws one, previews the film or plays over the still while the slide is the one in view. */\nfunction SlideMedia({ slide, loop, ratio, closeLabel, playerLabels }: SlideMediaProps) {\n if (slide.film) {\n return (\n <MediaPlayer\n {...slide.film}\n labels={slide.film.labels ?? playerLabels}\n mode=\"lightbox\"\n poster={slide.src}\n posterAlt={slide.alt}\n caption={slide.caption}\n closeLabel={closeLabel}\n preview={loop}\n className=\"h-full rounded-none border-0\"\n />\n );\n }\n return (\n <>\n <img src={slide.src} alt={slide.alt} loading=\"lazy\" decoding=\"async\" draggable={false} className={s.media()} style={{ aspectRatio: ratio }} />\n {loop}\n {slide.caption && <figcaption className={s.caption()}>{slide.caption}</figcaption>}\n </>\n );\n}\n\n/** A few realisations in one frame, one at a time: swipe, buttons or arrow keys on them; nothing advances by itself. */\nexport function MediaCarousel({ slides, label, ratio = \"16 / 10\", labels: given, playerLabels, renderLoop, className, ...props }: Readonly<MediaCarouselProps>) {\n const labels = { ...mediaCarouselLabels, ...given };\n const track = React.useRef<HTMLUListElement>(null);\n const toolbar = React.useRef<HTMLDivElement>(null);\n const { active, go } = useActiveSlide(track, slides.length);\n const turn = (delta: 1 | -1) => keepFocus(toolbar.current, go(active + delta), slides.length);\n const swipe = useSwipe(turn);\n const keys = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const delta = ARROWS[event.key];\n if (!delta) return;\n event.preventDefault();\n turn(delta);\n };\n const name = (i: number) => labels.slide.replace(\"{n}\", String(i + 1)).replace(\"{total}\", String(slides.length));\n return (\n <section aria-roledescription=\"carousel\" aria-label={label} className={s.root({ className })} {...props}>\n <ul ref={track} className={s.track()} {...swipe}>\n {slides.map((slide, i) => (\n <li key={slide.id} aria-roledescription=\"slide\" aria-label={name(i)} className={s.slide()} style={{ aspectRatio: ratio }} aria-hidden={i === active ? undefined : true} inert={i === active ? undefined : true}>\n <figure className=\"m-0 h-full w-full\">\n <SlideMedia slide={slide} loop={slide.video && renderLoop?.(slide.video, { poster: slide.src, inView: i === active })} ratio={ratio} closeLabel={labels.close} playerLabels={playerLabels} />\n </figure>\n </li>\n ))}\n </ul>\n {slides.length > 1 && (\n <div className={s.bar()}>\n <span className={s.count()} aria-live=\"polite\">{active + 1} / {slides.length}</span>\n <div ref={toolbar} role=\"toolbar\" aria-orientation=\"horizontal\" className={s.buttons()} onKeyDown={keys}>\n <IconButton variant=\"secondary\" label={labels.previous} disabled={active === 0} onClick={() => turn(-1)}>\n <ChevronGlyph direction=\"left\" className=\"h-5 w-5\" />\n </IconButton>\n <IconButton variant=\"secondary\" label={labels.next} disabled={active === slides.length - 1} onClick={() => turn(1)}>\n <ChevronGlyph direction=\"right\" className=\"h-5 w-5\" />\n </IconButton>\n </div>\n </div>\n )}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAGA,YAAY,WAAW;AACvB,SAAS,UAAU;AA6Gb,SAcF,UAdE,KAcF,YAdE;AAtGC,IAAM,gBAAgB,GAAG;AAAA,EAC9B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS;AAAA,IACT,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,EACX;AACF,CAAC;AACD,IAAM,IAAI,cAAc;AAkBjB,IAAM,sBAA2C,EAAE,UAAU,YAAY,MAAM,QAAQ,OAAO,SAAS,OAAO,iBAAiB;AAkBtI,IAAM,iBAAiB;AAGvB,SAAS,eAAe,OAAiD,OAAe;AACtF,QAAM,CAAC,QAAQ,SAAS,IAAU,eAAS,CAAC;AAC5C,QAAM,SAAS,wBAAwB;AACvC,QAAM,KAAK,CAAC,OAAe;AACzB,UAAM,KAAK,MAAM;AACjB,QAAI,CAAC,GAAI,QAAO;AAChB,UAAM,OAAO,KAAK,IAAI,QAAQ,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;AAChD,OAAG,SAAS,EAAE,MAAM,QAAQ,GAAG,cAAc,QAAQ,UAAU,SAAS,SAAS,SAAS,CAAC;AAC3F,cAAU,IAAI;AACd,WAAO;AAAA,EACT;AACA,SAAO,EAAE,QAAQ,GAAG;AACtB;AAGA,SAAS,SAAS,MAA+B;AAC/C,QAAM,OAAa,aAAsB,IAAI;AAC7C,SAAO;AAAA,IACL,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AIf,CACD,GACH;AAAA,IACC,OAAO,SAAS,KACjB,qBAAC,SAAI,WAAW,EAAE,IAAI,GACpB;AAAA,2BAAC,UAAK,WAAW,EAAE,MAAM,GAAG,aAAU,UAAU;AAAA,iBAAS;AAAA,QAAE;AAAA,QAAI,OAAO;AAAA,SAAO;AAAA,MAC7E,qBAAC,SAAI,KAAK,SAAS,MAAK,WAAU,oBAAiB,cAAa,WAAW,EAAE,QAAQ,GAAG,WAAW,MACjG;AAAA,4BAAC,cAAW,SAAQ,aAAY,OAAO,OAAO,UAAU,UAAU,WAAW,GAAG,SAAS,MAAM,KAAK,EAAE,GACpG,8BAAC,gBAAa,WAAU,QAAO,WAAU,WAAU,GACrD;AAAA,QACA,oBAAC,cAAW,SAAQ,aAAY,OAAO,OAAO,MAAM,UAAU,WAAW,OAAO,SAAS,GAAG,SAAS,MAAM,KAAK,CAAC,GAC/G,8BAAC,gBAAa,WAAU,SAAQ,WAAU,WAAU,GACtD;AAAA,SACF;AAAA,OACF;AAAA,KAEF;AAEJ;","names":[]}
|
package/dist/media-player.d.ts
CHANGED
|
@@ -113,6 +113,7 @@ declare const mediaPlayer: tailwind_variants.TVReturnType<{
|
|
|
113
113
|
[key: string]: {
|
|
114
114
|
[key: string]: tailwind_variants.ClassValue | {
|
|
115
115
|
caption?: tailwind_variants.ClassValue;
|
|
116
|
+
frame?: tailwind_variants.ClassValue;
|
|
116
117
|
image?: tailwind_variants.ClassValue;
|
|
117
118
|
poster?: tailwind_variants.ClassValue;
|
|
118
119
|
play?: tailwind_variants.ClassValue;
|
|
@@ -122,12 +123,14 @@ declare const mediaPlayer: tailwind_variants.TVReturnType<{
|
|
|
122
123
|
[x: string]: {
|
|
123
124
|
[x: string]: tailwind_variants.ClassValue | {
|
|
124
125
|
caption?: tailwind_variants.ClassValue;
|
|
126
|
+
frame?: tailwind_variants.ClassValue;
|
|
125
127
|
image?: tailwind_variants.ClassValue;
|
|
126
128
|
poster?: tailwind_variants.ClassValue;
|
|
127
129
|
play?: tailwind_variants.ClassValue;
|
|
128
130
|
};
|
|
129
131
|
};
|
|
130
132
|
} | {}, {
|
|
133
|
+
frame: string;
|
|
131
134
|
poster: string;
|
|
132
135
|
image: string;
|
|
133
136
|
play: string;
|
|
@@ -136,17 +139,20 @@ declare const mediaPlayer: tailwind_variants.TVReturnType<{
|
|
|
136
139
|
[key: string]: {
|
|
137
140
|
[key: string]: tailwind_variants.ClassValue | {
|
|
138
141
|
caption?: tailwind_variants.ClassValue;
|
|
142
|
+
frame?: tailwind_variants.ClassValue;
|
|
139
143
|
image?: tailwind_variants.ClassValue;
|
|
140
144
|
poster?: tailwind_variants.ClassValue;
|
|
141
145
|
play?: tailwind_variants.ClassValue;
|
|
142
146
|
};
|
|
143
147
|
};
|
|
144
148
|
} | {}, {
|
|
149
|
+
frame: string;
|
|
145
150
|
poster: string;
|
|
146
151
|
image: string;
|
|
147
152
|
play: string;
|
|
148
153
|
caption: string;
|
|
149
154
|
}, tailwind_variants.TVReturnTypeLike<unknown, {
|
|
155
|
+
frame: string;
|
|
150
156
|
poster: string;
|
|
151
157
|
image: string;
|
|
152
158
|
play: string;
|
|
@@ -155,8 +161,10 @@ declare const mediaPlayer: tailwind_variants.TVReturnType<{
|
|
|
155
161
|
type MediaPlayerProps = Pick<VideoPlayerProps, "src" | "poster" | "title" | "tracks" | "loadHls" | "labels" | "onPlay" | "onPause" | "onEnded" | "onError"> & {
|
|
156
162
|
/** `inline`: the player itself. `lightbox`: a poster that opens it in a dialog. Default `inline`. */
|
|
157
163
|
mode?: "inline" | "lightbox";
|
|
158
|
-
/** `9 / 16` frame for a vertical film; default `16 / 9`. */
|
|
164
|
+
/** `9 / 16` frame and the narrow dialog for a vertical film; default `16 / 9`. */
|
|
159
165
|
vertical?: boolean;
|
|
166
|
+
/** Any frame ratio (`19 / 16`, `4 / 3`): wins over the frame of `vertical` (give both for a portrait ratio: `vertical ratio="3 / 4"`). Default `16 / 9` (`9 / 16` when `vertical`). */
|
|
167
|
+
ratio?: string;
|
|
160
168
|
/** The poster's words in the lightbox ("Play the film"), passed translated. Required for `lightbox`. */
|
|
161
169
|
playLabel?: string;
|
|
162
170
|
/** The close button's words, passed translated. Default `Close`. */
|
|
@@ -165,13 +173,19 @@ type MediaPlayerProps = Pick<VideoPlayerProps, "src" | "poster" | "title" | "tra
|
|
|
165
173
|
posterAlt?: string;
|
|
166
174
|
/** A line over the foot of the poster (« Fig. 1a »). */
|
|
167
175
|
caption?: string;
|
|
176
|
+
/** Lightbox: drawn over the poster, under its press (the frame is `relative`): a `<PausableLoop>` of `@krizaka/ui/pausable-loop` previews the film with a muted loop. */
|
|
177
|
+
preview?: React.ReactNode;
|
|
178
|
+
/** Lightbox: opens or closes it from outside (controlled). With it, `onOpenChange` is how the lightbox asks to close. */
|
|
179
|
+
open?: boolean;
|
|
180
|
+
/** Lightbox: replaces the poster with your own opener (`(open) => <button onClick={open}>…`); `null` draws nothing, for a lightbox driven by `open` alone. */
|
|
181
|
+
trigger?: ((open: () => void) => React.ReactNode) | null;
|
|
168
182
|
/** Called when the lightbox opens or closes. */
|
|
169
183
|
onOpenChange?: (open: boolean) => void;
|
|
170
184
|
/** Classes merged on the player or the poster. */
|
|
171
185
|
className?: string;
|
|
172
186
|
};
|
|
173
187
|
/** A video in one frame: inline, in a lightbox (a press opens it with sound), 16:9 or vertical. */
|
|
174
|
-
declare function MediaPlayer({ mode, vertical, playLabel, closeLabel, posterAlt, caption, onOpenChange, className, ...player }: MediaPlayerProps): React.JSX.Element;
|
|
188
|
+
declare function MediaPlayer({ mode, vertical, playLabel, closeLabel, posterAlt, caption, preview, open: given, trigger, onOpenChange, ratio: freeRatio, className, ...player }: MediaPlayerProps): React.JSX.Element;
|
|
175
189
|
|
|
176
190
|
export { MediaPlayer, mediaPlayer };
|
|
177
191
|
export type { MediaPlayerProps };
|
package/dist/media-player.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type LoopSources = {
|
|
4
|
+
webm?: string;
|
|
5
|
+
mp4?: string;
|
|
6
|
+
};
|
|
7
|
+
type LoopLabels = {
|
|
8
|
+
pause: string;
|
|
9
|
+
play: string;
|
|
10
|
+
};
|
|
11
|
+
type PausableLoopProps = {
|
|
12
|
+
/** The loop's files; `mp4` and / or `webm`. */
|
|
13
|
+
sources: LoopSources;
|
|
14
|
+
/** The still under the loop, shown first and kept under reduced motion or Save-Data. */
|
|
15
|
+
poster: string;
|
|
16
|
+
/** Plays only while `true` (e.g. the slide in view). Default `true`. */
|
|
17
|
+
active?: boolean;
|
|
18
|
+
/** The pause / play words, passed translated. English by default. */
|
|
19
|
+
labels?: LoopLabels;
|
|
20
|
+
/** Classes of the `<video>`; default fills its frame, cropped. */
|
|
21
|
+
className?: string;
|
|
22
|
+
};
|
|
23
|
+
/** A muted, silent loop over a still, with a visible pause / play. Drop it into a frame that is `relative`: `MediaPlayer`'s `preview`, `MediaCarousel`'s `renderLoop`. */
|
|
24
|
+
declare function PausableLoop({ sources, poster, active, labels, className }: Readonly<PausableLoopProps>): React.JSX.Element;
|
|
25
|
+
|
|
26
|
+
export { PausableLoop };
|
|
27
|
+
export type { LoopLabels, LoopSources, PausableLoopProps };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
playSafely,
|
|
4
|
+
useInView,
|
|
5
|
+
usePrefersReducedMotion
|
|
6
|
+
} from "./chunk-TN5JJ6JI.js";
|
|
7
|
+
import {
|
|
8
|
+
PauseGlyph,
|
|
9
|
+
PlayGlyph
|
|
10
|
+
} from "./chunk-S2O4NSN5.js";
|
|
11
|
+
import {
|
|
12
|
+
cn
|
|
13
|
+
} from "./chunk-NSLXEDIS.js";
|
|
14
|
+
|
|
15
|
+
// src/media-gallery/pausable-loop.tsx
|
|
16
|
+
import * as React from "react";
|
|
17
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
var loopLabels = { pause: "Pause the animation", play: "Play the animation" };
|
|
19
|
+
var subscribeLoad = (notify) => {
|
|
20
|
+
window.addEventListener("load", notify);
|
|
21
|
+
return () => window.removeEventListener("load", notify);
|
|
22
|
+
};
|
|
23
|
+
function usePageLoaded() {
|
|
24
|
+
return React.useSyncExternalStore(subscribeLoad, () => document.readyState === "complete", () => false);
|
|
25
|
+
}
|
|
26
|
+
function useCalm() {
|
|
27
|
+
const reduce = usePrefersReducedMotion();
|
|
28
|
+
return reduce || typeof navigator !== "undefined" && Boolean(navigator.connection?.saveData);
|
|
29
|
+
}
|
|
30
|
+
function PausableLoop({ sources, poster, active = true, labels = loopLabels, className = "absolute inset-0 h-full w-full object-cover" }) {
|
|
31
|
+
const calm = useCalm();
|
|
32
|
+
const loaded = usePageLoaded();
|
|
33
|
+
const mounted = !calm && loaded;
|
|
34
|
+
const holder = React.useRef(null);
|
|
35
|
+
const video = React.useRef(null);
|
|
36
|
+
const [onScreen, setOnScreen] = React.useState(() => typeof IntersectionObserver === "undefined");
|
|
37
|
+
const [paused, setPaused] = React.useState(false);
|
|
38
|
+
useInView(holder, setOnScreen, mounted);
|
|
39
|
+
const playing = mounted && onScreen && active && !paused;
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
if (!video.current) return;
|
|
42
|
+
if (playing) playSafely(video.current);
|
|
43
|
+
else video.current.pause?.();
|
|
44
|
+
}, [playing]);
|
|
45
|
+
const Glyph = paused ? PlayGlyph : PauseGlyph;
|
|
46
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47
|
+
/* @__PURE__ */ jsx("div", { ref: holder, className: "absolute inset-0", children: mounted && /* @__PURE__ */ jsxs("video", { ref: video, className, poster, muted: true, loop: true, playsInline: true, preload: "metadata", "aria-hidden": true, tabIndex: -1, children: [
|
|
48
|
+
sources.webm && /* @__PURE__ */ jsx("source", { src: sources.webm, type: "video/webm" }),
|
|
49
|
+
sources.mp4 && /* @__PURE__ */ jsx("source", { src: sources.mp4, type: "video/mp4" })
|
|
50
|
+
] }) }),
|
|
51
|
+
!calm && /* @__PURE__ */ jsx(
|
|
52
|
+
"button",
|
|
53
|
+
{
|
|
54
|
+
type: "button",
|
|
55
|
+
"aria-label": paused ? labels.play : labels.pause,
|
|
56
|
+
onClick: () => setPaused((p) => !p),
|
|
57
|
+
className: cn(
|
|
58
|
+
"absolute right-2 top-2 z-10 flex h-9 w-9 items-center justify-center rounded-full bg-scrim-strong text-fg-on-media transition-colors hover:bg-scrim focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-reduce:transition-none"
|
|
59
|
+
),
|
|
60
|
+
children: /* @__PURE__ */ jsx(Glyph, { className: "h-4 w-4" })
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] });
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
PausableLoop
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=pausable-loop.js.map
|