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

[Checkbox][WIP] New features #2010

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
101 changes: 100 additions & 1 deletion src/definitions/modules/checkbox.less
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,64 @@
}
}

& when (@variationCheckboxColored) {
/*--------------
Colored
---------------*/

each(@colors, {
@color: replace(@key, '@', '');
@c: @colors[@@color][color];
@l: @colors[@@color][light];
@isVeryDark: @colors[@@color][isVeryDark];

.ui.@{color}.checkbox input:checked ~ label::after {
color: @c;
}
.ui.@{color}.radio.checkbox input:checked ~ label::after {
background-color: @c;
}
.ui.@{color}.toggle.checkbox input:checked ~ label::before,
.ui.@{color}.slider.checkbox input:checked ~ label::before {
background-color: @c !important;
}

& when (@variationCheckboxOutline) {
/*--------------
Outline
---------------*/
.ui.@{color}.outline.checkbox input:checked ~ label::before {
border-color: @c;
}
.ui.@{color}.outline.toggle.checkbox input:checked ~ label::after,
.ui.@{color}.outline.slider.checkbox input:checked ~ label::after {
box-shadow: @subtleShadow,
0 0 0 1px @c inset;
}
}
})
}

/*--------------------
Size
outline
---------------------*/

& when (@variationCheckboxOutline) {
.ui.outline.checkbox input:checked ~ label::before {
border-color: @checkboxActiveCheckColor;
}
.ui.outline.toggle.checkbox input:checked ~ label::after {
box-shadow: @subtleShadow,
0 0 0 1px @toggleOnLaneColor inset;
}
.ui.outline.slider.checkbox input:checked ~ label::after {
box-shadow: @subtleShadow,
0 0 0 1px @checkboxActiveCheckColor inset;
}
}

/*--------------------
Size
---------------------*/

each(@variationCheckboxSizes, {
Expand Down Expand Up @@ -861,4 +917,47 @@ each(@variationCheckboxSizes, {
}
})

/*--------------------
Icon
---------------------*/

& when (@variationCheckboxIcon) {
.ui.icon.checkbox input ~ label i {
width: auto;
margin: 0 !important;
line-height: @checkboxLineHeight;
}

.ui.icon.checkbox input:not(:checked) ~ label i {
Copy link
Member

@lubber-de lubber-de Aug 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means, that any icon inside the label (and not supposed to be used for the "check" icon) will vanish.
If we keep this logic, this would mean to define that icon.checkbox variations do not support Icons in the label itself

Just a thought (I don't request the following):

What about using the icon font family on icon.checkbox instead, so dont have to deal with a separate i tag? That would probably also fix the sizing issues and is the same approach as the current check icon.
Infact, this approach would mean to adjust all icons selectors which would be quite a lot.
A long time back we discussed data attributes "data-icon" which would be independent of the tag and could be reused here (yes, that would be a separate PR and huge breaking change....)

display: none;
}

.ui.icon.checkbox input:checked ~ label i:before {
position: absolute;
top: 0;
left: 0;
width: @checkboxSize;
height: @checkboxSize;
text-align: center;
font-size: @checkboxIconCheckFontSize;
}

& when (@variationCheckboxColored) {
/*--------------
Colored
---------------*/

each(@colors, {
@color: replace(@key, '@', '');
@c: @colors[@@color][color];
@l: @colors[@@color][light];
@isVeryDark: @colors[@@color][isVeryDark];

.ui.@{color}.checkbox input:checked ~ label i::before {
color: @c;
}
})
}
}

.loadUIOverrides();
3 changes: 3 additions & 0 deletions src/themes/default/globals/variation.variables
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@
@variationCheckboxFitted: true;
@variationCheckboxRightAligned: true;
@variationCheckboxSizes: @variationAllSizes;
@variationCheckboxColored: true;
@variationCheckboxOutline: true;
@variationCheckboxIcon: true;

/* Dimmer */
@variationDimmerInverted: true;
Expand Down
4 changes: 2 additions & 2 deletions src/themes/default/modules/checkbox.overrides
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
}

/* Checked */
.ui.checkbox input:checked ~ .box:after,
.ui.checkbox input:checked ~ label:after {
.ui.checkbox:not(.icon) input:checked ~ .box:after,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we removed the .box selectors by #2049 you may merge the current develop into this PR and remove the .box afterwwards

.ui.checkbox:not(.icon) input:checked ~ label:after {
content: '\e800';
}

Expand Down
1 change: 1 addition & 0 deletions src/themes/default/modules/checkbox.variables
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
@checkboxCheckTop: 0;
@checkboxCheckLeft: 0;
@checkboxCheckSize: @checkboxSize;
@checkboxIconCheckFontSize: 12px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the @{size}CheckboxSize variables already, you may reuse them (i didn't test 🙄 )
Also, please use em instead of px


/* Label */
@labelFontSize: @relativeMedium;
Expand Down