-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Separate Checkboxes for Telemetry and Newsletter Subscripti…
…on in Onboarding Wizard (#7447)
- Loading branch information
1 parent
901c87c
commit 436a18e
Showing
9 changed files
with
207 additions
and
43 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
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
47 changes: 47 additions & 0 deletions
47
assets/src/js/admin/onboarding-wizard/components/checkbox-input/index.js
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,47 @@ | ||
// Import vendor dependencies | ||
import PropTypes from 'prop-types'; | ||
|
||
// Import utilities | ||
import {toKebabCase} from '../../utils'; | ||
|
||
// Import styles | ||
import './style.scss'; | ||
|
||
const CheckboxInput = ({label, help, value, checked, testId, onChange}) => { | ||
return ( | ||
<div className="give-obw-checkbox-input" data-givewp-test={testId}> | ||
{label && ( | ||
<label className="give-obw-checkbox-input__label" htmlFor={toKebabCase(label)}> | ||
{label} | ||
</label> | ||
)} | ||
{help && <p className="give-obw-checkbox-input__help">{help}</p>} | ||
<input | ||
type="checkbox" | ||
id={toKebabCase(label)} | ||
className="give-obw-checkbox-input__input" | ||
value={value} | ||
checked={checked} | ||
onChange={onChange} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
CheckboxInput.propTypes = { | ||
label: PropTypes.string, | ||
help: PropTypes.string, | ||
value: PropTypes.string.isRequired, | ||
checked: PropTypes.bool, | ||
onChange: PropTypes.func, | ||
}; | ||
|
||
CheckboxInput.defaultProps = { | ||
label: null, | ||
help: null, | ||
value: null, | ||
checked: false, | ||
onChange: null, | ||
}; | ||
|
||
export default CheckboxInput; |
49 changes: 49 additions & 0 deletions
49
assets/src/js/admin/onboarding-wizard/components/checkbox-input/style.scss
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,49 @@ | ||
/* stylelint-disable function-url-quotes */ | ||
|
||
.give-obw-checkbox-input { | ||
margin: 0.5rem 1rem; | ||
position: relative; | ||
padding-left: 2.5rem; | ||
|
||
> .give-obw-checkbox-input__label { | ||
color: #333; | ||
font-size: 1.125rem; | ||
font-weight: 600; | ||
line-height: 1.56; | ||
} | ||
|
||
> .give-obw-checkbox-input__help { | ||
color: #0e0e0e; | ||
font-size: 1rem; | ||
font-weight: 400; | ||
line-height: 1.5; | ||
margin-top: 0.5rem; | ||
} | ||
|
||
> .give-obw-checkbox-input__input { | ||
appearance: none; | ||
background-color: #fff; | ||
border: solid 1px #4fa651; | ||
border-radius: 0.25rem; | ||
color: #4fa651; | ||
cursor: pointer; | ||
font-size: inherit; | ||
height: 1.5rem; | ||
left: 0; | ||
margin: 0; | ||
opacity: 1; | ||
top: 0; | ||
vertical-align: middle; | ||
width: 1.5rem; | ||
|
||
&:checked { | ||
--icon-checkbox: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2724%27 height=%2724%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27rgb%28255, 255, 255%29%27 stroke-width=%274%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpolyline points=%2720 6 9 17 4 12%27%3E%3C/polyline%3E%3C/svg%3E"); | ||
|
||
background-color: #4fa651; | ||
background-image: var(--icon-checkbox); | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
background-size: 1em auto; | ||
} | ||
} | ||
} |