@markdy/renderer-dom 0.5.6 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -540,6 +540,7 @@ function buildAction(ev, el, s, baseOpts, delayMs, durMs, ast, states, scene, as
|
|
|
540
540
|
transformOrigin: "center bottom",
|
|
541
541
|
background: "white",
|
|
542
542
|
border: "2px solid #222",
|
|
543
|
+
color: "#222",
|
|
543
544
|
borderRadius: "12px",
|
|
544
545
|
padding: "6px 14px",
|
|
545
546
|
fontFamily: "system-ui, sans-serif",
|
|
@@ -636,6 +637,22 @@ function buildAction(ev, el, s, baseOpts, delayMs, durMs, ast, states, scene, as
|
|
|
636
637
|
}
|
|
637
638
|
|
|
638
639
|
// src/player.ts
|
|
640
|
+
function bgToTextColor(bg) {
|
|
641
|
+
let hex = bg.trim().replace(/^#/, "");
|
|
642
|
+
if (hex.length === 3) hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
643
|
+
if (hex.length === 6) {
|
|
644
|
+
const r = parseInt(hex.slice(0, 2), 16);
|
|
645
|
+
const g = parseInt(hex.slice(2, 4), 16);
|
|
646
|
+
const b = parseInt(hex.slice(4, 6), 16);
|
|
647
|
+
return 0.299 * r + 0.587 * g + 0.114 * b > 140 ? "#1a1a1a" : "#f0f0f0";
|
|
648
|
+
}
|
|
649
|
+
const named = {
|
|
650
|
+
white: "#1a1a1a",
|
|
651
|
+
black: "#f0f0f0",
|
|
652
|
+
transparent: "#1a1a1a"
|
|
653
|
+
};
|
|
654
|
+
return named[bg.toLowerCase()] ?? "#1a1a1a";
|
|
655
|
+
}
|
|
639
656
|
function createPlayer(opts) {
|
|
640
657
|
const { container, code, assets: assetOverrides = {}, autoplay = true, loop = true, copyright = true, progressBar = true } = opts;
|
|
641
658
|
const ast = parse(code);
|
|
@@ -712,6 +729,7 @@ function createPlayer(opts) {
|
|
|
712
729
|
width: `${ast.meta.width}px`,
|
|
713
730
|
height: `${ast.meta.height}px`,
|
|
714
731
|
background: ast.meta.bg,
|
|
732
|
+
color: bgToTextColor(ast.meta.bg),
|
|
715
733
|
overflow: "hidden",
|
|
716
734
|
userSelect: "none",
|
|
717
735
|
transformOrigin: "0 0"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/renderer-dom",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"description": "Web Animations API renderer for MarkdyScript scenes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@markdy/core": "0.5.
|
|
46
|
+
"@markdy/core": "0.5.8"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"tsup": "^8.5.1",
|