-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move theme-toggle styles into external css (#5)
- fixes not allowed `<style>` attribute within body
- Loading branch information
Showing
3 changed files
with
140 additions
and
137 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[params] | ||
custom_css = ["css/theme-toggle.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
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,138 @@ | ||
/* | ||
Theme toggle styles | ||
*/ | ||
.dark-mode__switch { | ||
display: flex; | ||
position: relative; | ||
} | ||
.dark-mode__input { | ||
clip: rect(1px, 1px, 1px, 1px); | ||
clip-path: inset(50%); | ||
height: 1px; | ||
width: 1px; | ||
margin: -1px; | ||
overflow: hidden; | ||
padding: 0; | ||
position: absolute; | ||
} | ||
.dark-mode__label { | ||
position: relative; | ||
display: inline-block; | ||
width: 44px; | ||
height: 22px; | ||
margin: 16px 0 0; | ||
background-color: #2b2b2b; | ||
border: 2px solid #5b5b5b; | ||
border-radius: 50px; | ||
cursor: pointer; | ||
transition: all 0.4s cubic-bezier(0.46, 0.03, 0.52, 0.96); | ||
} | ||
.dark-mode__indicator { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%) translateX(-72%); | ||
display: block; | ||
width: 15px; | ||
height: 15px; | ||
background-color: #7b7b7b; | ||
border-radius: 50px; | ||
box-shadow: 5px 0px 0 0 rgba(0, 0, 0, 0.2) inset; | ||
} | ||
.dark-mode__indicator::before, .dark-mode__indicator::after { | ||
position: absolute; | ||
content: ""; | ||
display: block; | ||
background-color: #fff; | ||
border-radius: 9999px; | ||
} | ||
.dark-mode__indicator::before { | ||
top: 3.5px; | ||
left: 3.5px; | ||
width: 4.5px; | ||
height: 4.5px; | ||
background-color: #fff; | ||
opacity: 0.6; | ||
} | ||
.dark-mode__indicator::after { | ||
bottom: 4px; | ||
right: 3px; | ||
width: 6px; | ||
height: 6px; | ||
background-color: #fff; | ||
opacity: 0.8; | ||
} | ||
.dark-mode__indicator, .dark-mode__indicator::before, .dark-mode__indicator::after { | ||
transition: all 0.4s cubic-bezier(0.46, 0.03, 0.52, 0.96); | ||
} | ||
.dark-mode__decoration { | ||
position: absolute; | ||
top: 65%; | ||
left: 50%; | ||
display: block; | ||
width: 2px; | ||
height: 2px; | ||
background-color: #fff; | ||
border-radius: 50px; | ||
opacity: .3; | ||
} | ||
.dark-mode__decoration::before, .dark-mode__decoration::after { | ||
position: absolute; | ||
display: block; | ||
content: ''; | ||
width: 2px; | ||
height: 2px; | ||
background-color: #fff; | ||
border-radius: 50px; | ||
} | ||
.dark-mode__decoration::before { | ||
top: -8px; | ||
left: 7px; | ||
opacity: 1; | ||
} | ||
.dark-mode__decoration::after { | ||
top: -3px; | ||
left: 15px; | ||
opacity: .2; | ||
} | ||
.dark-mode__input:checked + .dark-mode__label { | ||
background-color: #8fb5f5; | ||
border-color: #347cf8; | ||
} | ||
.dark-mode__input:checked + .dark-mode__label .dark-mode__indicator { | ||
background-color: #ecd21f; | ||
box-shadow: none; | ||
transform: translate(-50%, -50%) translateX(72%); | ||
} | ||
.dark-mode__input:checked + .dark-mode__label .dark-mode__indicator::before, .dark-mode__input:checked + .dark-mode__label .dark-mode__indicator::after { | ||
display: none; | ||
} | ||
.dark-mode__input:checked + .dark-mode__label .dark-mode__decoration { | ||
top: 50%; | ||
transform: translate(0%, -50%); | ||
width: 10px; | ||
height: 10px; | ||
opacity: 1; | ||
} | ||
.dark-mode__input:checked + .dark-mode__label .dark-mode__decoration::before { | ||
width: 5px; | ||
height: 5px; | ||
top: auto; | ||
bottom: 0; | ||
left: -4px; | ||
opacity: 1; | ||
} | ||
.dark-mode__input:checked + .dark-mode__label .dark-mode__decoration::after { | ||
width: 7px; | ||
height: 7px; | ||
top: auto; | ||
bottom: 0; | ||
left: 8px; | ||
opacity: 1; | ||
} | ||
.dark-mode__input:checked + .dark-mode__label .dark-mode__decoration, .dark-mode__input:checked + .dark-mode__label .dark-mode__decoration::before, .dark-mode__input:checked + .dark-mode__label .dark-mode__decoration::after { | ||
border-radius: 50px 50px 0 0; | ||
} | ||
.dark-mode__input:checked + .dark-mode__label .dark-mode__decoration::after { | ||
border-bottom-right-radius: 50px; | ||
} |