Unverified Commit 3d9aef2b authored by Mehmet Sağır's avatar Mehmet Sağır Committed by GitHub
Browse files

Dark Mode (#1217)

* corrections were made

* added dark-mode

* back-to-top-button added

* back-to-top button edited

* back-to-top button edited

* last edit

* last edit

* arrangements were made

* dark-mode-button-updated

* dark-mode-option-added
parent 45e58371
......@@ -60,6 +60,20 @@
</section>
<section class="animation-list">
<label for="night-light-checkbox" class="night-light-label">
<input type="checkbox" id="night-light-checkbox" />
<span class="night-light-ball"></span>
<svg viewBox="0 0 512 512" class="sun-svg">
<path id="sun-svg"
d="M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z">
</path>
</svg>
<svg viewBox="0 0 512 512" class="moon-svg">
<path id="moon-svg"
d="M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z">
</path>
</svg>
</label>
<button class="callout-hideList button">Close list</button>
<section class="attention_seekers" id="attention_seekers">
......
......@@ -2,9 +2,11 @@ import buildDocsIndex from './modules/buildDocsIndex.mjs';
import playground from './modules/playground.mjs';
import startAnimations from './modules/startAnimations.mjs';
import toggleOnClick from './modules/toggle.mjs';
import darkModeControl from './modules/darkMode.mjs';
buildDocsIndex();
playground();
darkModeControl();
toggleOnClick('.callout-showList', 'html', 'animationList-active');
toggleOnClick('.callout-hideList', 'html', 'animationList-active');
......@@ -14,12 +16,12 @@ toggleOnClick('.docs-index', 'html', 'hamburger-active');
requestAnimationFrame(startAnimations);
document.querySelectorAll('.copy-icon').forEach(icon => {
icon.addEventListener('click', () => {
icon.classList.add('copied');
document.querySelector('.copied .tooltip').textContent = "Copied!";
setTimeout(() => {
icon.children[0].textContent = "Copy class name to clipboard"
icon.classList.remove('copied')
}, 750)
})
icon.addEventListener('click', () => {
icon.classList.add('copied');
document.querySelector('.copied .tooltip').textContent = 'Copied!';
setTimeout(() => {
icon.children[0].textContent = 'Copy class name to clipboard'
icon.classList.remove('copied')
}, 750)
})
})
const darkModeControl = () => {
const darkCheck = document.getElementById('night-light-checkbox');
darkCheck.addEventListener('click', () => {
if (darkCheck.checked) {
document.body.classList.add('dark');
localStorage.setItem('animate-css', 'dark');
} else {
document.body.classList.remove('dark');
localStorage.removeItem('animate-css');
}
})
if (localStorage.getItem('animate-css')) {
document.body.className = 'dark';
darkCheck.checked = true;
}
}
export default darkModeControl;
\ No newline at end of file
......@@ -616,3 +616,114 @@ blockquote {
.animation-list {
text-align: left;
}
/*-----------------------------------*\
$DARK-MODE
\*-----------------------------------*/
.night-light-label #night-light-checkbox {
position: absolute;
visibility: hidden;
}
.night-light-label {
display: block;
margin: 20px 0;
height: 31px;
width: 60px;
border: 2px solid #4672fe;
border-radius: 30px;
position: relative;
cursor: pointer;
}
.night-light-label .night-light-ball {
position: absolute;
width: 25px;
height: 25px;
top: 1px;
left: 1px;
border-radius: 50%;
background: #4672fe;
z-index: 99;
transition: 300ms;
}
.night-light-label #night-light-checkbox:checked + .night-light-ball {
transform: translateX(28px);
}
.moon-svg,
.sun-svg {
width: 16px;
height: 16px;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.moon-svg {
right: 5px;
}
.sun-svg {
left: 5px;
}
.dark #moon-svg,
.dark #sun-svg {
fill: #e0e0e0 !important;
}
.dark {
background-color: #111;
color: #e0e0e0;
}
.dark .intro {
background: #111;
}
.dark .animation-list,
.dark .sidebar {
background: #15151D;
}
.dark .button.button-animations,
.dark .callout-hideList.button {
color: #e0e0e0;
border-color: rgba(255, 255, 255, .7);
outline: none;
}
.dark .copy-icon,
.dark .copy-icon:hover {
background: #15151D;
border-color: #e0e0e0;
}
.dark .copy-icon::before,
.dark .copy-icon:hover::before {
border-color: #e0e0e0;
}
.dark code {
color: #111;
}
.dark h2,
.dark h3,
.dark h4,
.dark a[title="Documentation"],
.dark pre * {
color: #e0e0e0;
}
.dark section {
border-color: rgba(255, 255, 255, .2);
}
.dark h1,
.dark a {
color: #4672fe;
}
\ No newline at end of file
......@@ -23,3 +23,4 @@ fs.writeFile(output, withVersion, 'utf8', (err) => {
if (err) console.error(err);
console.log('Template compiled succesfully.');
});
......@@ -60,6 +60,20 @@
</section>
<section class="animation-list">
<label for="night-light-checkbox" class="night-light-label">
<input type="checkbox" id="night-light-checkbox" />
<span class="night-light-ball"></span>
<svg viewBox="0 0 512 512" class="sun-svg">
<path id="sun-svg"
d="M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z">
</path>
</svg>
<svg viewBox="0 0 512 512" class="moon-svg">
<path id="moon-svg"
d="M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z">
</path>
</svg>
</label>
<button class="callout-hideList button">Close list</button>
{{list}}
</section>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment