Skip to content

Commit

Permalink
feat(checkbox): support right aligned position of checkbox variants
Browse files Browse the repository at this point in the history
It was not supported to have any kind of checkbox positioned to the right of the label.
This PR now introduces right aligned checkbox variants
  • Loading branch information
lubber-de authored Sep 10, 2020
1 parent 59d9b40 commit db91227
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
50 changes: 49 additions & 1 deletion src/definitions/modules/checkbox.less
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,17 @@
color: @checkboxColor;
transition: @checkboxTransition;
}

& when (@variationCheckboxRightAligned) {
.ui.right.aligned.checkbox label {
padding-left: 0;
padding-right: @labelDistance;
&:after,
&:before {
right: 0;
left: auto;
}
}
}
/*--------------
Label
---------------*/
Expand Down Expand Up @@ -317,6 +327,12 @@
left: @toggleCenterOffset;
}
}
& when (@variationCheckboxRightAligned) {
.ui.right.aligned.indeterminate.toggle.checkbox input:not([type=radio]) ~ label:after {
left: auto;
right: @toggleCenterOffset;
}
}
}

/*--------------
Expand Down Expand Up @@ -542,6 +558,22 @@
.ui.slider.checkbox input:focus:checked ~ label:before {
background-color: @sliderOnFocusLineColor !important;
}

& when (@variationCheckboxRightAligned) {
.ui.right.aligned.slider.checkbox label {
padding-left: 0;
padding-right: @sliderLabelDistance;
}
.ui.right.aligned.slider.checkbox label:after {
left: auto;
right: @sliderTravelDistance;
transition: @sliderHandleTransitionRightAligned;
}
.ui.right.aligned.slider.checkbox input:checked ~ label:after {
left: auto;
right: 0;
}
}
}

& when (@variationCheckboxToggle) {
Expand Down Expand Up @@ -643,6 +675,22 @@
.ui.toggle.checkbox input:focus:checked ~ label:before {
background-color: @toggleOnFocusLaneColor !important;
}

& when (@variationCheckboxRightAligned) {
.ui.right.aligned.toggle.checkbox label {
padding-left: 0;
padding-right: @toggleLabelDistance;
}
.ui.right.aligned.toggle.checkbox input ~ label:after {
left: auto;
right: @toggleOnOffset;
transition: @toggleHandleTransitionRightAligned;
}
.ui.right.aligned.toggle.checkbox input:checked ~ label:after {
left: auto;
right: @toggleOffOffset;
}
}
}

/*******************************
Expand Down
1 change: 1 addition & 0 deletions src/themes/default/globals/variation.variables
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@
@variationCheckboxToggle: true;
@variationCheckboxIndeterminate: true;
@variationCheckboxFitted: true;
@variationCheckboxRightAligned: true;
@variationCheckboxSizes: @variationAllSizes;

/* Dimmer */
Expand Down
5 changes: 5 additions & 0 deletions src/themes/default/modules/checkbox.variables
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@

@sliderHandleOffset: (1rem - @sliderHandleSize) / 2;
@sliderHandleTransition: left @sliderTransitionDuration @defaultEasing;
@sliderHandleTransitionRightAligned: right @sliderTransitionDuration @defaultEasing;

@sliderWidth: @sliderLineWidth;
@sliderHeight: (@sliderHandleSize + @sliderHandleOffset);
Expand Down Expand Up @@ -159,6 +160,10 @@
background @sliderTransitionDuration @defaultEasing,
left @sliderTransitionDuration @defaultEasing
;
@toggleHandleTransitionRightAligned:
background @sliderTransitionDuration @defaultEasing,
right @sliderTransitionDuration @defaultEasing
;

@toggleLaneBackground: @transparentBlack;
@toggleLaneHeight: @toggleHandleSize;
Expand Down

0 comments on commit db91227

Please sign in to comment.