Skip to content

Commit 0b0a459

Browse files
committed
Restore using getComputedStyles() if style references CSS variable
1 parent f0bc1a1 commit 0b0a459

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/layerchart/src/lib/utils/canvas.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,14 @@ function render(
8282

8383
// TODO: Consider memoizing? How about reactiving to CSS variable changes (light/dark mode toggle)
8484
let resolvedStyles: StyleOptions;
85-
if (styleOptions.classes == null) {
86-
// Skip resolving styles if no classes are provided
85+
if (
86+
styleOptions.classes == null &&
87+
!Object.values(styleOptions.styles ?? {}).some(
88+
(v) => typeof v === 'string' && v.includes('var(')
89+
)
90+
) {
91+
// Skip resolving styles if no classes are provided and no styles are using CSS variables
92+
// TODO: Convert colors using `rgb(0 0 0 / 50%)` to `rgba(0, 0, 0, 0.5)`
8793
resolvedStyles = styleOptions.styles ?? {};
8894
} else {
8995
const computedStyles = getComputedStyles(ctx.canvas, styleOptions);

0 commit comments

Comments
 (0)