-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
8 changed files
with
313 additions
and
12 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
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,37 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Darkmode example</title> | ||
<style> | ||
/* Styles for light theme */ | ||
.theme-light { | ||
background: #fff; | ||
color: #000; | ||
} | ||
|
||
/* Styles for dark theme */ | ||
.theme-dark { | ||
background: #000; | ||
color: #fff; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>Darkmode example</h1> | ||
</body> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/drkmd-js/dist/drkmd-js.min.js" data-drkmd-attach ></script> | ||
|
||
<!-- or --> | ||
|
||
<!-- | ||
<script> | ||
import Darkmode from 'drkmd-js' | ||
new Darkmode().attach() | ||
</script> | ||
--> | ||
</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,43 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Darkmode example</title> | ||
<style> | ||
/* Light Colors*/ | ||
.theme-light { | ||
--background: #fff; | ||
--color: #000; | ||
} | ||
|
||
/* Dark Colors */ | ||
.theme-dark { | ||
--background: #000; | ||
--color: #fff; | ||
} | ||
|
||
html, | ||
body { | ||
background: var(--background); | ||
color: var(--color); | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>Darkmode example</h1> | ||
</body> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/drkmd-js/dist/drkmd-js.min.js" data-drkmd-attach ></script> | ||
|
||
<!-- or --> | ||
|
||
<!-- | ||
<script> | ||
import Darkmode from 'drkmd-js' | ||
new Darkmode().attach() | ||
</script> | ||
--> | ||
</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,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Darkmode example</title> | ||
<style> | ||
/* Light Colors*/ | ||
.theme-light { | ||
--background: #fff; | ||
--color: #000; | ||
} | ||
|
||
/* Dark Colors */ | ||
.theme-dark { | ||
--background: #000; | ||
--color: #fff; | ||
} | ||
|
||
html, | ||
body { | ||
background: var(--background); | ||
color: var(--color); | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>Darkmode example</h1> | ||
<span data-drkmd-toggle>Switch theme</span> | ||
|
||
<span data-drkmd-to-light>Light theme</span> | ||
<span data-drkmd-to-dark>Dark theme</span> | ||
</body> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/drkmd-js/dist/drkmd-js.min.js" ></script> | ||
|
||
<!-- or --> | ||
|
||
<!-- | ||
<script> | ||
import Darkmode from 'drkmd-js' | ||
</script> | ||
--> | ||
</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,56 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Darkmode example</title> | ||
<style> | ||
/* Light Colors*/ | ||
.theme-light { | ||
--background: #fff; | ||
--color: #000; | ||
} | ||
|
||
/* Dark Colors */ | ||
.theme-dark { | ||
--background: #000; | ||
--color: #fff; | ||
} | ||
|
||
html, | ||
body { | ||
background: var(--background); | ||
color: var(--color); | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>Darkmode example</h1> | ||
</body> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/drkmd-js/dist/drkmd-js.min.js" data-drkmd-attach ></script> | ||
|
||
<!-- or --> | ||
|
||
<!-- | ||
<script> | ||
import Darkmode from 'drkmd-js' | ||
new Darkmode().attach() | ||
</script> | ||
--> | ||
|
||
<script> | ||
const imageSrc = { | ||
dark: "/path/to/dark.png", | ||
light: "/path/to/light.png" | ||
} | ||
|
||
window.addEventListener('theme-change', e => { | ||
const theme = e.detail.to // will return 'light' or 'dark' | ||
document.getElementById('image').src = imageSrc[theme] | ||
}) | ||
</script> | ||
|
||
</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,50 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Darkmode example</title> | ||
<style> | ||
/* Light Colors*/ | ||
.theme-light { | ||
--background: #fff; | ||
--color: #000; | ||
} | ||
|
||
/* Dark Colors */ | ||
.theme-dark { | ||
--background: #000; | ||
--color: #fff; | ||
} | ||
|
||
html, | ||
body { | ||
background: var(--background); | ||
color: var(--color); | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>Darkmode example</h1> | ||
</body> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/drkmd-js/dist/drkmd-js.min.js" data-drkmd-opts='{ "cookie": true, "defaultTheme": "dark", "attach": true }' ></script> | ||
|
||
<!-- or --> | ||
|
||
<!-- | ||
<script> | ||
import Darkmode from 'drkmd-js' | ||
const options = { | ||
cookie: true, | ||
defaultTheme: 'dark', | ||
attach: true | ||
} | ||
const darkmode = new Darkmode(options) | ||
</script> | ||
--> | ||
</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,65 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Darkmode example</title> | ||
<style> | ||
/* Light Colors*/ | ||
.theme-light { | ||
--background: #fff; | ||
--color: #000; | ||
} | ||
|
||
/* Dark Colors */ | ||
.theme-dark { | ||
--background: #000; | ||
--color: #fff; | ||
} | ||
|
||
html, | ||
body { | ||
background: var(--background); | ||
color: var(--color); | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>Darkmode example</h1> | ||
<button id="myBtn">Click me</button> | ||
<span id="theme"></span> | ||
</body> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/drkmd-js/dist/drkmd-js.min.js" ></script> | ||
|
||
<!-- or --> | ||
|
||
<!-- | ||
<script> | ||
import Darkmode from 'drkmd-js' | ||
</script> | ||
--> | ||
|
||
<script> | ||
const darkmode = new Darkmode() | ||
|
||
const updateValue = () => { | ||
document.getElementById('theme').value = `Current theme: ${ darkmode.currentTheme() }` | ||
} | ||
|
||
document.getElementById('myBtn').addEventListener('click', () => { | ||
if (darkmode.isDark()) { | ||
// Do something | ||
} | ||
|
||
darkmode.toggle() | ||
|
||
updateValue() | ||
}) | ||
|
||
updateValue() | ||
</script> | ||
|
||
</html> |
File renamed without changes.