Skip to content

Commit 5cbe097

Browse files
authored
fix: skeleton with color having opacity (codesandbox#3873)
1 parent 0b04cc6 commit 5cbe097

File tree

1 file changed

+10
-1
lines changed
  • packages/app/src/app/pages/Sandbox/Editor/Skeleton

1 file changed

+10
-1
lines changed

packages/app/src/app/pages/Sandbox/Editor/Skeleton/elements.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const pulse = keyframes`
77
`;
88

99
export const SkeletonTextBlock = styled.div(props => {
10-
const color = props.theme.colors?.sideBar.border || '#242424';
10+
let color = props.theme.colors?.sideBar.border || '#242424';
1111
const themeType = props.theme.vscodeTheme.type;
1212

1313
/**
@@ -23,7 +23,16 @@ export const SkeletonTextBlock = styled.div(props => {
2323
const backgroundLuminosity = themeType === 'light' ? 86 : 14;
2424
const highlightLuminosity = themeType === 'light' ? 88 : 16;
2525

26+
// Color('#ff000033') throws error.
27+
const colorWithOpacity = color.length === 9;
28+
29+
if (colorWithOpacity) {
30+
// remove the opacity
31+
color = color.slice(0, -2);
32+
}
33+
2634
const hsl = Color(color).hsl();
35+
2736
const background = Color({ ...hsl, l: backgroundLuminosity }).hslString();
2837
const highlight = Color({ ...hsl, l: highlightLuminosity }).hslString();
2938

0 commit comments

Comments
 (0)