Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Styling: Checkbox States (Error/Warning/Success) #1889

Merged
merged 9 commits into from
Jan 23, 2024
61 changes: 56 additions & 5 deletions docs/pages/checkboxes.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,67 @@ variation_groups:
variation_description: ''
variation_name: Standard checkbox
variation_specs: ''
- variation_is_deprecated: false
variation_name: Validation status
variation_code_snippet: >-
<!--Success-->

<div class="m-form-field m-form-field__checkbox m-form-field__checkbox__success">
<input class="a-checkbox" type="checkbox" id="test_checkbox_success">
<label class="a-label" for="test_checkbox_success">Success</label>
</div>

<br>

<!--Success-(Focus)-->

<div class="m-form-field m-form-field__checkbox m-form-field__checkbox__success">
<input class="a-checkbox focus" type="checkbox" id="test_checkbox_success_focus">
<label class="a-label" for="test_checkbox_success_focus">Success (Focus)</label>
</div>

<br>

<!--Warning-->

<div class="m-form-field m-form-field__checkbox m-form-field__checkbox__warning">
<input class="a-checkbox" type="checkbox" id="test_checkbox_warning">
<label class="a-label" for="test_checkbox_warning">Warning</label>
</div>

<br>

<!--Warning-(Focus)-->

<div class="m-form-field m-form-field__checkbox m-form-field__checkbox__warning">
<input class="a-checkbox focus" type="checkbox" id="test_checkbox_warning_focus">
<label class="a-label" for="test_checkbox_warning_focus">Warning (Focus)</label>
</div>

<br>

<!--Error-->

<div class="m-form-field m-form-field__checkbox m-form-field__checkbox__error">
<input class="a-checkbox" type="checkbox" id="test_checkbox_error">
<label class="a-label" for="test_checkbox_error">Error</label>
</div>

<br>

<!--Error-(Focus)-->

<div class="m-form-field m-form-field__checkbox m-form-field__checkbox__error">
<input class="a-checkbox focus" type="checkbox" id="test_checkbox_error_focus">
<label class="a-label" for="test_checkbox_error_focus">Error (Focus)</label>
</div>
- variation_is_deprecated: false
variation_name: Standard checkbox with helper text
variation_code_snippet: >-
<div class="m-form-field m-form-field__checkbox">
<input class="a-radio" type="checkbox" id="test_checkbox_basic_helper">
<input class="a-checkbox" type="checkbox" id="test_checkbox_basic_helper">
<label class="a-label" for="test_checkbox_basic_helper">
Checkbox label
<small class="a-label_helper">
(This is optional helper text)
</small>
Success
</label>
</div>
- variation_is_deprecated: false
Expand Down
69 changes: 69 additions & 0 deletions packages/cfpb-forms/src/molecules/form-fields.less
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,75 @@
.u-svg-inline-bg( 'approved', @gray );
}
}

&__error {
.a-label {
&::before {
border-color: @input-border__error;
box-shadow: 0 0 0 1px @input-border__error;
}
}

.a-checkbox {
&:focus + .a-label::before,
&.focus + .a-label::before {
border-color: @input-border__error;
box-shadow: 0 0 0 1px @input-border__error;
}

&:focus + .a-label,
&.focus + .a-label {
outline: 1px dotted @input-border__error;
outline-offset: 1px;
}
}
}

&__warning {
.a-label {
&::before {
border-color: @input-border__warning;
box-shadow: 0 0 0 1px @input-border__warning;
}
}

.a-checkbox {
&:focus + .a-label::before,
&.focus + .a-label::before {
border-color: @input-border__warning;
box-shadow: 0 0 0 1px @input-border__warning;
}

&:focus + .a-label,
&.focus + .a-label {
outline: 1px dotted @input-border__warning;
outline-offset: 1px;
}
}
}

&__successs {
.a-label {
&::before {
border-color: @input-border__success;
box-shadow: 0 0 0 1px @input-border__success;
}
}

.a-checkbox {
&:focus + .a-label::before,
&.focus + .a-label::before {
border-color: @input-border__success;
box-shadow: 0 0 0 1px @input-border__success;
}

&:focus + .a-label,
&.focus + .a-label {
outline: 1px dotted @input-border__success;
outline-offset: 1px;
}
}
}
}

&__radio {
Expand Down
Loading