@d4gger/design-system 4.0.2 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/_internal/BaseDialog.cjs +21 -18
- package/dist/_internal/BaseDialog.cjs.map +3 -3
- package/dist/_internal/BaseDialog.d.cts +3 -3
- package/dist/_internal/BaseDialog.d.cts.map +1 -1
- package/dist/_internal/BaseDialog.d.mts +3 -3
- package/dist/_internal/BaseDialog.d.mts.map +1 -1
- package/dist/_internal/BaseDialog.d.ts +3 -3
- package/dist/_internal/BaseDialog.d.ts.map +1 -1
- package/dist/_internal/BaseDialog.js +21 -18
- package/dist/_internal/BaseDialog.js.map +3 -3
- package/dist/components/richTextEditor/EditorTools.cjs +6 -3
- package/dist/components/richTextEditor/EditorTools.cjs.map +3 -3
- package/dist/components/richTextEditor/EditorTools.d.cts.map +1 -1
- package/dist/components/richTextEditor/EditorTools.d.mts.map +1 -1
- package/dist/components/richTextEditor/EditorTools.d.ts.map +1 -1
- package/dist/components/richTextEditor/EditorTools.js +6 -3
- package/dist/components/richTextEditor/EditorTools.js.map +3 -3
- package/dist/docs/component-index.json +1 -1
- package/dist/docs/components/rich-text-editor.md +1 -1
- package/dist/docs/consumer-guide.md +96 -0
- package/dist/foundations/Theme.cjs +5 -3
- package/dist/foundations/Theme.cjs.map +3 -3
- package/dist/foundations/Theme.d.cts +1 -1
- package/dist/foundations/Theme.d.cts.map +1 -1
- package/dist/foundations/Theme.d.mts +1 -1
- package/dist/foundations/Theme.d.mts.map +1 -1
- package/dist/foundations/Theme.d.ts +1 -1
- package/dist/foundations/Theme.d.ts.map +1 -1
- package/dist/foundations/Theme.js +5 -3
- package/dist/foundations/Theme.js.map +3 -3
- package/dist/foundations/telegram/index.cjs +20 -0
- package/dist/foundations/telegram/index.cjs.map +7 -0
- package/dist/foundations/telegram/index.d.cts +3 -0
- package/dist/foundations/telegram/index.d.cts.map +1 -0
- package/dist/foundations/telegram/index.d.mts +3 -0
- package/dist/foundations/telegram/index.d.mts.map +1 -0
- package/dist/foundations/telegram/index.d.ts +3 -0
- package/dist/foundations/telegram/index.d.ts.map +1 -0
- package/dist/foundations/telegram/index.js +3 -0
- package/dist/foundations/telegram/index.js.map +7 -0
- package/dist/foundations/telegram/theme-params.cjs +160 -0
- package/dist/foundations/telegram/theme-params.cjs.map +7 -0
- package/dist/foundations/telegram/theme-params.d.cts +124 -0
- package/dist/foundations/telegram/theme-params.d.cts.map +1 -0
- package/dist/foundations/telegram/theme-params.d.mts +124 -0
- package/dist/foundations/telegram/theme-params.d.mts.map +1 -0
- package/dist/foundations/telegram/theme-params.d.ts +124 -0
- package/dist/foundations/telegram/theme-params.d.ts.map +1 -0
- package/dist/foundations/telegram/theme-params.js +140 -0
- package/dist/foundations/telegram/theme-params.js.map +7 -0
- package/dist/foundations/telegram/viewport.cjs +81 -0
- package/dist/foundations/telegram/viewport.cjs.map +7 -0
- package/dist/foundations/telegram/viewport.d.cts +57 -0
- package/dist/foundations/telegram/viewport.d.cts.map +1 -0
- package/dist/foundations/telegram/viewport.d.mts +57 -0
- package/dist/foundations/telegram/viewport.d.mts.map +1 -0
- package/dist/foundations/telegram/viewport.d.ts +57 -0
- package/dist/foundations/telegram/viewport.d.ts.map +1 -0
- package/dist/foundations/telegram/viewport.js +61 -0
- package/dist/foundations/telegram/viewport.js.map +7 -0
- package/dist/styles.css +2 -3
- package/dist/telegram.css +93 -0
- package/dist/tokens.cjs +968 -0
- package/dist/tokens.d.cts +964 -0
- package/dist/tokens.d.mts +964 -0
- package/dist/tokens.d.ts +964 -0
- package/dist/tokens.dtcg.json +2511 -0
- package/dist/tokens.js +964 -0
- package/dist/tokens.json +964 -0
- package/dist/utilities.css +2 -3
- package/package.json +26 -2
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const TELEGRAM_THEME_PARAM_NAMES = [
|
|
2
|
+
"bg_color",
|
|
3
|
+
"text_color",
|
|
4
|
+
"hint_color",
|
|
5
|
+
"link_color",
|
|
6
|
+
"button_color",
|
|
7
|
+
"button_text_color",
|
|
8
|
+
"secondary_bg_color",
|
|
9
|
+
"header_bg_color",
|
|
10
|
+
"bottom_bar_bg_color",
|
|
11
|
+
"accent_text_color",
|
|
12
|
+
"section_bg_color",
|
|
13
|
+
"section_header_text_color",
|
|
14
|
+
"section_separator_color",
|
|
15
|
+
"subtitle_text_color",
|
|
16
|
+
"destructive_text_color"
|
|
17
|
+
];
|
|
18
|
+
const TELEGRAM_THEME_CSS_VARS = {
|
|
19
|
+
bg_color: "--tg-theme-bg-color",
|
|
20
|
+
text_color: "--tg-theme-text-color",
|
|
21
|
+
hint_color: "--tg-theme-hint-color",
|
|
22
|
+
link_color: "--tg-theme-link-color",
|
|
23
|
+
button_color: "--tg-theme-button-color",
|
|
24
|
+
button_text_color: "--tg-theme-button-text-color",
|
|
25
|
+
secondary_bg_color: "--tg-theme-secondary-bg-color",
|
|
26
|
+
header_bg_color: "--tg-theme-header-bg-color",
|
|
27
|
+
bottom_bar_bg_color: "--tg-theme-bottom-bar-bg-color",
|
|
28
|
+
accent_text_color: "--tg-theme-accent-text-color",
|
|
29
|
+
section_bg_color: "--tg-theme-section-bg-color",
|
|
30
|
+
section_header_text_color: "--tg-theme-section-header-text-color",
|
|
31
|
+
section_separator_color: "--tg-theme-section-separator-color",
|
|
32
|
+
subtitle_text_color: "--tg-theme-subtitle-text-color",
|
|
33
|
+
destructive_text_color: "--tg-theme-destructive-text-color"
|
|
34
|
+
};
|
|
35
|
+
const TELEGRAM_THEME_PARAM_BRIDGE = {
|
|
36
|
+
bg_color: ["--dsx-color-background"],
|
|
37
|
+
text_color: ["--dsx-color-on-background"],
|
|
38
|
+
hint_color: ["--dsx-color-on-surface-variant"],
|
|
39
|
+
link_color: ["--dsx-color-accent-indicator"],
|
|
40
|
+
accent_text_color: ["--dsx-color-accent-indicator"],
|
|
41
|
+
button_color: ["--dsx-color-primary", "--dsx-color-accent-track"],
|
|
42
|
+
button_text_color: ["--dsx-color-on-primary", "--dsx-color-accent-contrast"],
|
|
43
|
+
secondary_bg_color: ["--dsx-color-surface"],
|
|
44
|
+
section_bg_color: ["--dsx-color-surface-raised"],
|
|
45
|
+
destructive_text_color: ["--dsx-color-error"]
|
|
46
|
+
};
|
|
47
|
+
const TELEGRAM_THEME_PARAM_DERIVED = {
|
|
48
|
+
button_color: ["--dsx-color-accent-10", "--dsx-color-accent-surface"]
|
|
49
|
+
};
|
|
50
|
+
const HOVER_SHADE = 0.12;
|
|
51
|
+
const SURFACE_ALPHA = 0.2;
|
|
52
|
+
const TELEGRAM_BRIDGE_ORDER = [
|
|
53
|
+
"bg_color",
|
|
54
|
+
"text_color",
|
|
55
|
+
"hint_color",
|
|
56
|
+
"link_color",
|
|
57
|
+
"accent_text_color",
|
|
58
|
+
"button_color",
|
|
59
|
+
"button_text_color",
|
|
60
|
+
"secondary_bg_color",
|
|
61
|
+
"section_bg_color",
|
|
62
|
+
"destructive_text_color"
|
|
63
|
+
];
|
|
64
|
+
function isHexColor(value) {
|
|
65
|
+
return /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(value);
|
|
66
|
+
}
|
|
67
|
+
function parseHex(value) {
|
|
68
|
+
const digits = value.slice(1);
|
|
69
|
+
const full = digits.length === 3 ? [...digits].map((digit) => digit + digit).join("") : digits;
|
|
70
|
+
return [0, 2, 4].map((offset) => parseInt(full.slice(offset, offset + 2), 16));
|
|
71
|
+
}
|
|
72
|
+
function toHex(channels) {
|
|
73
|
+
return `#${channels.map((channel) => channel.toString(16).padStart(2, "0")).join("")}`;
|
|
74
|
+
}
|
|
75
|
+
const DERIVE_FROM_BUTTON_COLOR = {
|
|
76
|
+
"--dsx-color-accent-10": (rgb) => toHex(rgb.map((channel) => Math.round(channel * (1 - HOVER_SHADE)))),
|
|
77
|
+
"--dsx-color-accent-surface": ([red, green, blue]) => `rgba(${red}, ${green}, ${blue}, ${SURFACE_ALPHA})`
|
|
78
|
+
};
|
|
79
|
+
function writesFor(name, value) {
|
|
80
|
+
const writes = TELEGRAM_THEME_PARAM_BRIDGE[name].map((token) => [token, value]);
|
|
81
|
+
if (name === "button_color") {
|
|
82
|
+
const rgb = parseHex(value);
|
|
83
|
+
for (const token of TELEGRAM_THEME_PARAM_DERIVED.button_color) {
|
|
84
|
+
writes.push([token, DERIVE_FROM_BUTTON_COLOR[token](rgb)]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return writes;
|
|
88
|
+
}
|
|
89
|
+
function themeHosts(root) {
|
|
90
|
+
const { documentElement, body } = root.ownerDocument;
|
|
91
|
+
return root === documentElement && body ? [root, body] : [root];
|
|
92
|
+
}
|
|
93
|
+
const DEFAULT_APPLY_OPTIONS = {
|
|
94
|
+
density: "compact",
|
|
95
|
+
markHost: true
|
|
96
|
+
};
|
|
97
|
+
function applyTelegramThemeParams(root, params, options = {}) {
|
|
98
|
+
const { density, markHost } = { ...DEFAULT_APPLY_OPTIONS, ...options };
|
|
99
|
+
const hosts = themeHosts(root);
|
|
100
|
+
if (markHost && !root.hasAttribute("data-tg-mini-app")) {
|
|
101
|
+
root.setAttribute("data-tg-mini-app", "");
|
|
102
|
+
}
|
|
103
|
+
if (density !== false && !root.hasAttribute("data-dsx-density")) {
|
|
104
|
+
root.setAttribute("data-dsx-density", density);
|
|
105
|
+
}
|
|
106
|
+
for (const name of TELEGRAM_BRIDGE_ORDER) {
|
|
107
|
+
const value = params[name];
|
|
108
|
+
if (typeof value !== "string" || !isHexColor(value)) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
for (const [token, tokenValue] of writesFor(name, value)) {
|
|
112
|
+
for (const host of hosts) {
|
|
113
|
+
host.style.setProperty(token, tokenValue);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function clearTelegramThemeParams(root) {
|
|
119
|
+
const targets = /* @__PURE__ */ new Set();
|
|
120
|
+
for (const names of [...Object.values(TELEGRAM_THEME_PARAM_BRIDGE), ...Object.values(TELEGRAM_THEME_PARAM_DERIVED)]) {
|
|
121
|
+
for (const target of names) {
|
|
122
|
+
targets.add(target);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const host of themeHosts(root)) {
|
|
126
|
+
for (const target of targets) {
|
|
127
|
+
host.style.removeProperty(target);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
root.removeAttribute("data-tg-mini-app");
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
TELEGRAM_THEME_CSS_VARS,
|
|
134
|
+
TELEGRAM_THEME_PARAM_BRIDGE,
|
|
135
|
+
TELEGRAM_THEME_PARAM_DERIVED,
|
|
136
|
+
TELEGRAM_THEME_PARAM_NAMES,
|
|
137
|
+
applyTelegramThemeParams,
|
|
138
|
+
clearTelegramThemeParams
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=theme-params.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/foundations/telegram/theme-params.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Telegram Mini App `theme_params` contract and its bridge into DS tokens.\n *\n * Telegram publishes the client's palette two ways: as a `themeParams`\n * object on `Telegram.WebApp` (snake_case hex colors, e.g. `bg_color`) and\n * as CSS custom properties on `:root` (`--tg-theme-bg-color`, \u2026). This\n * module types the params object, names the CSS variables, and maps each\n * param onto the DS token it feeds \u2014 without taking a Telegram SDK\n * dependency (same stance as `ThemeProvider`'s system-mode handling).\n *\n * Mode ownership stays with `Theme` / `ThemeProvider`: this bridge only\n * writes paint tokens on the Mini App root. `colorScheme` sync (including\n * the `themeChanged` subscription) already lives in `ThemeProvider`.\n *\n * The bridge is the one path from Telegram's palette to DS tokens (G-35:\n * `telegram.css` carries no colour rules). It writes the accent *roles* the\n * components read (`track`, `contrast`, `indicator`, `surface`, ADR 003) next\n * to the legacy `primary` pair, and it writes on both `<html>` and `<body>`\n * because `Theme` mirrors its data attributes on both and the theme rules\n * re-declare every token on `<body>` (G-33, G-34).\n */\n\nexport type TelegramColorScheme = 'light' | 'dark'\n\n/**\n * Subset of `Telegram.WebApp.themeParams` the bridge consumes. Every field\n * is optional \u2014 Telegram omits keys it has no value for, and older clients\n * predate newer keys (`bottom_bar_bg_color`). Values are `#rrggbb` hex.\n */\nexport type TelegramThemeParams = {\n bg_color?: string\n text_color?: string\n hint_color?: string\n link_color?: string\n button_color?: string\n button_text_color?: string\n secondary_bg_color?: string\n header_bg_color?: string\n bottom_bar_bg_color?: string\n accent_text_color?: string\n section_bg_color?: string\n section_header_text_color?: string\n section_separator_color?: string\n subtitle_text_color?: string\n destructive_text_color?: string\n}\n\nexport type TelegramThemeParamName = keyof TelegramThemeParams\n\n/** Every `themeParams` key, in Telegram's documented order. */\nexport const TELEGRAM_THEME_PARAM_NAMES = [\n 'bg_color',\n 'text_color',\n 'hint_color',\n 'link_color',\n 'button_color',\n 'button_text_color',\n 'secondary_bg_color',\n 'header_bg_color',\n 'bottom_bar_bg_color',\n 'accent_text_color',\n 'section_bg_color',\n 'section_header_text_color',\n 'section_separator_color',\n 'subtitle_text_color',\n 'destructive_text_color',\n] as const satisfies readonly TelegramThemeParamName[]\n\n/** `themeParams` key \u2192 the `--tg-theme-*` CSS variable Telegram sets for it. */\nexport const TELEGRAM_THEME_CSS_VARS = {\n bg_color: '--tg-theme-bg-color',\n text_color: '--tg-theme-text-color',\n hint_color: '--tg-theme-hint-color',\n link_color: '--tg-theme-link-color',\n button_color: '--tg-theme-button-color',\n button_text_color: '--tg-theme-button-text-color',\n secondary_bg_color: '--tg-theme-secondary-bg-color',\n header_bg_color: '--tg-theme-header-bg-color',\n bottom_bar_bg_color: '--tg-theme-bottom-bar-bg-color',\n accent_text_color: '--tg-theme-accent-text-color',\n section_bg_color: '--tg-theme-section-bg-color',\n section_header_text_color: '--tg-theme-section-header-text-color',\n section_separator_color: '--tg-theme-section-separator-color',\n subtitle_text_color: '--tg-theme-subtitle-text-color',\n destructive_text_color: '--tg-theme-destructive-text-color',\n} as const satisfies Record<TelegramThemeParamName, `--tg-theme-${string}`>\n\n/**\n * `themeParams` key \u2192 DS paint token(s) `applyTelegramThemeParams` writes\n * verbatim. Only pairs with a clear semantic fit are bridged; the rest stay\n * readable through `TELEGRAM_THEME_CSS_VARS` for app-owned mapping.\n *\n * - `button_color` feeds the solid-fill role (`accent-track`: the primary\n * button, progress and slider fills) and the legacy `primary` alias.\n * - `button_text_color` feeds `accent-contrast` (text on that fill) and `on-primary`.\n * - `link_color` and `accent_text_color` feed `accent-indicator` (links, active\n * markers, accent foreground). Precedence: `accent_text_color` is applied\n * after `link_color`, so the more specific param wins when both are present.\n */\nexport const TELEGRAM_THEME_PARAM_BRIDGE = {\n bg_color: ['--dsx-color-background'],\n text_color: ['--dsx-color-on-background'],\n hint_color: ['--dsx-color-on-surface-variant'],\n link_color: ['--dsx-color-accent-indicator'],\n accent_text_color: ['--dsx-color-accent-indicator'],\n button_color: ['--dsx-color-primary', '--dsx-color-accent-track'],\n button_text_color: ['--dsx-color-on-primary', '--dsx-color-accent-contrast'],\n secondary_bg_color: ['--dsx-color-surface'],\n section_bg_color: ['--dsx-color-surface-raised'],\n destructive_text_color: ['--dsx-color-error'],\n} as const satisfies Partial<Record<TelegramThemeParamName, readonly string[]>>\n\n/**\n * Tokens the bridge derives from a param instead of copying it. Telegram has\n * no param for them, and leaving them would show the DS accent next to the\n * Telegram one: the primary button's hover step (`accent-10`, 12% darker than\n * `button_color`) and the soft accent surface behind selected rows and soft\n * badges (`accent-surface`, `button_color` at 20% alpha, as the shipped accents do).\n */\nexport const TELEGRAM_THEME_PARAM_DERIVED = {\n button_color: ['--dsx-color-accent-10', '--dsx-color-accent-surface'],\n} as const satisfies Partial<Record<TelegramThemeParamName, readonly string[]>>\n\nconst HOVER_SHADE = 0.12\nconst SURFACE_ALPHA = 0.2\n\ntype Rgb = readonly [number, number, number]\n\n/** Application order for the bridge: `accent_text_color` after `link_color` (the precedence note above). */\nconst TELEGRAM_BRIDGE_ORDER: Array<keyof typeof TELEGRAM_THEME_PARAM_BRIDGE> = [\n 'bg_color',\n 'text_color',\n 'hint_color',\n 'link_color',\n 'accent_text_color',\n 'button_color',\n 'button_text_color',\n 'secondary_bg_color',\n 'section_bg_color',\n 'destructive_text_color',\n]\n\nfunction isHexColor(value: string): boolean {\n return /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(value)\n}\n\nfunction parseHex(value: string): Rgb {\n const digits = value.slice(1)\n const full = digits.length === 3 ? [...digits].map((digit) => digit + digit).join('') : digits\n return [0, 2, 4].map((offset) => parseInt(full.slice(offset, offset + 2), 16)) as unknown as Rgb\n}\n\nfunction toHex(channels: Rgb): string {\n return `#${channels.map((channel) => channel.toString(16).padStart(2, '0')).join('')}`\n}\n\nconst DERIVE_FROM_BUTTON_COLOR: Record<(typeof TELEGRAM_THEME_PARAM_DERIVED.button_color)[number], (rgb: Rgb) => string> = {\n '--dsx-color-accent-10': (rgb) =>\n toHex(rgb.map((channel) => Math.round(channel * (1 - HOVER_SHADE))) as unknown as Rgb),\n '--dsx-color-accent-surface': ([red, green, blue]) => `rgba(${red}, ${green}, ${blue}, ${SURFACE_ALPHA})`,\n}\n\n/** Every `[token, value]` pair one valid param writes. */\nfunction writesFor(name: keyof typeof TELEGRAM_THEME_PARAM_BRIDGE, value: string): Array<[string, string]> {\n const writes: Array<[string, string]> = TELEGRAM_THEME_PARAM_BRIDGE[name].map((token) => [token, value])\n\n if (name === 'button_color') {\n const rgb = parseHex(value)\n for (const token of TELEGRAM_THEME_PARAM_DERIVED.button_color) {\n writes.push([token, DERIVE_FROM_BUTTON_COLOR[token](rgb)])\n }\n }\n\n return writes\n}\n\n/**\n * The elements that carry the DS theme attributes. `Theme` mirrors them on\n * `<html>` and `<body>`, and the theme rules re-declare every token on each\n * element that has them, so a value written only on `<html>` never reaches a\n * component under `<body>`. Given `<html>`, write on both; given anything else, on it alone.\n */\nfunction themeHosts(root: HTMLElement): HTMLElement[] {\n const { documentElement, body } = root.ownerDocument\n return root === documentElement && body ? [root, body] : [root]\n}\n\nexport type ApplyTelegramThemeParamsOptions = {\n /**\n * DS density for the Mini App root. Mini Apps default to `compact`\n * (small WebView, thumb reach); pass an explicit mode to override, or\n * `false` to leave the attribute untouched. A `data-dsx-density` the app\n * already set always wins over this default \u2014 `ThemeProvider` always sets\n * one, so an app under it passes `density={TELEGRAM_MINI_APP_DENSITY_DEFAULT}` itself.\n */\n density?: 'comfortable' | 'compact' | false\n /**\n * Write `data-tg-mini-app=\"\"` on the root so `telegram.css` can scope its\n * motion rules. Disable when the app manages its own marker.\n */\n markHost?: boolean\n}\n\nconst DEFAULT_APPLY_OPTIONS = {\n density: 'compact',\n markHost: true,\n} as const satisfies Required<ApplyTelegramThemeParamsOptions>\n\n/**\n * Bridge Telegram `theme_params` into DS paint tokens on `root` (usually\n * `document.documentElement`; `<body>` is covered with it). Writes are inline\n * custom properties, so they beat stylesheet defaults without `!important`\n * and vanish with the element. Unknown or non-hex values are skipped, never written.\n */\nexport function applyTelegramThemeParams(\n root: HTMLElement,\n params: TelegramThemeParams,\n options: ApplyTelegramThemeParamsOptions = {},\n): void {\n const { density, markHost } = { ...DEFAULT_APPLY_OPTIONS, ...options }\n const hosts = themeHosts(root)\n\n if (markHost && !root.hasAttribute('data-tg-mini-app')) {\n root.setAttribute('data-tg-mini-app', '')\n }\n\n if (density !== false && !root.hasAttribute('data-dsx-density')) {\n root.setAttribute('data-dsx-density', density)\n }\n\n for (const name of TELEGRAM_BRIDGE_ORDER) {\n const value = params[name]\n if (typeof value !== 'string' || !isHexColor(value)) {\n continue\n }\n\n for (const [token, tokenValue] of writesFor(name, value)) {\n for (const host of hosts) {\n host.style.setProperty(token, tokenValue)\n }\n }\n }\n}\n\n/** Remove everything `applyTelegramThemeParams` wrote (tokens, on every host, and the marker it set). */\nexport function clearTelegramThemeParams(root: HTMLElement): void {\n const targets = new Set<string>()\n for (const names of [...Object.values(TELEGRAM_THEME_PARAM_BRIDGE), ...Object.values(TELEGRAM_THEME_PARAM_DERIVED)]) {\n for (const target of names) {\n targets.add(target)\n }\n }\n\n for (const host of themeHosts(root)) {\n for (const target of targets) {\n host.style.removeProperty(target)\n }\n }\n\n root.removeAttribute('data-tg-mini-app')\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var viewport_exports = {};
|
|
20
|
+
__export(viewport_exports, {
|
|
21
|
+
TELEGRAM_COLOR_SCHEME_VAR: () => TELEGRAM_COLOR_SCHEME_VAR,
|
|
22
|
+
TELEGRAM_CONTENT_SAFE_AREA_VARS: () => TELEGRAM_CONTENT_SAFE_AREA_VARS,
|
|
23
|
+
TELEGRAM_MINI_APP_ATTRIBUTE: () => TELEGRAM_MINI_APP_ATTRIBUTE,
|
|
24
|
+
TELEGRAM_MINI_APP_DENSITY_DEFAULT: () => TELEGRAM_MINI_APP_DENSITY_DEFAULT,
|
|
25
|
+
TELEGRAM_SAFE_AREA_VARS: () => TELEGRAM_SAFE_AREA_VARS,
|
|
26
|
+
TELEGRAM_VIEWPORT_HEIGHT_VAR: () => TELEGRAM_VIEWPORT_HEIGHT_VAR,
|
|
27
|
+
TELEGRAM_VIEWPORT_STABLE_HEIGHT_VAR: () => TELEGRAM_VIEWPORT_STABLE_HEIGHT_VAR,
|
|
28
|
+
isTelegramWebView: () => isTelegramWebView,
|
|
29
|
+
observeTelegramHost: () => observeTelegramHost
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(viewport_exports);
|
|
32
|
+
const TELEGRAM_VIEWPORT_HEIGHT_VAR = "--tg-viewport-height";
|
|
33
|
+
const TELEGRAM_VIEWPORT_STABLE_HEIGHT_VAR = "--tg-viewport-stable-height";
|
|
34
|
+
const TELEGRAM_COLOR_SCHEME_VAR = "--tg-color-scheme";
|
|
35
|
+
const TELEGRAM_SAFE_AREA_VARS = {
|
|
36
|
+
top: "--tg-safe-area-inset-top",
|
|
37
|
+
right: "--tg-safe-area-inset-right",
|
|
38
|
+
bottom: "--tg-safe-area-inset-bottom",
|
|
39
|
+
left: "--tg-safe-area-inset-left"
|
|
40
|
+
};
|
|
41
|
+
const TELEGRAM_CONTENT_SAFE_AREA_VARS = {
|
|
42
|
+
top: "--tg-content-safe-area-inset-top",
|
|
43
|
+
right: "--tg-content-safe-area-inset-right",
|
|
44
|
+
bottom: "--tg-content-safe-area-inset-bottom",
|
|
45
|
+
left: "--tg-content-safe-area-inset-left"
|
|
46
|
+
};
|
|
47
|
+
const TELEGRAM_MINI_APP_DENSITY_DEFAULT = "compact";
|
|
48
|
+
const TELEGRAM_MINI_APP_ATTRIBUTE = "data-tg-mini-app";
|
|
49
|
+
function getTelegramWebApp() {
|
|
50
|
+
if (typeof window === "undefined") {
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
return window.Telegram?.WebApp;
|
|
54
|
+
}
|
|
55
|
+
function isTelegramWebView() {
|
|
56
|
+
return getTelegramWebApp() !== void 0;
|
|
57
|
+
}
|
|
58
|
+
function observeTelegramHost(apply, options = {}) {
|
|
59
|
+
const { themeChanged = true, viewportChanged = true } = options;
|
|
60
|
+
const webApp = getTelegramWebApp();
|
|
61
|
+
if (!webApp?.onEvent) {
|
|
62
|
+
return () => {
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const subscriptions = [];
|
|
66
|
+
if (themeChanged) {
|
|
67
|
+
subscriptions.push(["themeChanged", apply]);
|
|
68
|
+
}
|
|
69
|
+
if (viewportChanged) {
|
|
70
|
+
subscriptions.push(["viewportChanged", apply]);
|
|
71
|
+
}
|
|
72
|
+
for (const [type, listener] of subscriptions) {
|
|
73
|
+
webApp.onEvent(type, listener);
|
|
74
|
+
}
|
|
75
|
+
return () => {
|
|
76
|
+
for (const [type, listener] of subscriptions) {
|
|
77
|
+
webApp.offEvent?.(type, listener);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=viewport.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/foundations/telegram/viewport.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Telegram Mini App viewport contract: the CSS variables Telegram's script\n * sets on `:root` as soon as it loads (no `ready()` call is needed, and\n * Telegram keeps them current on `viewportChanged` / `safeAreaChanged` /\n * `contentSafeAreaChanged`), plus the DS-side defaults for hosted\n * (non-Telegram) rendering. CSS that reads them needs no JS subscription;\n * `observeTelegramHost` only re-runs the colour bridge.\n *\n * - `--tg-viewport-height` tracks the full WebView height, including areas\n * temporarily covered (e.g. by the on-screen keyboard).\n * - `--tg-viewport-stable-height` excludes transient shrinking \u2014 the value\n * full-height panels should bind to (already the default for `body` and\n * full Drawers via the `globals.css` compliance layer).\n * - `--tg-safe-area-inset-*` / `--tg-content-safe-area-inset-*` carry the\n * notch / status-bar / home-indicator regions; the content variant is the\n * inset inside Telegram's own bottom chrome.\n *\n * Every `var(--tg-\u2026)` reference in `telegram.css` carries a standard-web\n * fallback, so the stylesheet is a no-op outside a Telegram WebView. The\n * `qa:telegram-vars` package check enforces that invariant.\n */\n\nimport type { DensityMode } from '../../layout/responsive.props'\n\nexport const TELEGRAM_VIEWPORT_HEIGHT_VAR = '--tg-viewport-height' as const\nexport const TELEGRAM_VIEWPORT_STABLE_HEIGHT_VAR = '--tg-viewport-stable-height' as const\nexport const TELEGRAM_COLOR_SCHEME_VAR = '--tg-color-scheme' as const\n\nexport const TELEGRAM_SAFE_AREA_VARS = {\n top: '--tg-safe-area-inset-top',\n right: '--tg-safe-area-inset-right',\n bottom: '--tg-safe-area-inset-bottom',\n left: '--tg-safe-area-inset-left',\n} as const\n\nexport const TELEGRAM_CONTENT_SAFE_AREA_VARS = {\n top: '--tg-content-safe-area-inset-top',\n right: '--tg-content-safe-area-inset-right',\n bottom: '--tg-content-safe-area-inset-bottom',\n left: '--tg-content-safe-area-inset-left',\n} as const\n\n/** DS density a Mini App root defaults to \u2014 small WebView, thumb reach. */\nexport const TELEGRAM_MINI_APP_DENSITY_DEFAULT: DensityMode = 'compact'\n\n/** Host marker attribute the bridge sets and `telegram.css` scopes to. */\nexport const TELEGRAM_MINI_APP_ATTRIBUTE = 'data-tg-mini-app' as const\n\ntype MinimalTelegramWebApp = {\n colorScheme?: 'light' | 'dark'\n viewportHeight?: number\n viewportStableHeight?: number\n isExpanded?: boolean\n onEvent?: (type: string, listener: () => void) => void\n offEvent?: (type: string, listener: () => void) => void\n}\n\nfunction getTelegramWebApp(): MinimalTelegramWebApp | undefined {\n if (typeof window === 'undefined') {\n return undefined\n }\n\n return (window as typeof window & { Telegram?: { WebApp?: MinimalTelegramWebApp } }).Telegram?.WebApp\n}\n\n/** True inside a Telegram Mini App WebView (real or stubbed in tests). */\nexport function isTelegramWebView(): boolean {\n return getTelegramWebApp() !== undefined\n}\n\nexport type ObserveTelegramHostOptions = {\n /** Re-run the bridge when Telegram fires `themeChanged`. Default true. */\n themeChanged?: boolean\n /** Re-run the bridge when Telegram fires `viewportChanged`. Default true. */\n viewportChanged?: boolean\n}\n\n/**\n * Keep the bridge output fresh across a Mini App session: re-runs `apply`\n * on Telegram's `themeChanged` / `viewportChanged` events. Returns a\n * cleanup that detaches both listeners. No-op (returns a no-op cleanup)\n * outside a Telegram WebView or when the host exposes no event API.\n */\nexport function observeTelegramHost(\n apply: () => void,\n options: ObserveTelegramHostOptions = {},\n): () => void {\n const { themeChanged = true, viewportChanged = true } = options\n const webApp = getTelegramWebApp()\n if (!webApp?.onEvent) {\n return () => {}\n }\n\n const subscriptions: Array<[string, () => void]> = []\n if (themeChanged) {\n subscriptions.push(['themeChanged', apply])\n }\n if (viewportChanged) {\n subscriptions.push(['viewportChanged', apply])\n }\n\n for (const [type, listener] of subscriptions) {\n webApp.onEvent(type, listener)\n }\n\n return () => {\n for (const [type, listener] of subscriptions) {\n webApp.offEvent?.(type, listener)\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBO,MAAM,+BAA+B;AACrC,MAAM,sCAAsC;AAC5C,MAAM,4BAA4B;AAElC,MAAM,0BAA0B;AAAA,EACrC,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;AAEO,MAAM,kCAAkC;AAAA,EAC7C,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;AAGO,MAAM,oCAAiD;AAGvD,MAAM,8BAA8B;AAW3C,SAAS,oBAAuD;AAC9D,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;AAAA,EACT;AAEA,SAAQ,OAA6E,UAAU;AACjG;AAGO,SAAS,oBAA6B;AAC3C,SAAO,kBAAkB,MAAM;AACjC;AAeO,SAAS,oBACd,OACA,UAAsC,CAAC,GAC3B;AACZ,QAAM,EAAE,eAAe,MAAM,kBAAkB,KAAK,IAAI;AACxD,QAAM,SAAS,kBAAkB;AACjC,MAAI,CAAC,QAAQ,SAAS;AACpB,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AAEA,QAAM,gBAA6C,CAAC;AACpD,MAAI,cAAc;AAChB,kBAAc,KAAK,CAAC,gBAAgB,KAAK,CAAC;AAAA,EAC5C;AACA,MAAI,iBAAiB;AACnB,kBAAc,KAAK,CAAC,mBAAmB,KAAK,CAAC;AAAA,EAC/C;AAEA,aAAW,CAAC,MAAM,QAAQ,KAAK,eAAe;AAC5C,WAAO,QAAQ,MAAM,QAAQ;AAAA,EAC/B;AAEA,SAAO,MAAM;AACX,eAAW,CAAC,MAAM,QAAQ,KAAK,eAAe;AAC5C,aAAO,WAAW,MAAM,QAAQ;AAAA,IAClC;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Mini App viewport contract: the CSS variables Telegram's script
|
|
3
|
+
* sets on `:root` as soon as it loads (no `ready()` call is needed, and
|
|
4
|
+
* Telegram keeps them current on `viewportChanged` / `safeAreaChanged` /
|
|
5
|
+
* `contentSafeAreaChanged`), plus the DS-side defaults for hosted
|
|
6
|
+
* (non-Telegram) rendering. CSS that reads them needs no JS subscription;
|
|
7
|
+
* `observeTelegramHost` only re-runs the colour bridge.
|
|
8
|
+
*
|
|
9
|
+
* - `--tg-viewport-height` tracks the full WebView height, including areas
|
|
10
|
+
* temporarily covered (e.g. by the on-screen keyboard).
|
|
11
|
+
* - `--tg-viewport-stable-height` excludes transient shrinking — the value
|
|
12
|
+
* full-height panels should bind to (already the default for `body` and
|
|
13
|
+
* full Drawers via the `globals.css` compliance layer).
|
|
14
|
+
* - `--tg-safe-area-inset-*` / `--tg-content-safe-area-inset-*` carry the
|
|
15
|
+
* notch / status-bar / home-indicator regions; the content variant is the
|
|
16
|
+
* inset inside Telegram's own bottom chrome.
|
|
17
|
+
*
|
|
18
|
+
* Every `var(--tg-…)` reference in `telegram.css` carries a standard-web
|
|
19
|
+
* fallback, so the stylesheet is a no-op outside a Telegram WebView. The
|
|
20
|
+
* `qa:telegram-vars` package check enforces that invariant.
|
|
21
|
+
*/
|
|
22
|
+
import type { DensityMode } from '../../layout/responsive.props.cjs';
|
|
23
|
+
export declare const TELEGRAM_VIEWPORT_HEIGHT_VAR: "--tg-viewport-height";
|
|
24
|
+
export declare const TELEGRAM_VIEWPORT_STABLE_HEIGHT_VAR: "--tg-viewport-stable-height";
|
|
25
|
+
export declare const TELEGRAM_COLOR_SCHEME_VAR: "--tg-color-scheme";
|
|
26
|
+
export declare const TELEGRAM_SAFE_AREA_VARS: {
|
|
27
|
+
readonly top: "--tg-safe-area-inset-top";
|
|
28
|
+
readonly right: "--tg-safe-area-inset-right";
|
|
29
|
+
readonly bottom: "--tg-safe-area-inset-bottom";
|
|
30
|
+
readonly left: "--tg-safe-area-inset-left";
|
|
31
|
+
};
|
|
32
|
+
export declare const TELEGRAM_CONTENT_SAFE_AREA_VARS: {
|
|
33
|
+
readonly top: "--tg-content-safe-area-inset-top";
|
|
34
|
+
readonly right: "--tg-content-safe-area-inset-right";
|
|
35
|
+
readonly bottom: "--tg-content-safe-area-inset-bottom";
|
|
36
|
+
readonly left: "--tg-content-safe-area-inset-left";
|
|
37
|
+
};
|
|
38
|
+
/** DS density a Mini App root defaults to — small WebView, thumb reach. */
|
|
39
|
+
export declare const TELEGRAM_MINI_APP_DENSITY_DEFAULT: DensityMode;
|
|
40
|
+
/** Host marker attribute the bridge sets and `telegram.css` scopes to. */
|
|
41
|
+
export declare const TELEGRAM_MINI_APP_ATTRIBUTE: "data-tg-mini-app";
|
|
42
|
+
/** True inside a Telegram Mini App WebView (real or stubbed in tests). */
|
|
43
|
+
export declare function isTelegramWebView(): boolean;
|
|
44
|
+
export type ObserveTelegramHostOptions = {
|
|
45
|
+
/** Re-run the bridge when Telegram fires `themeChanged`. Default true. */
|
|
46
|
+
themeChanged?: boolean;
|
|
47
|
+
/** Re-run the bridge when Telegram fires `viewportChanged`. Default true. */
|
|
48
|
+
viewportChanged?: boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Keep the bridge output fresh across a Mini App session: re-runs `apply`
|
|
52
|
+
* on Telegram's `themeChanged` / `viewportChanged` events. Returns a
|
|
53
|
+
* cleanup that detaches both listeners. No-op (returns a no-op cleanup)
|
|
54
|
+
* outside a Telegram WebView or when the host exposes no event API.
|
|
55
|
+
*/
|
|
56
|
+
export declare function observeTelegramHost(apply: () => void, options?: ObserveTelegramHostOptions): () => void;
|
|
57
|
+
//# sourceMappingURL=viewport.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.cts","sourceRoot":"","sources":["../../../src/foundations/telegram/viewport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAEhE,eAAO,MAAM,4BAA4B,EAAG,sBAA+B,CAAA;AAC3E,eAAO,MAAM,mCAAmC,EAAG,6BAAsC,CAAA;AACzF,eAAO,MAAM,yBAAyB,EAAG,mBAA4B,CAAA;AAErE,eAAO,MAAM,uBAAuB;;;;;CAK1B,CAAA;AAEV,eAAO,MAAM,+BAA+B;;;;;CAKlC,CAAA;AAEV,2EAA2E;AAC3E,eAAO,MAAM,iCAAiC,EAAE,WAAuB,CAAA;AAEvE,0EAA0E;AAC1E,eAAO,MAAM,2BAA2B,EAAG,kBAA2B,CAAA;AAmBtE,0EAA0E;AAC1E,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,0EAA0E;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,6EAA6E;IAC7E,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,IAAI,EACjB,OAAO,GAAE,0BAA+B,GACvC,MAAM,IAAI,CAwBZ"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Mini App viewport contract: the CSS variables Telegram's script
|
|
3
|
+
* sets on `:root` as soon as it loads (no `ready()` call is needed, and
|
|
4
|
+
* Telegram keeps them current on `viewportChanged` / `safeAreaChanged` /
|
|
5
|
+
* `contentSafeAreaChanged`), plus the DS-side defaults for hosted
|
|
6
|
+
* (non-Telegram) rendering. CSS that reads them needs no JS subscription;
|
|
7
|
+
* `observeTelegramHost` only re-runs the colour bridge.
|
|
8
|
+
*
|
|
9
|
+
* - `--tg-viewport-height` tracks the full WebView height, including areas
|
|
10
|
+
* temporarily covered (e.g. by the on-screen keyboard).
|
|
11
|
+
* - `--tg-viewport-stable-height` excludes transient shrinking — the value
|
|
12
|
+
* full-height panels should bind to (already the default for `body` and
|
|
13
|
+
* full Drawers via the `globals.css` compliance layer).
|
|
14
|
+
* - `--tg-safe-area-inset-*` / `--tg-content-safe-area-inset-*` carry the
|
|
15
|
+
* notch / status-bar / home-indicator regions; the content variant is the
|
|
16
|
+
* inset inside Telegram's own bottom chrome.
|
|
17
|
+
*
|
|
18
|
+
* Every `var(--tg-…)` reference in `telegram.css` carries a standard-web
|
|
19
|
+
* fallback, so the stylesheet is a no-op outside a Telegram WebView. The
|
|
20
|
+
* `qa:telegram-vars` package check enforces that invariant.
|
|
21
|
+
*/
|
|
22
|
+
import type { DensityMode } from '../../layout/responsive.props.js';
|
|
23
|
+
export declare const TELEGRAM_VIEWPORT_HEIGHT_VAR: "--tg-viewport-height";
|
|
24
|
+
export declare const TELEGRAM_VIEWPORT_STABLE_HEIGHT_VAR: "--tg-viewport-stable-height";
|
|
25
|
+
export declare const TELEGRAM_COLOR_SCHEME_VAR: "--tg-color-scheme";
|
|
26
|
+
export declare const TELEGRAM_SAFE_AREA_VARS: {
|
|
27
|
+
readonly top: "--tg-safe-area-inset-top";
|
|
28
|
+
readonly right: "--tg-safe-area-inset-right";
|
|
29
|
+
readonly bottom: "--tg-safe-area-inset-bottom";
|
|
30
|
+
readonly left: "--tg-safe-area-inset-left";
|
|
31
|
+
};
|
|
32
|
+
export declare const TELEGRAM_CONTENT_SAFE_AREA_VARS: {
|
|
33
|
+
readonly top: "--tg-content-safe-area-inset-top";
|
|
34
|
+
readonly right: "--tg-content-safe-area-inset-right";
|
|
35
|
+
readonly bottom: "--tg-content-safe-area-inset-bottom";
|
|
36
|
+
readonly left: "--tg-content-safe-area-inset-left";
|
|
37
|
+
};
|
|
38
|
+
/** DS density a Mini App root defaults to — small WebView, thumb reach. */
|
|
39
|
+
export declare const TELEGRAM_MINI_APP_DENSITY_DEFAULT: DensityMode;
|
|
40
|
+
/** Host marker attribute the bridge sets and `telegram.css` scopes to. */
|
|
41
|
+
export declare const TELEGRAM_MINI_APP_ATTRIBUTE: "data-tg-mini-app";
|
|
42
|
+
/** True inside a Telegram Mini App WebView (real or stubbed in tests). */
|
|
43
|
+
export declare function isTelegramWebView(): boolean;
|
|
44
|
+
export type ObserveTelegramHostOptions = {
|
|
45
|
+
/** Re-run the bridge when Telegram fires `themeChanged`. Default true. */
|
|
46
|
+
themeChanged?: boolean;
|
|
47
|
+
/** Re-run the bridge when Telegram fires `viewportChanged`. Default true. */
|
|
48
|
+
viewportChanged?: boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Keep the bridge output fresh across a Mini App session: re-runs `apply`
|
|
52
|
+
* on Telegram's `themeChanged` / `viewportChanged` events. Returns a
|
|
53
|
+
* cleanup that detaches both listeners. No-op (returns a no-op cleanup)
|
|
54
|
+
* outside a Telegram WebView or when the host exposes no event API.
|
|
55
|
+
*/
|
|
56
|
+
export declare function observeTelegramHost(apply: () => void, options?: ObserveTelegramHostOptions): () => void;
|
|
57
|
+
//# sourceMappingURL=viewport.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.mts","sourceRoot":"","sources":["../../../src/foundations/telegram/viewport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAEhE,eAAO,MAAM,4BAA4B,EAAG,sBAA+B,CAAA;AAC3E,eAAO,MAAM,mCAAmC,EAAG,6BAAsC,CAAA;AACzF,eAAO,MAAM,yBAAyB,EAAG,mBAA4B,CAAA;AAErE,eAAO,MAAM,uBAAuB;;;;;CAK1B,CAAA;AAEV,eAAO,MAAM,+BAA+B;;;;;CAKlC,CAAA;AAEV,2EAA2E;AAC3E,eAAO,MAAM,iCAAiC,EAAE,WAAuB,CAAA;AAEvE,0EAA0E;AAC1E,eAAO,MAAM,2BAA2B,EAAG,kBAA2B,CAAA;AAmBtE,0EAA0E;AAC1E,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,0EAA0E;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,6EAA6E;IAC7E,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,IAAI,EACjB,OAAO,GAAE,0BAA+B,GACvC,MAAM,IAAI,CAwBZ"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Mini App viewport contract: the CSS variables Telegram's script
|
|
3
|
+
* sets on `:root` as soon as it loads (no `ready()` call is needed, and
|
|
4
|
+
* Telegram keeps them current on `viewportChanged` / `safeAreaChanged` /
|
|
5
|
+
* `contentSafeAreaChanged`), plus the DS-side defaults for hosted
|
|
6
|
+
* (non-Telegram) rendering. CSS that reads them needs no JS subscription;
|
|
7
|
+
* `observeTelegramHost` only re-runs the colour bridge.
|
|
8
|
+
*
|
|
9
|
+
* - `--tg-viewport-height` tracks the full WebView height, including areas
|
|
10
|
+
* temporarily covered (e.g. by the on-screen keyboard).
|
|
11
|
+
* - `--tg-viewport-stable-height` excludes transient shrinking — the value
|
|
12
|
+
* full-height panels should bind to (already the default for `body` and
|
|
13
|
+
* full Drawers via the `globals.css` compliance layer).
|
|
14
|
+
* - `--tg-safe-area-inset-*` / `--tg-content-safe-area-inset-*` carry the
|
|
15
|
+
* notch / status-bar / home-indicator regions; the content variant is the
|
|
16
|
+
* inset inside Telegram's own bottom chrome.
|
|
17
|
+
*
|
|
18
|
+
* Every `var(--tg-…)` reference in `telegram.css` carries a standard-web
|
|
19
|
+
* fallback, so the stylesheet is a no-op outside a Telegram WebView. The
|
|
20
|
+
* `qa:telegram-vars` package check enforces that invariant.
|
|
21
|
+
*/
|
|
22
|
+
import type { DensityMode } from '../../layout/responsive.props.js';
|
|
23
|
+
export declare const TELEGRAM_VIEWPORT_HEIGHT_VAR: "--tg-viewport-height";
|
|
24
|
+
export declare const TELEGRAM_VIEWPORT_STABLE_HEIGHT_VAR: "--tg-viewport-stable-height";
|
|
25
|
+
export declare const TELEGRAM_COLOR_SCHEME_VAR: "--tg-color-scheme";
|
|
26
|
+
export declare const TELEGRAM_SAFE_AREA_VARS: {
|
|
27
|
+
readonly top: "--tg-safe-area-inset-top";
|
|
28
|
+
readonly right: "--tg-safe-area-inset-right";
|
|
29
|
+
readonly bottom: "--tg-safe-area-inset-bottom";
|
|
30
|
+
readonly left: "--tg-safe-area-inset-left";
|
|
31
|
+
};
|
|
32
|
+
export declare const TELEGRAM_CONTENT_SAFE_AREA_VARS: {
|
|
33
|
+
readonly top: "--tg-content-safe-area-inset-top";
|
|
34
|
+
readonly right: "--tg-content-safe-area-inset-right";
|
|
35
|
+
readonly bottom: "--tg-content-safe-area-inset-bottom";
|
|
36
|
+
readonly left: "--tg-content-safe-area-inset-left";
|
|
37
|
+
};
|
|
38
|
+
/** DS density a Mini App root defaults to — small WebView, thumb reach. */
|
|
39
|
+
export declare const TELEGRAM_MINI_APP_DENSITY_DEFAULT: DensityMode;
|
|
40
|
+
/** Host marker attribute the bridge sets and `telegram.css` scopes to. */
|
|
41
|
+
export declare const TELEGRAM_MINI_APP_ATTRIBUTE: "data-tg-mini-app";
|
|
42
|
+
/** True inside a Telegram Mini App WebView (real or stubbed in tests). */
|
|
43
|
+
export declare function isTelegramWebView(): boolean;
|
|
44
|
+
export type ObserveTelegramHostOptions = {
|
|
45
|
+
/** Re-run the bridge when Telegram fires `themeChanged`. Default true. */
|
|
46
|
+
themeChanged?: boolean;
|
|
47
|
+
/** Re-run the bridge when Telegram fires `viewportChanged`. Default true. */
|
|
48
|
+
viewportChanged?: boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Keep the bridge output fresh across a Mini App session: re-runs `apply`
|
|
52
|
+
* on Telegram's `themeChanged` / `viewportChanged` events. Returns a
|
|
53
|
+
* cleanup that detaches both listeners. No-op (returns a no-op cleanup)
|
|
54
|
+
* outside a Telegram WebView or when the host exposes no event API.
|
|
55
|
+
*/
|
|
56
|
+
export declare function observeTelegramHost(apply: () => void, options?: ObserveTelegramHostOptions): () => void;
|
|
57
|
+
//# sourceMappingURL=viewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../../src/foundations/telegram/viewport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAEhE,eAAO,MAAM,4BAA4B,EAAG,sBAA+B,CAAA;AAC3E,eAAO,MAAM,mCAAmC,EAAG,6BAAsC,CAAA;AACzF,eAAO,MAAM,yBAAyB,EAAG,mBAA4B,CAAA;AAErE,eAAO,MAAM,uBAAuB;;;;;CAK1B,CAAA;AAEV,eAAO,MAAM,+BAA+B;;;;;CAKlC,CAAA;AAEV,2EAA2E;AAC3E,eAAO,MAAM,iCAAiC,EAAE,WAAuB,CAAA;AAEvE,0EAA0E;AAC1E,eAAO,MAAM,2BAA2B,EAAG,kBAA2B,CAAA;AAmBtE,0EAA0E;AAC1E,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,0EAA0E;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,6EAA6E;IAC7E,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,IAAI,EACjB,OAAO,GAAE,0BAA+B,GACvC,MAAM,IAAI,CAwBZ"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const TELEGRAM_VIEWPORT_HEIGHT_VAR = "--tg-viewport-height";
|
|
2
|
+
const TELEGRAM_VIEWPORT_STABLE_HEIGHT_VAR = "--tg-viewport-stable-height";
|
|
3
|
+
const TELEGRAM_COLOR_SCHEME_VAR = "--tg-color-scheme";
|
|
4
|
+
const TELEGRAM_SAFE_AREA_VARS = {
|
|
5
|
+
top: "--tg-safe-area-inset-top",
|
|
6
|
+
right: "--tg-safe-area-inset-right",
|
|
7
|
+
bottom: "--tg-safe-area-inset-bottom",
|
|
8
|
+
left: "--tg-safe-area-inset-left"
|
|
9
|
+
};
|
|
10
|
+
const TELEGRAM_CONTENT_SAFE_AREA_VARS = {
|
|
11
|
+
top: "--tg-content-safe-area-inset-top",
|
|
12
|
+
right: "--tg-content-safe-area-inset-right",
|
|
13
|
+
bottom: "--tg-content-safe-area-inset-bottom",
|
|
14
|
+
left: "--tg-content-safe-area-inset-left"
|
|
15
|
+
};
|
|
16
|
+
const TELEGRAM_MINI_APP_DENSITY_DEFAULT = "compact";
|
|
17
|
+
const TELEGRAM_MINI_APP_ATTRIBUTE = "data-tg-mini-app";
|
|
18
|
+
function getTelegramWebApp() {
|
|
19
|
+
if (typeof window === "undefined") {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
return window.Telegram?.WebApp;
|
|
23
|
+
}
|
|
24
|
+
function isTelegramWebView() {
|
|
25
|
+
return getTelegramWebApp() !== void 0;
|
|
26
|
+
}
|
|
27
|
+
function observeTelegramHost(apply, options = {}) {
|
|
28
|
+
const { themeChanged = true, viewportChanged = true } = options;
|
|
29
|
+
const webApp = getTelegramWebApp();
|
|
30
|
+
if (!webApp?.onEvent) {
|
|
31
|
+
return () => {
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const subscriptions = [];
|
|
35
|
+
if (themeChanged) {
|
|
36
|
+
subscriptions.push(["themeChanged", apply]);
|
|
37
|
+
}
|
|
38
|
+
if (viewportChanged) {
|
|
39
|
+
subscriptions.push(["viewportChanged", apply]);
|
|
40
|
+
}
|
|
41
|
+
for (const [type, listener] of subscriptions) {
|
|
42
|
+
webApp.onEvent(type, listener);
|
|
43
|
+
}
|
|
44
|
+
return () => {
|
|
45
|
+
for (const [type, listener] of subscriptions) {
|
|
46
|
+
webApp.offEvent?.(type, listener);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
TELEGRAM_COLOR_SCHEME_VAR,
|
|
52
|
+
TELEGRAM_CONTENT_SAFE_AREA_VARS,
|
|
53
|
+
TELEGRAM_MINI_APP_ATTRIBUTE,
|
|
54
|
+
TELEGRAM_MINI_APP_DENSITY_DEFAULT,
|
|
55
|
+
TELEGRAM_SAFE_AREA_VARS,
|
|
56
|
+
TELEGRAM_VIEWPORT_HEIGHT_VAR,
|
|
57
|
+
TELEGRAM_VIEWPORT_STABLE_HEIGHT_VAR,
|
|
58
|
+
isTelegramWebView,
|
|
59
|
+
observeTelegramHost
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=viewport.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/foundations/telegram/viewport.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Telegram Mini App viewport contract: the CSS variables Telegram's script\n * sets on `:root` as soon as it loads (no `ready()` call is needed, and\n * Telegram keeps them current on `viewportChanged` / `safeAreaChanged` /\n * `contentSafeAreaChanged`), plus the DS-side defaults for hosted\n * (non-Telegram) rendering. CSS that reads them needs no JS subscription;\n * `observeTelegramHost` only re-runs the colour bridge.\n *\n * - `--tg-viewport-height` tracks the full WebView height, including areas\n * temporarily covered (e.g. by the on-screen keyboard).\n * - `--tg-viewport-stable-height` excludes transient shrinking \u2014 the value\n * full-height panels should bind to (already the default for `body` and\n * full Drawers via the `globals.css` compliance layer).\n * - `--tg-safe-area-inset-*` / `--tg-content-safe-area-inset-*` carry the\n * notch / status-bar / home-indicator regions; the content variant is the\n * inset inside Telegram's own bottom chrome.\n *\n * Every `var(--tg-\u2026)` reference in `telegram.css` carries a standard-web\n * fallback, so the stylesheet is a no-op outside a Telegram WebView. The\n * `qa:telegram-vars` package check enforces that invariant.\n */\n\nimport type { DensityMode } from '../../layout/responsive.props'\n\nexport const TELEGRAM_VIEWPORT_HEIGHT_VAR = '--tg-viewport-height' as const\nexport const TELEGRAM_VIEWPORT_STABLE_HEIGHT_VAR = '--tg-viewport-stable-height' as const\nexport const TELEGRAM_COLOR_SCHEME_VAR = '--tg-color-scheme' as const\n\nexport const TELEGRAM_SAFE_AREA_VARS = {\n top: '--tg-safe-area-inset-top',\n right: '--tg-safe-area-inset-right',\n bottom: '--tg-safe-area-inset-bottom',\n left: '--tg-safe-area-inset-left',\n} as const\n\nexport const TELEGRAM_CONTENT_SAFE_AREA_VARS = {\n top: '--tg-content-safe-area-inset-top',\n right: '--tg-content-safe-area-inset-right',\n bottom: '--tg-content-safe-area-inset-bottom',\n left: '--tg-content-safe-area-inset-left',\n} as const\n\n/** DS density a Mini App root defaults to \u2014 small WebView, thumb reach. */\nexport const TELEGRAM_MINI_APP_DENSITY_DEFAULT: DensityMode = 'compact'\n\n/** Host marker attribute the bridge sets and `telegram.css` scopes to. */\nexport const TELEGRAM_MINI_APP_ATTRIBUTE = 'data-tg-mini-app' as const\n\ntype MinimalTelegramWebApp = {\n colorScheme?: 'light' | 'dark'\n viewportHeight?: number\n viewportStableHeight?: number\n isExpanded?: boolean\n onEvent?: (type: string, listener: () => void) => void\n offEvent?: (type: string, listener: () => void) => void\n}\n\nfunction getTelegramWebApp(): MinimalTelegramWebApp | undefined {\n if (typeof window === 'undefined') {\n return undefined\n }\n\n return (window as typeof window & { Telegram?: { WebApp?: MinimalTelegramWebApp } }).Telegram?.WebApp\n}\n\n/** True inside a Telegram Mini App WebView (real or stubbed in tests). */\nexport function isTelegramWebView(): boolean {\n return getTelegramWebApp() !== undefined\n}\n\nexport type ObserveTelegramHostOptions = {\n /** Re-run the bridge when Telegram fires `themeChanged`. Default true. */\n themeChanged?: boolean\n /** Re-run the bridge when Telegram fires `viewportChanged`. Default true. */\n viewportChanged?: boolean\n}\n\n/**\n * Keep the bridge output fresh across a Mini App session: re-runs `apply`\n * on Telegram's `themeChanged` / `viewportChanged` events. Returns a\n * cleanup that detaches both listeners. No-op (returns a no-op cleanup)\n * outside a Telegram WebView or when the host exposes no event API.\n */\nexport function observeTelegramHost(\n apply: () => void,\n options: ObserveTelegramHostOptions = {},\n): () => void {\n const { themeChanged = true, viewportChanged = true } = options\n const webApp = getTelegramWebApp()\n if (!webApp?.onEvent) {\n return () => {}\n }\n\n const subscriptions: Array<[string, () => void]> = []\n if (themeChanged) {\n subscriptions.push(['themeChanged', apply])\n }\n if (viewportChanged) {\n subscriptions.push(['viewportChanged', apply])\n }\n\n for (const [type, listener] of subscriptions) {\n webApp.onEvent(type, listener)\n }\n\n return () => {\n for (const [type, listener] of subscriptions) {\n webApp.offEvent?.(type, listener)\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAwBO,MAAM,+BAA+B;AACrC,MAAM,sCAAsC;AAC5C,MAAM,4BAA4B;AAElC,MAAM,0BAA0B;AAAA,EACrC,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;AAEO,MAAM,kCAAkC;AAAA,EAC7C,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;AAGO,MAAM,oCAAiD;AAGvD,MAAM,8BAA8B;AAW3C,SAAS,oBAAuD;AAC9D,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;AAAA,EACT;AAEA,SAAQ,OAA6E,UAAU;AACjG;AAGO,SAAS,oBAA6B;AAC3C,SAAO,kBAAkB,MAAM;AACjC;AAeO,SAAS,oBACd,OACA,UAAsC,CAAC,GAC3B;AACZ,QAAM,EAAE,eAAe,MAAM,kBAAkB,KAAK,IAAI;AACxD,QAAM,SAAS,kBAAkB;AACjC,MAAI,CAAC,QAAQ,SAAS;AACpB,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AAEA,QAAM,gBAA6C,CAAC;AACpD,MAAI,cAAc;AAChB,kBAAc,KAAK,CAAC,gBAAgB,KAAK,CAAC;AAAA,EAC5C;AACA,MAAI,iBAAiB;AACnB,kBAAc,KAAK,CAAC,mBAAmB,KAAK,CAAC;AAAA,EAC/C;AAEA,aAAW,CAAC,MAAM,QAAQ,KAAK,eAAe;AAC5C,WAAO,QAAQ,MAAM,QAAQ;AAAA,EAC/B;AAEA,SAAO,MAAM;AACX,eAAW,CAAC,MAAM,QAAQ,KAAK,eAAe;AAC5C,aAAO,WAAW,MAAM,QAAQ;AAAA,IAClC;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/styles.css
CHANGED
|
@@ -1458,9 +1458,8 @@ html {
|
|
|
1458
1458
|
Telegram WebView (every `var()` here falls back to prior/standard-web
|
|
1459
1459
|
behavior when the Telegram-set custom property is absent).
|
|
1460
1460
|
|
|
1461
|
-
`--tg-viewport-stable-height` is set by Telegram on `:root`
|
|
1462
|
-
|
|
1463
|
-
height (excludes Telegram's own header/bottom chrome, and — unlike the
|
|
1461
|
+
`--tg-viewport-stable-height` is set by Telegram's script on `:root` as
|
|
1462
|
+
soon as it loads, and tracks the WebView's real visible height (excludes Telegram's own header/bottom chrome, and — unlike the
|
|
1464
1463
|
plain `--tg-viewport-height` — ignores transient shrinking while the
|
|
1465
1464
|
on-screen keyboard is up). Redefining `--dsx-drawer-min-height-full` here,
|
|
1466
1465
|
after `tokens.css`, updates every full-height Drawer variant (the
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* D4gger Telegram Mini App adapter (opt-in, additive).
|
|
3
|
+
*
|
|
4
|
+
* Import AFTER the core bundle in a Mini App entry:
|
|
5
|
+
*
|
|
6
|
+
* import '@d4gger/design-system/styles.css'
|
|
7
|
+
* import '@d4gger/design-system/telegram.css'
|
|
8
|
+
*
|
|
9
|
+
* Every `var(--tg-*)` reference below falls back to standard-web behavior,
|
|
10
|
+
* so this file is a no-op outside a Telegram WebView (Telegram's script sets
|
|
11
|
+
* its `--tg-*` vars on `:root` as soon as it loads). The `qa:telegram-vars`
|
|
12
|
+
* package check enforces that invariant: each `--tg-*` reference must carry
|
|
13
|
+
* a fallback, and this file must never declare a `--tg-*` variable
|
|
14
|
+
* (Telegram owns that namespace — referenced, never declared, same
|
|
15
|
+
* relationship the package already has with `--radix-*`).
|
|
16
|
+
*
|
|
17
|
+
* Two layers, and no colours:
|
|
18
|
+
* 1. Viewport + content-safe-area bindings (`--dsx-tg-*` aliases).
|
|
19
|
+
* The stable-height and base safe-area aliases already ship in the
|
|
20
|
+
* core `globals.css` compliance layer; this file adds the stable
|
|
21
|
+
* aliases for composition plus the content-safe-area inset variant
|
|
22
|
+
* (inside Telegram's own bottom chrome).
|
|
23
|
+
* 2. A low-end motion guard for small WebViews.
|
|
24
|
+
*
|
|
25
|
+
* Telegram's palette reaches the DS through ONE path, the `./telegram`
|
|
26
|
+
* subpath's `applyTelegramThemeParams` (G-35). A CSS-only colour bridge
|
|
27
|
+
* cannot work: the theme rules re-declare every token on `<body>`, and a
|
|
28
|
+
* token cannot fall back to itself.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
:root {
|
|
32
|
+
--dsx-tg-viewport-height: var(--tg-viewport-height, 100vh);
|
|
33
|
+
--dsx-tg-viewport-stable-height: var(--tg-viewport-stable-height, 100vh);
|
|
34
|
+
--dsx-tg-content-safe-area-inset-top: var(
|
|
35
|
+
--tg-content-safe-area-inset-top,
|
|
36
|
+
var(--dsx-safe-area-inset-top, env(safe-area-inset-top, 0px))
|
|
37
|
+
);
|
|
38
|
+
--dsx-tg-content-safe-area-inset-right: var(
|
|
39
|
+
--tg-content-safe-area-inset-right,
|
|
40
|
+
var(--dsx-safe-area-inset-right, env(safe-area-inset-right, 0px))
|
|
41
|
+
);
|
|
42
|
+
--dsx-tg-content-safe-area-inset-bottom: var(
|
|
43
|
+
--tg-content-safe-area-inset-bottom,
|
|
44
|
+
var(--dsx-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))
|
|
45
|
+
);
|
|
46
|
+
--dsx-tg-content-safe-area-inset-left: var(
|
|
47
|
+
--tg-content-safe-area-inset-left,
|
|
48
|
+
var(--dsx-safe-area-inset-left, env(safe-area-inset-left, 0px))
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Low-end motion guard for small WebViews. The OS-level
|
|
53
|
+
* `prefers-reduced-motion` signal is already honored globally by
|
|
54
|
+
* `motion.css` / `brand-effects.css` themselves; what they lack is an
|
|
55
|
+
* app-set kill-switch for low-end Android WebViews where the OS signal
|
|
56
|
+
* never fires. Setting `data-tg-motion="reduced"` on the Mini App root
|
|
57
|
+
* (the app decides, e.g. via `navigator.hardwareConcurrency` /
|
|
58
|
+
* device-memory heuristics) applies the same treatment motion.css uses,
|
|
59
|
+
* mirrored class-for-class: entrances resolve to their resting state,
|
|
60
|
+
* continuous loops go static, ember motes hide, and collapse skips its
|
|
61
|
+
* transition without cancelling the exit it animates.
|
|
62
|
+
* 60fps guidance for Mini Apps: keep this marker available, avoid
|
|
63
|
+
* `brand-effects.css` inside the WebView, and keep per-frame work (orbit
|
|
64
|
+
* satellites, scan sweeps, starfields) off small screens. */
|
|
65
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-fade,
|
|
66
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-converge,
|
|
67
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-rift,
|
|
68
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-stagger > *,
|
|
69
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-orbit,
|
|
70
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-pulse,
|
|
71
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-scan,
|
|
72
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-glow,
|
|
73
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-drift,
|
|
74
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-starfield::before,
|
|
75
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-aurora::after,
|
|
76
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-twinkle,
|
|
77
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-brand-ambient,
|
|
78
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-brand-starfield,
|
|
79
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-brand-shimmer {
|
|
80
|
+
animation: none;
|
|
81
|
+
opacity: 1;
|
|
82
|
+
filter: none;
|
|
83
|
+
transform: none;
|
|
84
|
+
clip-path: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-collapse {
|
|
88
|
+
animation: none;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[data-tg-mini-app][data-tg-motion='reduced'] .dsx-motion-ember__mote {
|
|
92
|
+
display: none;
|
|
93
|
+
}
|