sanity-plugin-studio-scene 0.0.0-stage → 0.1.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.
@@ -0,0 +1,20 @@
1
+ /** Entrances, named by where the content comes from (data values stay short: "up" = rises in from below). */
2
+ export declare const ENTER_OPTIONS: {
3
+ title: string;
4
+ value: string;
5
+ }[];
6
+ /** Exits, named by where the content goes. "Reverse" leaves the way it came in. */
7
+ export declare const EXIT_OPTIONS: {
8
+ title: string;
9
+ value: string;
10
+ }[];
11
+ /**
12
+ * How content moves over its shot. Every field is optional: empty means "inherit" (a group from its shot,
13
+ * a shot from the page). The page turns it into CSS variables driven by the runtime's --stop-t.
14
+ */
15
+ export declare function motionType(): {
16
+ type: "object";
17
+ name: "studioSlotMotion";
18
+ } & Omit<import("sanity").ObjectDefinition, "preview"> & {
19
+ preview?: import("sanity").PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
20
+ };
@@ -0,0 +1,63 @@
1
+ import { defineField, defineType } from "sanity";
2
+ import { T } from "../options";
3
+ const radio = (list) => ({ list, layout: "radio", direction: "horizontal" });
4
+ /** Entrances, named by where the content comes from (data values stay short: "up" = rises in from below). */
5
+ export const ENTER_OPTIONS = [
6
+ { title: "Fade", value: "fade" },
7
+ { title: "From below", value: "up" },
8
+ { title: "From above", value: "down" },
9
+ { title: "From left", value: "left" },
10
+ { title: "From right", value: "right" },
11
+ { title: "Zoom", value: "scale" },
12
+ { title: "Blur", value: "blur" },
13
+ { title: "None", value: "none" },
14
+ ];
15
+ /** Exits, named by where the content goes. "Reverse" leaves the way it came in. */
16
+ export const EXIT_OPTIONS = [
17
+ { title: "Reverse", value: "reverse" },
18
+ { title: "Fade", value: "fade" },
19
+ { title: "Up", value: "up" },
20
+ { title: "Down", value: "down" },
21
+ { title: "To left", value: "left" },
22
+ { title: "To right", value: "right" },
23
+ { title: "Zoom", value: "scale" },
24
+ { title: "Blur", value: "blur" },
25
+ { title: "None", value: "none" },
26
+ ];
27
+ /**
28
+ * How content moves over its shot. Every field is optional: empty means "inherit" (a group from its shot,
29
+ * a shot from the page). The page turns it into CSS variables driven by the runtime's --stop-t.
30
+ */
31
+ export function motionType() {
32
+ return defineType({
33
+ name: T.motion,
34
+ title: "Motion",
35
+ type: "object",
36
+ fields: [
37
+ defineField({
38
+ name: "flow",
39
+ title: "Content",
40
+ description: "Stays on screen while its shot is on, or scrolls past with the page (its length then sets how long the camera stops).",
41
+ type: "string",
42
+ options: radio([{ title: "Stays on screen", value: "hold" }, { title: "Scrolls past", value: "scroll" }]),
43
+ }),
44
+ defineField({ name: "enter", title: "In", description: "How content arrives. Default: fade.", type: "string", options: radio(ENTER_OPTIONS) }),
45
+ defineField({ name: "exit", title: "Out", description: "How it leaves. Default: reverse (the way it came in).", type: "string", options: radio(EXIT_OPTIONS) }),
46
+ defineField({
47
+ name: "mode",
48
+ title: "Plays",
49
+ type: "string",
50
+ options: radio([{ title: "Follows the scroll", value: "scrub" }, { title: "By itself", value: "play" }]),
51
+ }),
52
+ defineField({
53
+ name: "timing",
54
+ title: "Starts",
55
+ type: "string",
56
+ options: radio([{ title: "Before the camera arrives", value: "early" }, { title: "As it arrives", value: "with" }, { title: "Once it stops", value: "late" }]),
57
+ }),
58
+ defineField({ name: "distance", title: "Strength", description: "How far it slides, how much it zooms or blurs.", type: "string", options: radio([{ title: "Subtle", value: "small" }, { title: "Medium", value: "medium" }, { title: "Bold", value: "large" }]) }),
59
+ defineField({ name: "stagger", title: "One block at a time", type: "boolean" }),
60
+ defineField({ name: "parallax", title: "Drift while the camera holds", type: "string", options: radio([{ title: "None", value: "none" }, { title: "Subtle", value: "subtle" }, { title: "Strong", value: "strong" }]) }),
61
+ ],
62
+ });
63
+ }
@@ -0,0 +1,30 @@
1
+ import { type ResolvedOptions } from "../options";
2
+ /**
3
+ * A scene placed on a page: which scene, the page's text for any of its shots, and how it looks. Use it as a
4
+ * field or as a page-builder section. The same scene can be placed on many pages, each with its own text and
5
+ * styling; text is keyed on the shot's id, so re-exporting the scene keeps it.
6
+ */
7
+ export declare function placementTypes(opts: ResolvedOptions): (({
8
+ type: "object";
9
+ name: "studioSlotGroup";
10
+ } & Omit<import("sanity").ObjectDefinition, "preview"> & {
11
+ preview?: import("sanity").PreviewConfig<{
12
+ title: string;
13
+ }, Record<"title", any>> | undefined;
14
+ }) | ({
15
+ type: "object";
16
+ name: "studioSlot";
17
+ } & Omit<import("sanity").ObjectDefinition, "preview"> & {
18
+ preview?: import("sanity").PreviewConfig<{
19
+ title: string;
20
+ }, Record<"title", any>> | undefined;
21
+ }) | ({
22
+ type: "object";
23
+ name: "studioScenePlacement";
24
+ } & Omit<import("sanity").ObjectDefinition, "preview"> & {
25
+ preview?: import("sanity").PreviewConfig<{
26
+ title: string;
27
+ posterUrl: string;
28
+ slots: string;
29
+ }, Record<"title" | "posterUrl" | "slots", any>> | undefined;
30
+ }))[];
@@ -0,0 +1,96 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { defineArrayMember, defineField, defineType } from "sanity";
3
+ import { API_VERSION, T } from "../options";
4
+ import { placementInput } from "../PlacementInput";
5
+ /**
6
+ * A scene placed on a page: which scene, the page's text for any of its shots, and how it looks. Use it as a
7
+ * field or as a page-builder section. The same scene can be placed on many pages, each with its own text and
8
+ * styling; text is keyed on the shot's id, so re-exporting the scene keeps it.
9
+ */
10
+ export function placementTypes(opts) {
11
+ const pinField = defineField({
12
+ name: "pin",
13
+ title: "Pin to a 3D point",
14
+ description: "Follows a point marked in STUDIO (a web point) as the camera moves. Empty: placed on the page.",
15
+ type: "string",
16
+ });
17
+ const lineField = defineField({
18
+ name: "line",
19
+ title: "Line to the point",
20
+ description: "Pinned content only: a callout, with a line from the card to a dot on the point. Position sets which side the card sits.",
21
+ type: "string",
22
+ options: { list: [{ title: "Short", value: "short" }, { title: "Medium", value: "medium" }, { title: "Long", value: "long" }], layout: "radio", direction: "horizontal" },
23
+ });
24
+ /** An extra group of content on a shot, with its own position, look and motion (e.g. a stat beside the main copy). */
25
+ const group = defineType({
26
+ name: T.group,
27
+ title: "Content group",
28
+ type: "object",
29
+ fields: [
30
+ defineField({ name: "content", title: "Content", type: "array", of: opts.stopContent }),
31
+ defineField({ name: "style", title: "Style", description: "Empty fields use the shot's.", type: T.style }),
32
+ defineField({ name: "motion", title: "Motion", description: "Empty fields use the shot's.", type: T.motion }),
33
+ pinField,
34
+ lineField,
35
+ ],
36
+ preview: { select: { title: "_key" } },
37
+ });
38
+ const slot = defineType({
39
+ name: T.slot,
40
+ title: "Content on a shot",
41
+ type: "object",
42
+ fields: [
43
+ defineField({ name: "content", title: "Content", type: "array", of: opts.stopContent }),
44
+ defineField({ name: "style", title: "Style for this shot", description: "Empty fields use the page's look.", type: T.style }),
45
+ defineField({ name: "motion", title: "Motion for this shot", description: "Empty fields use the page's.", type: T.motion }),
46
+ pinField,
47
+ lineField,
48
+ defineField({ name: "groups", title: "More groups", type: "array", of: [defineArrayMember({ type: T.group })] }),
49
+ ],
50
+ preview: { select: { title: "_key" } },
51
+ });
52
+ const placement = defineType({
53
+ name: T.placement,
54
+ title: opts.placementTitle,
55
+ type: "object",
56
+ components: { input: placementInput(opts) },
57
+ fields: [
58
+ defineField({
59
+ name: "scene",
60
+ title: "Scene",
61
+ description: "From Scroll scenes. Or upload a new STUDIO export here.",
62
+ type: "reference",
63
+ to: [{ type: T.scene }],
64
+ validation: (r) => r.required(),
65
+ }),
66
+ defineField({
67
+ name: "slots",
68
+ title: "Content on shots",
69
+ type: "array",
70
+ of: [defineArrayMember({ type: T.slot })],
71
+ validation: (r) => r.custom(async (slots, ctx) => {
72
+ const ref = ctx.parent?.scene?._ref;
73
+ if (!ref)
74
+ return true;
75
+ const stops = await ctx
76
+ .getClient({ apiVersion: API_VERSION })
77
+ .fetch(`coalesce(*[_id == "drafts." + $id][0], *[_id == $id][0]).stops[]._key`, { id: ref });
78
+ const ids = new Set(stops ?? []);
79
+ const orphans = (slots ?? []).filter((s) => !ids.has(s._key) && s.content?.length);
80
+ return orphans.length ? `Content on ${orphans.length} shot(s) that are no longer in the scene won't show. Move or delete it.` : true;
81
+ }).warning(),
82
+ }),
83
+ defineField({ name: "style", title: "Look for all shots", type: T.style }),
84
+ defineField({ name: "motion", title: "Motion for all shots", type: T.motion }),
85
+ ],
86
+ preview: {
87
+ select: { title: "scene.title", posterUrl: "scene.export.posterUrl", slots: "slots" },
88
+ prepare: ({ title, posterUrl, slots }) => ({
89
+ title: title ? `${opts.placementTitle}: ${title}` : opts.placementTitle,
90
+ subtitle: `${(slots ?? []).filter((s) => s.content?.length).length} shot(s) with content`,
91
+ media: posterUrl ? _jsx("img", { src: posterUrl, alt: "", style: { objectFit: "cover", width: "100%", height: "100%" } }) : undefined,
92
+ }),
93
+ },
94
+ });
95
+ return [group, slot, placement];
96
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The scene library: one document per STUDIO export. It holds the files (as Sanity assets) and the list of
3
+ * stops. Pages don't put content here; they place the scene (studioScenePlacement) and fill its stops there.
4
+ */
5
+ export declare function sceneTypes(): (({
6
+ type: "object";
7
+ name: "studioSceneFile";
8
+ } & Omit<import("sanity").ObjectDefinition, "preview"> & {
9
+ preview?: import("sanity").PreviewConfig<{
10
+ title: string;
11
+ }, Record<"title", any>> | undefined;
12
+ }) | ({
13
+ type: "object";
14
+ name: "studioSceneStop";
15
+ } & Omit<import("sanity").ObjectDefinition, "preview"> & {
16
+ preview?: import("sanity").PreviewConfig<{
17
+ title: string;
18
+ subtitle: string;
19
+ }, Record<"title" | "subtitle", any>> | undefined;
20
+ }) | ({
21
+ type: "object";
22
+ name: "studioScenePoint";
23
+ } & Omit<import("sanity").ObjectDefinition, "preview"> & {
24
+ preview?: import("sanity").PreviewConfig<{
25
+ title: string;
26
+ subtitle: string;
27
+ }, Record<"title" | "subtitle", any>> | undefined;
28
+ }) | ({
29
+ type: "object";
30
+ name: "studioSceneExport";
31
+ } & Omit<import("sanity").ObjectDefinition, "preview"> & {
32
+ preview?: import("sanity").PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
33
+ }) | ({
34
+ type: "document";
35
+ name: "studioScene";
36
+ } & Omit<import("sanity").DocumentDefinition, "preview"> & {
37
+ preview?: import("sanity").PreviewConfig<{
38
+ title: string;
39
+ posterUrl: string;
40
+ file: string;
41
+ stops: string;
42
+ }, Record<"file" | "title" | "stops" | "posterUrl", any>> | undefined;
43
+ }))[];
@@ -0,0 +1,104 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { defineArrayMember, defineField, defineType } from "sanity";
3
+ import { T } from "../options";
4
+ import { SceneInput } from "../SceneInput";
5
+ /** A play-in-a-frame icon, inline so the plugin needs no icon package. */
6
+ function SceneIcon() {
7
+ return (_jsxs("svg", { width: "1em", height: "1em", viewBox: "0 0 25 25", fill: "none", stroke: "currentColor", strokeWidth: 1.2, children: [_jsx("rect", { x: "4.5", y: "6.5", width: "16", height: "12", rx: "1.5" }), _jsx("path", { d: "M11 9.75v5.5l4.5-2.75-4.5-2.75Z", fill: "currentColor", stroke: "none" })] }));
8
+ }
9
+ /**
10
+ * The scene library: one document per STUDIO export. It holds the files (as Sanity assets) and the list of
11
+ * stops. Pages don't put content here; they place the scene (studioScenePlacement) and fill its stops there.
12
+ */
13
+ export function sceneTypes() {
14
+ const file = defineType({
15
+ name: T.sceneFile,
16
+ title: "Export file",
17
+ type: "object",
18
+ readOnly: true,
19
+ fields: [
20
+ defineField({ name: "path", title: "Path in the export", type: "string" }),
21
+ defineField({ name: "asset", title: "File", type: "file" }),
22
+ ],
23
+ preview: { select: { title: "path" } },
24
+ });
25
+ const stop = defineType({
26
+ name: T.sceneStop,
27
+ title: "Shot",
28
+ type: "object",
29
+ readOnly: true,
30
+ fields: [
31
+ defineField({ name: "label", type: "string" }),
32
+ defineField({ name: "slug", title: "data-stop", type: "string" }),
33
+ defineField({ name: "camera", type: "string" }),
34
+ defineField({ name: "thumb", title: "Still (path in the export)", type: "string" }),
35
+ defineField({ name: "thumbUrl", title: "Still", type: "url" }),
36
+ ],
37
+ preview: { select: { title: "label", subtitle: "slug" } },
38
+ });
39
+ const point = defineType({
40
+ name: T.point,
41
+ title: "3D point",
42
+ type: "object",
43
+ readOnly: true,
44
+ fields: [
45
+ defineField({ name: "name", type: "string" }),
46
+ defineField({ name: "slug", title: "data-point", type: "string" }),
47
+ ],
48
+ preview: { select: { title: "name", subtitle: "slug" } },
49
+ });
50
+ const exp = defineType({
51
+ name: T.sceneExport,
52
+ title: "Export",
53
+ type: "object",
54
+ readOnly: true,
55
+ fields: [
56
+ defineField({ name: "fileName", type: "string" }),
57
+ defineField({ name: "importedAt", type: "datetime" }),
58
+ defineField({ name: "timelineUrl", type: "url" }),
59
+ defineField({ name: "posterUrl", type: "url" }),
60
+ defineField({ name: "bytes", type: "number" }),
61
+ defineField({ name: "stops", type: "number" }),
62
+ defineField({ name: "added", type: "number" }),
63
+ defineField({ name: "removed", type: "number" }),
64
+ ],
65
+ });
66
+ const scene = defineType({
67
+ name: T.scene,
68
+ title: "Scroll scene",
69
+ type: "document",
70
+ icon: SceneIcon,
71
+ components: { input: SceneInput },
72
+ fields: [
73
+ defineField({ name: "title", title: "Name", type: "string", validation: (r) => r.required() }),
74
+ defineField({ name: "stops", title: "Shots", type: "array", readOnly: true, hidden: true, of: [defineArrayMember({ type: T.sceneStop })] }),
75
+ defineField({ name: "points", title: "3D points", type: "array", readOnly: true, hidden: true, of: [defineArrayMember({ type: T.point })] }),
76
+ defineField({ name: "files", title: "Export files", type: "array", readOnly: true, hidden: true, of: [defineArrayMember({ type: T.sceneFile })] }),
77
+ defineField({ name: "export", title: "Current export", type: T.sceneExport, hidden: true }),
78
+ defineField({ name: "history", title: "Earlier exports", type: "array", readOnly: true, hidden: true, of: [defineArrayMember({ type: T.sceneExport })] }),
79
+ defineField({
80
+ name: "source",
81
+ title: "Source",
82
+ type: "object",
83
+ readOnly: true,
84
+ hidden: true,
85
+ // Where the files came from: a zip today; a STUDIO "Publish to Sanity" later fills sceneId / version.
86
+ fields: [
87
+ defineField({ name: "kind", type: "string" }),
88
+ defineField({ name: "projectId", type: "string" }),
89
+ defineField({ name: "sceneId", type: "string" }),
90
+ defineField({ name: "version", type: "number" }),
91
+ ],
92
+ }),
93
+ ],
94
+ preview: {
95
+ select: { title: "title", posterUrl: "export.posterUrl", file: "export.fileName", stops: "stops" },
96
+ prepare: ({ title, posterUrl, file, stops }) => ({
97
+ title: title || "Untitled scene",
98
+ subtitle: file ? `${stops?.length ?? 0} shots · ${file}` : "No export yet",
99
+ media: posterUrl ? _jsx("img", { src: posterUrl, alt: "", style: { objectFit: "cover", width: "100%", height: "100%" } }) : undefined,
100
+ }),
101
+ },
102
+ });
103
+ return [file, stop, point, exp, scene];
104
+ }
@@ -0,0 +1,11 @@
1
+ import { type ResolvedOptions } from "../options";
2
+ /**
3
+ * Slot style. Every field is optional: empty means "inherit" (a slot from its placement's default style, the
4
+ * placement from the site's CSS). The frontend gets them as CSS custom properties.
5
+ */
6
+ export declare function styleType(opts: ResolvedOptions): {
7
+ type: "object";
8
+ name: "studioSlotStyle";
9
+ } & Omit<import("sanity").ObjectDefinition, "preview"> & {
10
+ preview?: import("sanity").PreviewConfig<Record<string, string>, Record<never, any>> | undefined;
11
+ };
@@ -0,0 +1,75 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Button, Flex, Stack, Text, TextInput } from "@sanity/ui";
3
+ import { defineField, defineType, set, unset } from "sanity";
4
+ import { T } from "../options";
5
+ const radio = (list) => ({ list, layout: "radio", direction: "horizontal" });
6
+ const POS = [
7
+ { title: "Start", value: "start" },
8
+ { title: "Centre", value: "center" },
9
+ { title: "End", value: "end" },
10
+ ];
11
+ /** A colour: palette swatches from the plugin options, and (unless paletteOnly) any CSS colour. */
12
+ function colorInput(opts) {
13
+ return function SlotColorInput(props) {
14
+ const { value, onChange, readOnly, elementProps } = props;
15
+ return (_jsxs(Stack, { gap: 2, children: [opts.colors.length ? (_jsx(Flex, { gap: 2, wrap: "wrap", children: opts.colors.map((c) => (_jsx(Button, { mode: value === c.value ? "default" : "ghost", tone: value === c.value ? "primary" : "default", disabled: readOnly, padding: 2, onClick: () => onChange(value === c.value ? unset() : set(c.value)), title: c.value, children: _jsxs(Flex, { gap: 2, align: "center", children: [_jsx("span", { style: { width: 16, height: 16, borderRadius: 4, background: c.preview ?? c.value, boxShadow: "inset 0 0 0 1px rgba(127,127,127,.4)" } }), _jsx(Text, { size: 1, children: c.title })] }) }, c.value))) })) : null, opts.paletteOnly ? null : (_jsxs(Flex, { gap: 2, align: "center", children: [_jsx("span", { style: { width: 28, height: 28, flex: "none", borderRadius: 4, background: (opts.colors.find((c) => c.value === value)?.preview ?? value) || "transparent", boxShadow: "inset 0 0 0 1px rgba(127,127,127,.4)" } }), _jsx(Box, { style: { flex: 1 }, children: _jsx(TextInput, { ...elementProps, value: value ?? "", placeholder: "Inherit (any CSS colour: #fff, rgb(\u2026), var(--token))", onChange: (e) => {
16
+ const v = e.currentTarget.value.trim();
17
+ onChange(v ? set(v) : unset());
18
+ } }) })] }))] }));
19
+ };
20
+ }
21
+ /**
22
+ * Slot style. Every field is optional: empty means "inherit" (a slot from its placement's default style, the
23
+ * placement from the site's CSS). The frontend gets them as CSS custom properties.
24
+ */
25
+ export function styleType(opts) {
26
+ const Color = colorInput(opts);
27
+ const all = {
28
+ align: defineField({ name: "align", title: "Position", type: "string", options: radio(POS), fieldset: "layout" }),
29
+ verticalAlign: defineField({ name: "verticalAlign", title: "Vertical position", type: "string", options: radio([{ title: "Top", value: "start" }, { title: "Middle", value: "center" }, { title: "Bottom", value: "end" }]), fieldset: "layout" }),
30
+ textAlign: defineField({ name: "textAlign", title: "Text alignment", type: "string", options: radio([{ title: "Left", value: "start" }, { title: "Centre", value: "center" }, { title: "Right", value: "end" }]), fieldset: "layout" }),
31
+ width: defineField({ name: "width", title: "Width", type: "string", options: radio([{ title: "Narrow", value: "narrow" }, { title: "Medium", value: "medium" }, { title: "Wide", value: "wide" }, { title: "Full", value: "full" }]), fieldset: "layout" }),
32
+ padding: defineField({ name: "padding", title: "Padding", type: "string", options: radio([{ title: "None", value: "none" }, { title: "Small", value: "small" }, { title: "Medium", value: "medium" }, { title: "Large", value: "large" }]), fieldset: "layout" }),
33
+ card: defineField({ name: "card", title: "Background", type: "string", options: radio([{ title: "Card", value: "card" }, { title: "Outline", value: "outline" }, { title: "None", value: "plain" }]), fieldset: "look" }),
34
+ textColor: defineField({ name: "textColor", title: "Text colour", type: "string", components: { input: Color }, fieldset: "look" }),
35
+ cardColor: defineField({ name: "cardColor", title: "Card colour", type: "string", components: { input: Color }, fieldset: "look" }),
36
+ cardOpacity: defineField({ name: "cardOpacity", title: "Card opacity (%)", type: "number", validation: (r) => r.min(0).max(100), fieldset: "look" }),
37
+ blur: defineField({ name: "blur", title: "Background blur (px)", description: "Frosts the scene behind the card.", type: "number", validation: (r) => r.min(0).max(80), fieldset: "look" }),
38
+ radius: defineField({ name: "radius", title: "Corner radius (px)", type: "number", validation: (r) => r.min(0).max(200), fieldset: "look" }),
39
+ fontScale: defineField({ name: "fontScale", title: "Text size", description: "× the site's body size, e.g. 1.25.", type: "number", validation: (r) => r.min(0.5).max(4), fieldset: "look" }),
40
+ pause: defineField({
41
+ name: "pause",
42
+ title: "Pause length",
43
+ description: "Auto: the camera holds while the content scrolls past. Longer settings hold for at least that long, even with little content.",
44
+ type: "string",
45
+ options: radio([{ title: "Auto", value: "auto" }, { title: "Short", value: "short" }, { title: "Medium", value: "medium" }, { title: "Long", value: "long" }]),
46
+ fieldset: "motion",
47
+ }),
48
+ move: defineField({
49
+ name: "move",
50
+ title: "Camera move before this stop (% of a screen)",
51
+ description: "How far the visitor scrolls while the camera travels here. Default 80.",
52
+ type: "number",
53
+ validation: (r) => r.min(0).max(400),
54
+ fieldset: "motion",
55
+ }),
56
+ animation: defineField({
57
+ name: "animation",
58
+ title: "Content entrance",
59
+ type: "string",
60
+ options: radio([{ title: "None", value: "none" }, { title: "Fade", value: "fade" }, { title: "Rise", value: "rise" }, { title: "Slide", value: "slide" }, { title: "Scale", value: "scale" }]),
61
+ fieldset: "motion",
62
+ }),
63
+ };
64
+ return defineType({
65
+ name: T.style,
66
+ title: "Style",
67
+ type: "object",
68
+ fieldsets: [
69
+ { name: "layout", title: "Layout", options: { columns: 1 } },
70
+ { name: "look", title: "Look" },
71
+ { name: "motion", title: "Pause and motion" },
72
+ ],
73
+ fields: Object.keys(all).filter((k) => opts.controls.has(k)).map((k) => all[k]),
74
+ });
75
+ }
@@ -0,0 +1,131 @@
1
+ /**
2
+ * What each slot style value means on the page. The frontend component keeps an identical copy
3
+ * (ctb web: components/StudioScenePlacement/styleTokens.ts) until web imports sanity-plugin-studio-scene/style.
4
+ */
5
+ export interface SlotStyle {
6
+ align?: "start" | "center" | "end";
7
+ verticalAlign?: "start" | "center" | "end";
8
+ textAlign?: "start" | "center" | "end";
9
+ width?: "narrow" | "medium" | "wide" | "full";
10
+ card?: "card" | "outline" | "plain";
11
+ textColor?: string;
12
+ cardColor?: string;
13
+ /** 0–100 */
14
+ cardOpacity?: number;
15
+ /** px */
16
+ blur?: number;
17
+ /** px */
18
+ radius?: number;
19
+ padding?: "none" | "small" | "medium" | "large";
20
+ /** × the site's body size */
21
+ fontScale?: number;
22
+ pause?: "auto" | "short" | "medium" | "long";
23
+ /** % of the screen height scrolled while the camera moves into this stop */
24
+ move?: number;
25
+ animation?: "none" | "fade" | "rise" | "slide" | "scale";
26
+ }
27
+ export declare const WIDTH: {
28
+ readonly narrow: "24rem";
29
+ readonly medium: "32rem";
30
+ readonly wide: "44rem";
31
+ readonly full: "100%";
32
+ };
33
+ export declare const PADDING: {
34
+ readonly none: "0px";
35
+ readonly small: "12px";
36
+ readonly medium: "24px";
37
+ readonly large: "40px";
38
+ };
39
+ /** Minimum height of a stop: the camera holds at least this long. */
40
+ export declare const PAUSE: {
41
+ readonly auto: "100svh";
42
+ readonly short: "100svh";
43
+ readonly medium: "160svh";
44
+ readonly long: "240svh";
45
+ };
46
+ /** CSS custom properties for a style. Unset fields emit nothing, so they inherit (slot → placement → site). */
47
+ export declare function styleVars(s: SlotStyle | null | undefined): Record<string, string>;
48
+ /** The slot's own style over the placement's defaults (for previews; on the page, CSS inheritance does this). */
49
+ export declare function mergeStyle(base: SlotStyle | null | undefined, own: SlotStyle | null | undefined): SlotStyle;
50
+ /**
51
+ * Motion of content over a shot, driven by --stop-t, which the runtime writes on each shot's element:
52
+ * -1 → 0 while the camera moves in, 0 → 1 while it holds, 1 → 2 while it moves on.
53
+ */
54
+ export type MotionMove = "none" | "fade" | "up" | "down" | "left" | "right" | "scale" | "blur";
55
+ export interface SlotMotion {
56
+ /** How content comes in: "up" rises in from below, "down" drops in from above, "left" slides in from the left, "scale" zooms up. Default fade. */
57
+ enter?: MotionMove;
58
+ /** How it goes out: "reverse" (default) leaves the way it came in; "up" leaves upwards, "left" to the left, … */
59
+ exit?: MotionMove | "reverse";
60
+ /** Follow the scroll exactly (reverses when scrolling back), or play by itself at a set speed. */
61
+ mode?: "scrub" | "play";
62
+ /** When content arrives, relative to the camera. */
63
+ timing?: "early" | "with" | "late";
64
+ /** Strength: how far it slides, how much it zooms and blurs. */
65
+ distance?: "small" | "medium" | "large";
66
+ /** Blocks come in one after another. */
67
+ stagger?: boolean;
68
+ /** Content drifts slowly while the camera holds. */
69
+ parallax?: "none" | "subtle" | "strong";
70
+ /**
71
+ * "hold": the content stays on screen (placed by its position) while its shot is on, coming in and going out
72
+ * by its motion; the page scroll only drives the timing. "scroll": it scrolls past with the page, and its
73
+ * length sets how long the camera parks. Default hold.
74
+ */
75
+ flow?: "hold" | "scroll";
76
+ }
77
+ /** What an unset motion means everywhere (the page's own defaults sit on top of these). */
78
+ export declare const MOTION_DEFAULTS: Required<Omit<SlotMotion, "stagger">> & {
79
+ stagger: boolean;
80
+ };
81
+ /** Where the entrance happens, in --stop-t: start and length. */
82
+ export declare const TIMING: {
83
+ readonly early: readonly [-1, 0.6];
84
+ readonly with: readonly [-0.55, 0.55];
85
+ readonly late: readonly [0, 0.3];
86
+ };
87
+ /** Strength: slide distance, zoom amount (fraction of the size) and blur. */
88
+ export declare const STRENGTH: {
89
+ readonly small: {
90
+ readonly dist: "32px";
91
+ readonly scale: "0.05";
92
+ readonly blur: "4px";
93
+ };
94
+ readonly medium: {
95
+ readonly dist: "120px";
96
+ readonly scale: "0.15";
97
+ readonly blur: "12px";
98
+ };
99
+ readonly large: {
100
+ readonly dist: "40vw";
101
+ readonly scale: "0.4";
102
+ readonly blur: "28px";
103
+ };
104
+ };
105
+ export declare const PARALLAX: {
106
+ readonly none: "0px";
107
+ readonly subtle: "32px";
108
+ readonly strong: "96px";
109
+ };
110
+ /** CSS variables for a motion. Unset fields emit nothing, so they inherit (group → shot → page → defaults). */
111
+ export declare function motionVars(m: SlotMotion | null | undefined): Record<string, string>;
112
+ /** How far the card sits from its 3D point; with a line, the line's length. */
113
+ export declare const PIN_LINE: {
114
+ readonly short: "56px";
115
+ readonly medium: "112px";
116
+ readonly long: "200px";
117
+ };
118
+ export type PinLine = keyof typeof PIN_LINE;
119
+ /**
120
+ * CSS variables for a pinned group: which side of its point the card sits on (the group's own position:
121
+ * left / centre / right, above / middle / below; default centred above) and, for a callout, the line's length.
122
+ * Only the group's own style counts: a page-wide position doesn't move cards off their points.
123
+ */
124
+ export declare function pinVars(own: SlotStyle | null | undefined, line?: PinLine | null, card?: SlotStyle["card"] | null): Record<string, string>;
125
+ export declare function mergeMotion(...layers: (SlotMotion | null | undefined)[]): SlotMotion;
126
+ /**
127
+ * The motion rules, shared by the page and the Studio preview. Global class names: `ss-group` (a group of
128
+ * content over a shot; animates as a whole) and `ss-unit` (one block in it; animates on its own when the
129
+ * group has data-stagger, with --i its index). Everything is a no-op without --stop-t (no JS: content shows).
130
+ */
131
+ export declare const MOTION_CSS = "\n.ss-motion {\n --m-in-x: 0; --m-in-y: 0; --m-in-s: 0; --m-in-b: 0; --m-in-on: 1;\n --m-play: 0; --m-a: -0.55; --m-len: 0.55; --m-dist: 120px; --m-scl: 0.15; --m-blr: 12px; --m-par: 0px; --m-out-a: 1; --m-out-len: 0.5;\n}\n.ss-group, .ss-unit { --i: 0; }\n.ss-group:not([data-stagger]), .ss-group[data-stagger] > .ss-unit {\n --t: var(--stop-t, 0.5);\n --a: calc(var(--m-a) + var(--i) * var(--m-step, 0));\n --e: calc(clamp(0, (var(--t) - var(--a)) / var(--m-len), 1) * (1 - var(--m-play)) + clamp(0, (var(--t) - var(--a) - var(--m-len) / 2) * 1000, 1) * var(--m-play));\n --x: calc(clamp(0, (var(--t) - var(--m-out-a)) / var(--m-out-len), 1) * (1 - var(--m-play)) + clamp(0, (var(--t) - var(--m-out-a) - var(--m-out-len) / 2) * 1000, 1) * var(--m-play));\n --k: calc(1 - var(--e));\n /* The exit: its own, or (unset, or \"reverse\") the entrance played backwards. */\n --ox: var(--m-ex-x, var(--m-in-x)); --oy: var(--m-ex-y, var(--m-in-y)); --os: var(--m-ex-s, var(--m-in-s)); --ob: var(--m-ex-b, var(--m-in-b)); --oo: var(--m-ex-on, var(--m-in-on));\n opacity: calc((1 - var(--m-in-on) * var(--k)) * (1 - var(--oo) * var(--x)) * var(--g, 1));\n transform:\n translate3d(\n calc((var(--m-in-x) * var(--k) + var(--ox) * var(--x)) * var(--m-dist)),\n calc((var(--m-in-y) * var(--k) + var(--oy) * var(--x)) * var(--m-dist) + (0.5 - clamp(0, var(--t), 1)) * var(--m-par)),\n 0)\n scale(calc(1 - (var(--m-in-s) * var(--k) + var(--os) * var(--x)) * var(--m-scl)));\n filter: blur(calc((var(--m-in-b) * var(--k) + var(--ob) * var(--x)) * var(--m-blr)));\n transition-property: opacity, transform, filter;\n transition-duration: calc(var(--m-play) * 0.7s);\n transition-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);\n transition-delay: calc(var(--m-play) * var(--i) * 90ms);\n will-change: opacity, transform;\n}\n.ss-group[data-stagger] { --m-step: 0.15; }\n/* Held on screen ([data-hold] content, once the runtime drives the shots): shown only around its own shot, so\n neighbours swap halfway through the camera move between them (or when their motion says otherwise). */\n[data-stops-live] [data-hold] .ss-group:not([data-stagger]),\n[data-stops-live] [data-hold] .ss-group[data-stagger] > .ss-unit,\n[data-stops-live] [data-hold] .ss-group[data-stagger] {\n --g: calc(clamp(0, (var(--t) - min(-0.5, var(--a, var(--m-a)))) * 1000, 1) * clamp(0, (max(1.5, var(--m-out-a) + var(--m-out-len)) - var(--t)) * 1000, 1));\n}\n/* With a stagger, the group's box (its card) only fades, with its first block. */\n.ss-group[data-stagger] {\n --t: var(--stop-t, 0.5);\n opacity: calc((1 - var(--m-in-on) * (1 - clamp(0, (var(--t) - var(--m-a)) / var(--m-len), 1))) * (1 - var(--m-ex-on, var(--m-in-on)) * clamp(0, (var(--t) - var(--m-out-a)) / var(--m-out-len), 1)) * var(--g, 1));\n}\n/* Pinned to a 3D point (.ss-pin[data-pinned], at --px / --py): the card sits on one side of the point\n (--pin-dx / --pin-dy, -1 0 1), --pin-len away. A callout adds a line from the point to the card and a dot on\n the point; the line draws out as the shot comes on. Shown around its own shot, while the point is in view. */\n.ss-pin { --pin-dx: 0; --pin-dy: -1; --pin-len: 14px; }\n.ss-pin[data-pinned] {\n position: fixed; z-index: 1; left: var(--px); top: var(--py); width: 0; height: 0; display: block;\n --pt: var(--stop-t, 0.5);\n opacity: calc(var(--p-on, 1) * clamp(0, (var(--pt) + 0.6) * 1000, 1) * clamp(0, (1.6 - var(--pt)) * 1000, 1));\n transition: opacity 0.2s ease;\n}\n.ss-pin[data-pinned] .ss-pin-box {\n position: absolute; display: grid;\n left: calc(var(--pin-dx) * var(--pin-len)); top: calc(var(--pin-dy) * var(--pin-len));\n width: min(var(--slot-width, 22rem), 80vw);\n translate: calc((var(--pin-dx) - 1) * 50%) calc((var(--pin-dy) - 1) * 50%);\n}\n.ss-pin-line, .ss-pin-dot { display: none; }\n.ss-pin[data-pinned] .ss-pin-line {\n display: block; position: absolute; left: 0; top: -0.75px; height: 1.5px;\n width: calc(hypot(var(--pin-dx), var(--pin-dy)) * var(--pin-len));\n transform-origin: 0 50%;\n transform: rotate(atan2(var(--pin-dy), var(--pin-dx))) scaleX(min(clamp(0, (var(--pt) + 0.6) / 0.4, 1), clamp(0, (1.6 - var(--pt)) / 0.4, 1)));\n background: var(--pin-line, var(--slot-color, #fff));\n}\n.ss-pin[data-pinned] .ss-pin-dot {\n display: block; position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; box-sizing: border-box;\n border-radius: 50%; background: var(--pin-line, var(--slot-color, #fff));\n border: 3px solid var(--pin-ring, color-mix(in srgb, var(--slot-card-color, #1b1b1f) 85%, transparent));\n}\n@media (prefers-reduced-motion: reduce) {\n .ss-group, .ss-unit { opacity: var(--g, 1) !important; transform: none !important; filter: none !important; transition: none !important; }\n .ss-pin[data-pinned] .ss-pin-line { transform: rotate(atan2(var(--pin-dy), var(--pin-dx))) !important; }\n}\n";