Skip to content

Commit

Permalink
TEMP
Browse files Browse the repository at this point in the history
  • Loading branch information
mahozad committed Nov 17, 2023
1 parent 81d07fb commit 461dfb0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main.js
Expand Up @@ -266,6 +266,12 @@ function generateStyle() {
return `STYLES_TEMPLATE`;
}

window.CSS.registerProperty({
name: '--theme-switch-icon-color',
syntax: '<color>',
inherits: false,
initialValue: '#000',
});
updateTheme();
window.customElements.define(ELEMENT_NAME, ThemeSwitchElement);
window
Expand Down
10 changes: 10 additions & 0 deletions test/main.test.js
Expand Up @@ -335,6 +335,16 @@ describe("Screenshot tests", () => {
expect(screenshot).toMatchReferenceSnapshot();
}, 100_000);

test(`The icon color should be animatable`, async () => {
const screenshot = await takeScreenshot(() => {
localStorage.setItem("theme", "auto");
}, async (page, element) => {
await element.hover();
await page.waitForTimeout(1_000);
}, "template-8.html");
expect(screenshot).toMatchReferenceSnapshot();
}, 100_000);

// See https://stackoverflow.com/q/47107465/8583692
// and https://github.com/puppeteer/puppeteer/blob/main/examples/custom-event.js
test(`When the switch is toggled, it should trigger a "themeToggle" event`, async () => {
Expand Down
28 changes: 28 additions & 0 deletions test/template-8.html
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Theme switch test 8</title>
<style>
@keyframes anim {
0% { --theme-switch-icon-color: #000; }
100% { --theme-switch-icon-color: #f00; }
}
theme-switch {
width: 64px;
height: 64px;
--theme-switch-icon-color: #000;
transition: --theme-switch-icon-color 2s linear;
}
theme-switch:hover {
--theme-switch-icon-color: #f00;
}
</style>
<script src="../dist/theme-switch.js"></script>
</head>
<body>

<theme-switch></theme-switch>

</body>
</html>

0 comments on commit 461dfb0

Please sign in to comment.