Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Checkbox Component Styling Fix #5164

Merged
merged 3 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
}
}

.wc-block-components-checkbox {
margin-right: $gap;
}

.wc-block-checkout__terms_notice .components-notice__action {
margin-left: 0;
}
Expand Down
51 changes: 26 additions & 25 deletions packages/checkout/components/checkbox-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,39 +35,40 @@ const CheckboxControl = ( {
const checkboxId = id || `checkbox-control-${ instanceId }`;

return (
<label
<div
className={ classNames(
'wc-block-components-checkbox',
{
'has-error': hasError,
},
className
) }
htmlFor={ checkboxId }
>
<input
id={ checkboxId }
className="wc-block-components-checkbox__input"
type="checkbox"
onChange={ ( event ) => onChange( event.target.checked ) }
aria-invalid={ hasError === true }
{ ...rest }
/>
<svg
className="wc-block-components-checkbox__mark"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 20"
>
<path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" />
</svg>
{ label && (
<span className="wc-block-components-checkbox__label">
{ label }
</span>
) }
{ children }
</label>
<label htmlFor={ checkboxId }>
<input
id={ checkboxId }
className="wc-block-components-checkbox__input"
type="checkbox"
onChange={ ( event ) => onChange( event.target.checked ) }
aria-invalid={ hasError === true }
{ ...rest }
/>
<svg
className="wc-block-components-checkbox__mark"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 20"
>
<path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" />
</svg>
{ label && (
<span className="wc-block-components-checkbox__label">
{ label }
</span>
) }
{ children }
</label>
</div>
);
};

Expand Down
12 changes: 8 additions & 4 deletions packages/checkout/components/checkbox-control/style.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
.wc-block-components-checkbox {
@include reset-typography();
align-items: flex-start;
display: flex;
position: relative;
margin-top: em($gap-large);

label {
align-items: flex-start;
display: flex;
position: relative;
}

.wc-block-components-checkbox__input[type="checkbox"] {
font-size: 1em;
appearance: none;
Expand All @@ -14,6 +17,7 @@
height: em(24px);
width: em(24px);
margin: 0;
margin-right: $gap;
min-height: 24px;
min-width: 24px;
overflow: hidden;
Expand Down Expand Up @@ -83,6 +87,7 @@
margin-top: em(1px);
width: em(18px);
height: em(18px);
pointer-events: none;

.has-dark-controls & {
fill: #fff;
Expand All @@ -91,7 +96,6 @@

> span,
.wc-block-components-checkbox__label {
padding-left: $gap;
vertical-align: middle;
line-height: em(24px);
}
Expand Down