-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
704bea9
commit 7b32255
Showing
19 changed files
with
478 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/cases/multiple-themes-async-loading-with-default-light/expected/dark.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
background-color: black; | ||
} |
3 changes: 3 additions & 0 deletions
3
test/cases/multiple-themes-async-loading-with-default-light/expected/main.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
background-color: white; | ||
} |
12 changes: 12 additions & 0 deletions
12
test/cases/multiple-themes-async-loading-with-default-light/public/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Document</title> | ||
<link id="theme" rel="stylesheet" type="text/css" href="./main.css"> | ||
</head> | ||
<body> | ||
<script src="./main.js"></script> | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
test/cases/multiple-themes-async-loading-with-default-light/src/dark-theme/_vars.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$background: black; |
50 changes: 50 additions & 0 deletions
50
test/cases/multiple-themes-async-loading-with-default-light/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* eslint-env browser */ | ||
import "./style.scss"; | ||
|
||
let theme = "light"; | ||
const themes = {}; | ||
|
||
themes[theme] = document.querySelector("#theme"); | ||
|
||
async function loadTheme(newTheme) { | ||
// eslint-disable-next-line no-console | ||
console.log(`CHANGE THEME - ${newTheme}`); | ||
|
||
const themeElement = document.querySelector("#theme"); | ||
|
||
if (themeElement) { | ||
themeElement.remove(); | ||
} | ||
|
||
if (themes[newTheme]) { | ||
// eslint-disable-next-line no-console | ||
console.log(`THEME ALREADY LOADED - ${newTheme}`); | ||
|
||
document.head.appendChild(themes[newTheme]); | ||
|
||
return; | ||
} | ||
|
||
if (newTheme === "dark") { | ||
// eslint-disable-next-line no-console | ||
console.log(`LOADING THEME - ${newTheme}`); | ||
|
||
// eslint-disable-next-line import/no-unresolved | ||
import(/* webpackChunkName: "dark" */ "./style.scss?dark").then(() => { | ||
themes[newTheme] = document.querySelector("#theme"); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(`LOADED - ${newTheme}`); | ||
}); | ||
} | ||
} | ||
|
||
document.onclick = () => { | ||
if (theme === "light") { | ||
theme = "dark"; | ||
} else { | ||
theme = "light"; | ||
} | ||
|
||
loadTheme(theme); | ||
}; |
1 change: 1 addition & 0 deletions
1
test/cases/multiple-themes-async-loading-with-default-light/src/light-theme/_vars.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$background: white; |
3 changes: 3 additions & 0 deletions
3
test/cases/multiple-themes-async-loading-with-default-light/src/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
background-color: vars.$background; | ||
} |
Oops, something went wrong.