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

feat(checkbox): Updates to experimental checkbox #1135

Merged
merged 10 commits into from
Sep 28, 2018
84 changes: 40 additions & 44 deletions src/components/checkbox/_checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
height: 5px;
background: none;
/*rtl:ignore*/
border-left: 2px solid $inverse-01;
border-bottom: 2px solid $inverse-01;
border-left: 1px solid $inverse-01;
border-bottom: 1px solid $inverse-01;
/*rtl:ignore*/
transform: scale(0) rotate(-45deg);
position: absolute;
Expand Down Expand Up @@ -213,11 +213,11 @@
@include font-family;
@include font-smoothing;
@include typescale('zeta');
line-height: 1.25rem;
line-height: 1.5rem;
position: relative;
display: flex;
cursor: pointer;
padding-left: rem(24px);
padding-left: rem(26px); //width of checkbox 16px + 10px of padding
min-height: rem(24px);
user-select: none;
}
Expand All @@ -230,8 +230,8 @@
// According to the spec, we'll want the bounding box for our checkbox to
// be 16px. The border size will be what will be updated during the
// different checkbox states.
width: rem(12px);
height: rem(12px);
width: rem(16px);
height: rem(16px);
margin: rem(2px);

// We need to position the pseudo-element absolutely in the space that we've
Expand All @@ -243,53 +243,25 @@
top: rem(2px);
background-color: $ui-02;
border: 1px solid $ui-05;
border-radius: 1px;
border-radius: 2px;
}

// Create the appearance of the check in the `after` pseudo-element
.#{$prefix}--checkbox-label::after {
content: '';
position: absolute;
left: rem(5px);
top: rem(7px);
width: rem(6px);
left: rem(6px);
top: rem(8px);
width: rem(7px);
height: rem(3px);
background: none;
border-left: 1px solid $ui-02;
border-bottom: 1px solid $ui-02;
border-left: 2px solid $ui-02;
border-bottom: 2px solid $ui-02;
transform: scale(0) rotate(-45deg);
transform-origin: bottom right;
margin-top: rem(-3px);
}

//----------------------------------------------
// Hover
// ---------------------------------------------

// Hover color for border
.#{$prefix}--checkbox-wrapper:hover .#{$prefix}--checkbox-label::before {
border-color: $ibm-colors__gray--70;
}

//----------------------------------------------
// Focus
// ---------------------------------------------

// Update border color and width for focus
.#{$prefix}--checkbox:focus + .#{$prefix}--checkbox-label::before,
.#{$prefix}--checkbox-label__focus::before,
.#{$prefix}--checkbox-wrapper:hover .#{$prefix}--checkbox-label__focus::before {
border-color: $brand-01;
border-width: 3px;
}

// Handle case of checked and focused
.#{$prefix}--checkbox:checked:focus + .#{$prefix}--checkbox-label::before,
.#{$prefix}--checkbox-label[data-contained-checkbox-state='true'].#{$prefix}--checkbox-label__focus::before {
background-color: $brand-01;
border-color: $brand-01;
}

//----------------------------------------------
// Checked
// ---------------------------------------------
Expand All @@ -316,20 +288,44 @@
transform: scale(1) rotate(0deg);
border-left: 0 solid $inverse-01;
border-bottom: 1.5px solid $inverse-01;
width: rem(6px);
top: rem(9.25px);
width: rem(8px);
top: rem(11px);
}

//----------------------------------------------
// Focus
// ---------------------------------------------

// Unchecked
.#{$prefix}--checkbox:focus + .#{$prefix}--checkbox-label::before,
.#{$prefix}--checkbox-label__focus::before,
// Checked
.#{$prefix}--checkbox:checked:focus + .#{$prefix}--checkbox-label::before,
.#{$prefix}--checkbox-label[data-contained-checkbox-state='true'].#{$prefix}--checkbox-label__focus::before,
// Indeterminate
.#{$prefix}--checkbox:indeterminate:focus + .#{$prefix}--checkbox-label::before,
.#{$prefix}--checkbox-label[data-contained-checkbox-state='mixed'].#{$prefix}--checkbox-label__focus::before {
// We can't use outline here because of the rounded corners so have to increase the width/height to fake an outline.
border-color: $brand-01;
border-width: 3px;
width: rem(20px);
height: rem(20px);
left: -2px;
top: 0;
}

//----------------------------------------------
// Disabled
// ---------------------------------------------

.#{$prefix}--checkbox:disabled + .#{$prefix}--checkbox-label {
.#{$prefix}--checkbox:disabled + .#{$prefix}--checkbox-label,
.#{$prefix}--checkbox-label[data-contained-checkbox-disabled='true'] {
cursor: not-allowed;
color: $text-03;
}

.#{$prefix}--checkbox:disabled + .#{$prefix}--checkbox-label::before {
.#{$prefix}--checkbox:disabled + .#{$prefix}--checkbox-label::before,
.#{$prefix}--checkbox-label[data-contained-checkbox-disabled='true']::before {
border-color: $text-03;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/checkbox/checkbox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
</div>
<!-- label > input -->
<div class="bx--form-item bx--checkbox-wrapper">
<label for="bx--checkbox-new2" class="bx--checkbox-label">
<input id="bx--checkbox-new2" class="bx--checkbox" type="checkbox" value="yellow" name="checkbox" disabled>
<label for="bx--checkbox-disabled2" class="bx--checkbox-label">
<input id="bx--checkbox-disabled2" class="bx--checkbox" type="checkbox" value="yellow" name="checkbox" disabled>
Disabled checkbox
</label>
</div>
Expand Down