Polish BIM share modal controls
This commit is contained in:
+32
-2
@@ -36,6 +36,34 @@
|
||||
if (!Object.keys(s).length) return;
|
||||
const root = document.documentElement;
|
||||
const set = (k, v) => v !== undefined && root.style.setProperty(k, v);
|
||||
const parseColor = (value) => {
|
||||
if (typeof value !== "string") return null;
|
||||
const color = value.trim();
|
||||
const hex = color.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
|
||||
if (hex) {
|
||||
const raw = hex[1].length === 3
|
||||
? hex[1].split("").map((c) => c + c).join("")
|
||||
: hex[1];
|
||||
return [
|
||||
parseInt(raw.slice(0, 2), 16),
|
||||
parseInt(raw.slice(2, 4), 16),
|
||||
parseInt(raw.slice(4, 6), 16),
|
||||
];
|
||||
}
|
||||
const rgb = color.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);
|
||||
if (!rgb) return null;
|
||||
return rgb.slice(1, 4).map((channel) => Math.max(0, Math.min(255, Number(channel))));
|
||||
};
|
||||
const readableTextColor = (value) => {
|
||||
const rgb = parseColor(value);
|
||||
if (!rgb || rgb.some((channel) => !Number.isFinite(channel))) return "#15170f";
|
||||
const toLinear = (channel) => {
|
||||
const value = channel / 255;
|
||||
return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
||||
};
|
||||
const lum = 0.2126 * toLinear(rgb[0]) + 0.7152 * toLinear(rgb[1]) + 0.0722 * toLinear(rgb[2]);
|
||||
return (lum + 0.05) / 0.05 >= 1.05 / (lum + 0.05) ? "#15170f" : "#f5f5fa";
|
||||
};
|
||||
set("--bg-outer", s.bgOuter);
|
||||
set("--canvas-top", s.canvasTop);
|
||||
set("--canvas-bottom", s.canvasBottom);
|
||||
@@ -49,6 +77,7 @@
|
||||
set("--template-glow-strength", `${s.templateGlow}%`);
|
||||
set("--toolbar-bg", s.toolbarBg);
|
||||
set("--toolbar-bg-active", s.toolbarBgActive);
|
||||
set("--toolbar-bg-active-contrast", s.toolbarBgActive ? readableTextColor(s.toolbarBgActive) : undefined);
|
||||
set("--toolbar-border", s.toolbarBorder);
|
||||
set("--toolbar-outline", s.toolbarOutline);
|
||||
set("--modal-bg", s.modalBg);
|
||||
@@ -63,6 +92,7 @@
|
||||
set("--project-btn-border", s.projectBtnBorder);
|
||||
set("--project-btn-hover", s.projectBtnHover);
|
||||
set("--modal-btn-primary", s.modalBtnPrimary);
|
||||
set("--modal-btn-primary-contrast", s.modalBtnPrimary ? readableTextColor(s.modalBtnPrimary) : undefined);
|
||||
set("--modal-btn-secondary", s.modalBtnSecondary);
|
||||
set("--loader-color", s.loaderColor);
|
||||
set("--border", s.border);
|
||||
@@ -98,7 +128,7 @@
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="./dcViewer.css?v=21">
|
||||
<link rel="stylesheet" href="./dcViewer.css?v=22">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
@@ -369,6 +399,6 @@
|
||||
<input id="fileInput" class="hidden" type="file"
|
||||
accept=".xkt,.glb,.gltf,.bim,.las,.laz,.obj,.stl">
|
||||
|
||||
<script type="module" src="./dcViewer.js?v=25"></script>
|
||||
<script type="module" src="./dcViewer.js?v=26"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user