fix: change toggle style and improve responsiveness

This commit is contained in:
Oliver Eyton-Williams
2019-08-21 16:19:56 +02:00
committed by mrugesh
parent c6b287b2b3
commit e90eb66529
6 changed files with 88 additions and 6 deletions

View File

@ -5,6 +5,7 @@ function Spacer(props) {
<Fragment> <Fragment>
<span className='sr-only'>Passed</span> <span className='sr-only'>Passed</span>
<svg <svg
className='tick'
height='50' height='50'
viewBox='-10 -45 200 200' viewBox='-10 -45 200 200'
width='50' width='50'

View File

@ -5,6 +5,7 @@ function ToggleCheck(props) {
<Fragment> <Fragment>
<span className='sr-only'>Passed</span> <span className='sr-only'>Passed</span>
<svg <svg
className='tick'
height='50' height='50'
viewBox='-10 -45 200 200' viewBox='-10 -45 200 200'
width='50' width='50'

View File

@ -17,9 +17,11 @@
background-color: var(--secondary-color); background-color: var(--secondary-color);
} }
.btn .toggle-not-active, .btn-group .btn.toggle-not-active,
.btn .toggle-active { .btn-group .btn.toggle-active {
border-color: var(--secondary-color); border-color: var(--tertiary-color);
padding-left: 30px;
padding-right: 30px;
} }
.btn-group .btn-primary, .btn-group .btn-primary,
@ -27,3 +29,50 @@
.btn-group .btn-primary:hover { .btn-group .btn-primary:hover {
border-color: var(--secondary-color); border-color: var(--secondary-color);
} }
.btn.toggle-active > .tick,
.btn.toggle-not-active > .tick {
position: absolute;
}
.btn:first-child > .tick {
left: 9px;
top: calc(50% - 8pt);
}
.btn:last-child > .tick {
right: 6px;
top: calc(50% - 8pt);
}
.btn-group .btn + .btn {
margin-left: -2px;
}
label.toggle-label {
display: flex;
flex-direction: column;
justify-content: center;
}
@media (max-width: 550px) {
.btn:first-child > .tick {
left: 6px;
}
.btn:last-child > .tick {
right: 5px;
}
}
@media (max-width: 440px) {
.btn-group .btn + .btn {
margin-left: 0px;
margin-top: -2px;
}
.btn:first-child > .tick {
left: auto;
right: 5px;
}
}

View File

@ -13,7 +13,7 @@ const propTypes = {
export default function ThemeSettings({ currentTheme, toggleNightMode }) { export default function ThemeSettings({ currentTheme, toggleNightMode }) {
return ( return (
<div id='theme-settings-container'> <div className='toggle-setting-container' id='theme-settings-container'>
<ControlLabel className='theme-label' htmlFor='night-mode'> <ControlLabel className='theme-label' htmlFor='night-mode'>
<strong>Night Mode</strong> <strong>Night Mode</strong>
</ControlLabel> </ControlLabel>

View File

@ -3,6 +3,29 @@
justify-content: space-between; justify-content: space-between;
} }
.toggle-setting-container .form-group label { .toggle-setting-container .btn-group {
max-width: 50%; padding-left: 5px;
}
.toggle-setting-container > .form-group > * {
flex: 1 1 0;
}
.toggle-setting-container .btn-group {
display: flex;
justify-content: flex-end;
align-items: flex-start;
}
@media (max-width: 440px) {
.toggle-setting-container > .form-group > * {
flex: 0 1 auto;
}
.toggle-setting-container .btn-group,
.theme-setting-container .btn-group {
flex-direction: column;
align-items: stretch;
justify-content: flex-start;
}
} }

View File

@ -41,6 +41,14 @@
.underlined-link { .underlined-link {
text-decoration: underline; text-decoration: underline;
} }
/* Buttons with a lot of text can overflow and mess up formatting on small
screens, this stops that unless the word itself is too large. */
.btn {
white-space: pre-line;
}
@media (min-width: 991px) and (max-width: 1199px) { @media (min-width: 991px) and (max-width: 1199px) {
.testimonial-copy { .testimonial-copy {
height: 150px; height: 150px;