mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-15 09:35:21 +01:00
move theme switch to header, simplify
This commit is contained in:
parent
8f3429927d
commit
e0585386fb
@ -58,9 +58,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.hamburgerButton {
|
.hamburgerButton {
|
||||||
padding: 0.65rem 0.85rem;
|
padding: $spacer / 2;
|
||||||
text-align: center;
|
|
||||||
line-height: 1;
|
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
@import 'variables';
|
@import 'variables';
|
||||||
|
|
||||||
.searchButton {
|
.searchButton {
|
||||||
padding: 0.65rem 0.85rem;
|
padding: $spacer / 2;
|
||||||
text-align: center;
|
|
||||||
line-height: 1;
|
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-right: $spacer / 4;
|
margin-right: $spacer / 4;
|
||||||
|
@ -4,57 +4,36 @@
|
|||||||
.themeSwitch {
|
.themeSwitch {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: $spacer * $line-height;
|
vertical-align: middle;
|
||||||
|
margin-right: $spacer / 4;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
stroke: $brand-grey-light;
|
stroke: $brand-grey-light;
|
||||||
width: $font-size-base;
|
width: 24px;
|
||||||
height: $font-size-base;
|
height: 24px;
|
||||||
margin-top: -0.05rem;
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:hover,
|
||||||
width: $font-size-base * 0.9;
|
&:focus {
|
||||||
height: $font-size-base * 0.9;
|
svg {
|
||||||
|
stroke: $brand-cyan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.checkboxContainer {
|
&:active {
|
||||||
display: flex;
|
svg {
|
||||||
align-items: center;
|
stroke: darken($brand-cyan, 30%);
|
||||||
}
|
}
|
||||||
|
|
||||||
$knob-size: 8px;
|
|
||||||
$knob-space: 1px;
|
|
||||||
|
|
||||||
.checkboxFake {
|
|
||||||
display: block;
|
|
||||||
position: relative;
|
|
||||||
width: ($knob-size + ($knob-space * 2)) * 2;
|
|
||||||
height: $knob-size + ($knob-space * 4);
|
|
||||||
border: 1px solid $brand-grey-light;
|
|
||||||
border-radius: 15rem;
|
|
||||||
margin-left: $spacer / 3;
|
|
||||||
margin-right: $spacer / 3;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: $knob-space;
|
|
||||||
left: $knob-space;
|
|
||||||
width: $knob-size;
|
|
||||||
height: $knob-size;
|
|
||||||
background-color: $brand-grey-light;
|
|
||||||
border-radius: 15rem;
|
|
||||||
transition: transform 0.2s $easing;
|
|
||||||
transform: translate3d(0, 0, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkbox {
|
.checkbox {
|
||||||
position: relative;
|
position: relative;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
padding: $spacer / 2;
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
// hide visually
|
||||||
[type='checkbox'],
|
[type='checkbox'],
|
||||||
.label {
|
.label {
|
||||||
width: 1px;
|
width: 1px;
|
||||||
@ -66,16 +45,4 @@ $knob-space: 1px;
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
[type='checkbox'] {
|
|
||||||
&:checked {
|
|
||||||
+ .checkboxContainer {
|
|
||||||
.checkboxFake {
|
|
||||||
&::after {
|
|
||||||
transform: translate3d(100%, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,6 @@ import styles from './ThemeSwitch.module.scss'
|
|||||||
import Icon from '../atoms/Icon'
|
import Icon from '../atoms/Icon'
|
||||||
import { useSiteMetadata } from '../../hooks/use-site-metadata'
|
import { useSiteMetadata } from '../../hooks/use-site-metadata'
|
||||||
|
|
||||||
const ThemeToggle = () => (
|
|
||||||
<span id="toggle" className={styles.checkboxContainer} aria-live="assertive">
|
|
||||||
<Icon name="Sun" />
|
|
||||||
<span className={styles.checkboxFake} />
|
|
||||||
<Icon name="Moon" />
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
|
|
||||||
const ThemeToggleInput = ({
|
const ThemeToggleInput = ({
|
||||||
isDark,
|
isDark,
|
||||||
toggleDark
|
toggleDark
|
||||||
@ -48,7 +40,7 @@ export default function ThemeSwitch() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<HeadMarkup themeColor={themeColor} />
|
<HeadMarkup themeColor={themeColor} />
|
||||||
<aside className={styles.themeSwitch}>
|
<aside className={styles.themeSwitch} title="Toggle Dark Mode">
|
||||||
<label
|
<label
|
||||||
htmlFor="toggle"
|
htmlFor="toggle"
|
||||||
className={styles.checkbox}
|
className={styles.checkbox}
|
||||||
@ -61,7 +53,9 @@ export default function ThemeSwitch() {
|
|||||||
isDark={darkMode.value}
|
isDark={darkMode.value}
|
||||||
toggleDark={darkMode.toggle}
|
toggleDark={darkMode.toggle}
|
||||||
/>
|
/>
|
||||||
<ThemeToggle />
|
<div aria-live="assertive">
|
||||||
|
{darkMode.value ? <Icon name="Sun" /> : <Icon name="Moon" />}
|
||||||
|
</div>
|
||||||
</label>
|
</label>
|
||||||
</aside>
|
</aside>
|
||||||
</>
|
</>
|
||||||
|
@ -37,7 +37,6 @@ export default class Footer extends PureComponent {
|
|||||||
return (
|
return (
|
||||||
<footer role="contentinfo" className={styles.footer}>
|
<footer role="contentinfo" className={styles.footer}>
|
||||||
<Container>
|
<Container>
|
||||||
<ThemeSwitch />
|
|
||||||
<Vcard />
|
<Vcard />
|
||||||
|
|
||||||
<Copyright />
|
<Copyright />
|
||||||
|
@ -3,6 +3,7 @@ import { Link } from 'gatsby'
|
|||||||
import Container from '../atoms/Container'
|
import Container from '../atoms/Container'
|
||||||
import Search from '../molecules/Search'
|
import Search from '../molecules/Search'
|
||||||
import Menu from '../molecules/Menu'
|
import Menu from '../molecules/Menu'
|
||||||
|
import ThemeSwitch from '../molecules/ThemeSwitch'
|
||||||
import { ReactComponent as Logo } from '../../images/logo.svg'
|
import { ReactComponent as Logo } from '../../images/logo.svg'
|
||||||
|
|
||||||
import styles from './Header.module.scss'
|
import styles from './Header.module.scss'
|
||||||
@ -20,6 +21,7 @@ export default class Header extends PureComponent {
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<nav role="navigation" className={styles.nav}>
|
<nav role="navigation" className={styles.nav}>
|
||||||
|
<ThemeSwitch />
|
||||||
<Search />
|
<Search />
|
||||||
<Menu />
|
<Menu />
|
||||||
</nav>
|
</nav>
|
||||||
|
Loading…
Reference in New Issue
Block a user