-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5022 from codeEmpress1/theme-switch-in-examples
Theme switch in examples
- Loading branch information
Showing
21 changed files
with
142 additions
and
49 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,39 @@ | ||
@import 'settings'; | ||
|
||
@mixin vf-u-theme-toggle { | ||
.u-theme-toggle { | ||
bottom: $spv--x-large; | ||
position: fixed; | ||
right: $sp-unit * 30; | ||
z-index: 100; | ||
|
||
.u-theme-toggle__button { | ||
margin: 0; | ||
|
||
&:not(:last-child) { | ||
border-right: 0; | ||
} | ||
} | ||
|
||
.u-theme-toggle__dark { | ||
background-color: $colors--dark-theme--background-default; | ||
color: $colors--dark-theme--text-default; | ||
} | ||
|
||
.u-theme-toggle__light { | ||
background-color: $colors--light-theme--background-default; | ||
color: $colors--light-theme--text-default; | ||
} | ||
.u-theme-toggle__paper { | ||
background-color: $color-paper; | ||
color: $color-x-dark; | ||
} | ||
} | ||
|
||
// hide the theme toggle in Percy | ||
@media only percy { | ||
.u-theme-toggle { | ||
visibility: hidden !important; | ||
} | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
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,64 @@ | ||
(function () { | ||
function inIframe() { | ||
try { | ||
return window.self !== window.top; | ||
} catch (e) { | ||
return true; | ||
} | ||
} | ||
|
||
function fragmentFromString(htmlString) { | ||
var temp = document.createElement('template'); | ||
temp.innerHTML = htmlString; | ||
return temp.content; | ||
} | ||
|
||
if (!inIframe()) { | ||
document.documentElement.classList.add('u-baseline-grid'); | ||
|
||
document.addEventListener('DOMContentLoaded', function () { | ||
var body = document.body; | ||
var controls = fragmentFromString( | ||
'<div class="u-baseline-grid__toggle"><label class="p-switch"><input type="checkbox" class="p-switch__input js-baseline-toggle" /><span class="p-switch__slider"></span><span class="p-switch__label">Toggle baseline grid</span></label></div>', | ||
); | ||
var themes = fragmentFromString( | ||
'<div class="u-theme-toggle is-light"><button class="u-theme-toggle__button u-theme-toggle__dark js-dark-theme-toggle">Dark</button><button class="u-theme-toggle__button u-theme-toggle__light js-light-theme-toggle">Light</button><button class="u-theme-toggle__button u-theme-toggle__paper js-paper-theme-toggle">Paper</button></div>', | ||
); | ||
|
||
body.appendChild(themes); | ||
body.appendChild(controls); | ||
|
||
var toggle = document.querySelector('.js-baseline-toggle'); | ||
toggle.addEventListener('click', function (event) { | ||
body.classList.toggle('u-baseline-grid'); | ||
}); | ||
|
||
var themeToggles = document.querySelector('.u-theme-toggle'); | ||
|
||
if (!SHOW_THEME_SWITCH) { | ||
themeToggles.classList.add('u-hide'); | ||
} | ||
|
||
var darkTheme = document.querySelector('.js-dark-theme-toggle'); | ||
darkTheme.addEventListener('click', function (event) { | ||
body.classList.add('is-dark'); | ||
body.classList.remove('is-paper'); | ||
body.classList.remove('is-light'); | ||
}); | ||
|
||
var lightTheme = document.querySelector('.js-light-theme-toggle'); | ||
lightTheme.addEventListener('click', function (event) { | ||
body.classList.add('is-light'); | ||
body.classList.remove('is-dark'); | ||
body.classList.remove('is-paper'); | ||
}); | ||
|
||
var paperTheme = document.querySelector('.js-paper-theme-toggle'); | ||
paperTheme.addEventListener('click', function (event) { | ||
body.classList.add('is-paper'); | ||
body.classList.remove('is-dark'); | ||
body.classList.remove('is-light'); | ||
}); | ||
}); | ||
} | ||
})(); |