feat(08-03): 将产物预览内联样式变量令牌化
- 将产物预览 srcdoc 内联样式中的十六进制颜色值替换为工作区主题令牌变量 - 在 globals 和工作区主题令牌注册表中注册缺失的工作区主题令牌,以支持亮色/暗色主题
This commit is contained in:
parent
3d4e180a05
commit
fc27d179d4
|
|
@ -1559,13 +1559,36 @@ function buildArtifactViewerSrcDoc({
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
--bg: #f8f9fb;
|
--ws-color-f8f9fb: rgb(248 249 251);
|
||||||
--panel: #ffffff;
|
--ws-color-ffffff: rgb(255 255 255);
|
||||||
--text: #0f172a;
|
--ws-color-0f172a: rgb(15 23 42);
|
||||||
--muted: #667085;
|
--ws-color-667085: rgb(102 112 133);
|
||||||
--line: #e4e7ec;
|
--ws-color-e4e7ec: rgb(228 231 236);
|
||||||
|
--ws-color-f4f4f5: rgb(244 244 245);
|
||||||
|
--ws-color-000000: rgb(0 0 0);
|
||||||
|
--ws-color-2563eb: rgb(37 99 235);
|
||||||
|
--bg: var(--ws-color-f8f9fb);
|
||||||
|
--panel: var(--ws-color-ffffff);
|
||||||
|
--text: var(--ws-color-0f172a);
|
||||||
|
--muted: var(--ws-color-667085);
|
||||||
|
--line: var(--ws-color-e4e7ec);
|
||||||
|
--checker: var(--ws-color-f4f4f5);
|
||||||
|
--media-bg: var(--ws-color-000000);
|
||||||
|
--link: var(--ws-color-2563eb);
|
||||||
--radius: 12px;
|
--radius: 12px;
|
||||||
}
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--ws-color-f8f9fb: rgb(32 36 44);
|
||||||
|
--ws-color-ffffff: rgb(42 39 49);
|
||||||
|
--ws-color-0f172a: rgb(230 234 242);
|
||||||
|
--ws-color-667085: rgb(152 162 179);
|
||||||
|
--ws-color-e4e7ec: rgb(58 61 69);
|
||||||
|
--ws-color-f4f4f5: rgb(44 47 56);
|
||||||
|
--ws-color-000000: rgb(0 0 0);
|
||||||
|
--ws-color-2563eb: rgb(127 178 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
* { box-sizing: border-box; }
|
* { box-sizing: border-box; }
|
||||||
html, body {
|
html, body {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
@ -1599,13 +1622,13 @@ function buildArtifactViewerSrcDoc({
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
object-position: center;
|
object-position: center;
|
||||||
background:
|
background:
|
||||||
linear-gradient(45deg, #f4f4f5 25%, transparent 25%, transparent 75%, #f4f4f5 75%, #f4f4f5) 0 0/16px 16px,
|
linear-gradient(45deg, var(--checker) 25%, transparent 25%, transparent 75%, var(--checker) 75%, var(--checker)) 0 0/16px 16px,
|
||||||
linear-gradient(45deg, #f4f4f5 25%, transparent 25%, transparent 75%, #f4f4f5 75%, #f4f4f5) 8px 8px/16px 16px,
|
linear-gradient(45deg, var(--checker) 25%, transparent 25%, transparent 75%, var(--checker) 75%, var(--checker)) 8px 8px/16px 16px,
|
||||||
#fff;
|
var(--panel);
|
||||||
}
|
}
|
||||||
.media {
|
.media {
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
background: #000;
|
background: var(--media-bg);
|
||||||
}
|
}
|
||||||
.frame {
|
.frame {
|
||||||
border: 1px solid var(--line);
|
border: 1px solid var(--line);
|
||||||
|
|
@ -1648,7 +1671,7 @@ function buildArtifactViewerSrcDoc({
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
}
|
}
|
||||||
.link {
|
.link {
|
||||||
color: #2563eb;
|
color: var(--link);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,12 @@
|
||||||
--color-ws-000000c5: var(--ws-color-000000c5);
|
--color-ws-000000c5: var(--ws-color-000000c5);
|
||||||
--color-ws-00000015: var(--ws-color-00000015);
|
--color-ws-00000015: var(--ws-color-00000015);
|
||||||
--color-ws-1500331a: var(--ws-color-1500331a);
|
--color-ws-1500331a: var(--ws-color-1500331a);
|
||||||
|
--color-ws-f8f9fb: var(--ws-color-f8f9fb);
|
||||||
|
--color-ws-ffffff: var(--ws-color-ffffff);
|
||||||
|
--color-ws-0f172a: var(--ws-color-0f172a);
|
||||||
|
--color-ws-f4f4f5: var(--ws-color-f4f4f5);
|
||||||
|
--color-ws-000000: var(--ws-color-000000);
|
||||||
|
--color-ws-2563eb: var(--ws-color-2563eb);
|
||||||
--animate-aurora: aurora 8s ease-in-out infinite alternate;
|
--animate-aurora: aurora 8s ease-in-out infinite alternate;
|
||||||
|
|
||||||
@keyframes aurora {
|
@keyframes aurora {
|
||||||
|
|
@ -313,6 +319,12 @@
|
||||||
--ws-color-000000c5: #000000c5;
|
--ws-color-000000c5: #000000c5;
|
||||||
--ws-color-00000015: #00000015;
|
--ws-color-00000015: #00000015;
|
||||||
--ws-color-1500331a: #1500331a;
|
--ws-color-1500331a: #1500331a;
|
||||||
|
--ws-color-f8f9fb: #f8f9fb;
|
||||||
|
--ws-color-ffffff: #ffffff;
|
||||||
|
--ws-color-0f172a: #0f172a;
|
||||||
|
--ws-color-f4f4f5: #f4f4f5;
|
||||||
|
--ws-color-000000: #000000;
|
||||||
|
--ws-color-2563eb: #2563eb;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark {
|
.dark {
|
||||||
|
|
@ -360,6 +372,12 @@
|
||||||
--ws-color-000000c5: #ffffffcc;
|
--ws-color-000000c5: #ffffffcc;
|
||||||
--ws-color-00000015: #ffffff1f;
|
--ws-color-00000015: #ffffff1f;
|
||||||
--ws-color-1500331a: #f4ebff24;
|
--ws-color-1500331a: #f4ebff24;
|
||||||
|
--ws-color-f8f9fb: #20242c;
|
||||||
|
--ws-color-ffffff: #2a2731;
|
||||||
|
--ws-color-0f172a: #e6eaf2;
|
||||||
|
--ws-color-f4f4f5: #2c2f38;
|
||||||
|
--ws-color-000000: #000000;
|
||||||
|
--ws-color-2563eb: #7fb2ff;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,4 +16,10 @@ export const WORKSPACE_COLOR_TOKENS = {
|
||||||
"ws-000000c5": { light: "#000000c5", dark: "#ffffffcc" },
|
"ws-000000c5": { light: "#000000c5", dark: "#ffffffcc" },
|
||||||
"ws-00000015": { light: "#00000015", dark: "#ffffff1f" },
|
"ws-00000015": { light: "#00000015", dark: "#ffffff1f" },
|
||||||
"ws-1500331a": { light: "#1500331a", dark: "#f4ebff24" },
|
"ws-1500331a": { light: "#1500331a", dark: "#f4ebff24" },
|
||||||
|
"ws-f8f9fb": { light: "#f8f9fb", dark: "#20242c" },
|
||||||
|
"ws-ffffff": { light: "#ffffff", dark: "#2a2731" },
|
||||||
|
"ws-0f172a": { light: "#0f172a", dark: "#e6eaf2" },
|
||||||
|
"ws-f4f4f5": { light: "#f4f4f5", dark: "#2c2f38" },
|
||||||
|
"ws-000000": { light: "#000000", dark: "#000000" },
|
||||||
|
"ws-2563eb": { light: "#2563eb", dark: "#7fb2ff" },
|
||||||
} as const satisfies Record<string, WorkspaceColorToken>;
|
} as const satisfies Record<string, WorkspaceColorToken>;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue