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

Conversation

prudho
Copy link
Contributor

@prudho prudho commented Jul 7, 2021

Description

Following #2009, I think that indeed checkboxes need some fancy new features too. So I open this PR as a draft and discussion topic.

For now, I just add colored and outline checkboxes too see what it's possible to implement.

The others options i'm thinking are:

  • icons instead of check mark.
  • animated checks (js and Transition are paving the way).
  • label text depending on checkbox state...

What do you guys think about this ?

Testcase

JSFiddle

Screenshot

Capture

Related issues

#393, #550, #2009

@prudho prudho added type/feat Any feature requests or improvements lang/css Anything involving CSS lang/javascript Anything involving JavaScript type/discussion Anything which is up for discussion state/awaiting-reviews Pull requests which are waiting for reviews state/awaiting-docs Pull requests which need doc changes/additions state/awaiting-changes Anything which is awaiting changes tag/help-wanted Issues which need help to fix or implement labels Jul 7, 2021
@prudho prudho added this to the 2.9.0 milestone Jul 7, 2021
@prudho prudho marked this pull request as draft July 7, 2021 14:52
@lubber-de
Copy link
Member

I like the approach to make outline optional 👍🏼 !
I also like your additional ideas 🙂

Copy link
Member

@lubber-de lubber-de left a comment

Choose a reason for hiding this comment

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

I know, this PR is marked as Draft and WIP, but i wanted to give "official" Feedback beside my other comment anyway 🙂 for the current code.

src/definitions/modules/checkbox.less Outdated Show resolved Hide resolved
src/definitions/modules/checkbox.less Outdated Show resolved Hide resolved
Comment on lines 813 to 816
.ui.@{color}.toggle.checkbox input:checked ~ label::before,
.ui.@{color}.slider.checkbox input:checked ~ label::before {
background-color: @color !important;
}
Copy link
Member

Choose a reason for hiding this comment

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

Beside the variable name: Any chance to increase specificity without using !important? (Haven't tested myself yet!)

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried .ui.ui and .ui.ui.ui, but still need that !important to work... 😞

Copy link
Member

Choose a reason for hiding this comment

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

It's because there is an existing !important at

.ui.toggle.checkbox input:checked ~ label:before {
    background-color: #2185D0 !important;
}

We would need to remove the !important from there too

Copy link
Member

Choose a reason for hiding this comment

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

If you check the checkbox.less there are still a few !important for toggle and slider which are causing this. This PR is a good chance to get rid of them as well 😉

src/definitions/modules/checkbox.less Outdated Show resolved Hide resolved
src/definitions/modules/checkbox.less Outdated Show resolved Hide resolved
@prudho
Copy link
Contributor Author

prudho commented Aug 9, 2021

Icon instead of checkmark is doable:

image

But it will require more tests and code than previous modifications. Should I create another PR ?

@lubber-de
Copy link
Member

But it will require more tests and code than previous modifications. Should I create another PR ?

Up to you 😉 Just make sure that each PR is based on current develop (or do everything in one PR)

@lubber-de
Copy link
Member

lubber-de commented Aug 9, 2021

I have a suggestion/idea/question:
What about replacing outline by bordered?
We already have bordered icon and bordered image

https://fomantic-ui.com/elements/icon.html#bordered-colored

However, a checkbox/radio always has an "outline" or is "bordered". Your new feature does only make the outline/border more prominent/bold/colored

Opinion?

@prudho
Copy link
Contributor Author

prudho commented Aug 10, 2021

Yeah I don't know how to really name it, since I "copy" class name from another framework. And I struck to find another class name for a no bordered checkbox as well (well the border disapear when checked).

@prudho
Copy link
Contributor Author

prudho commented Aug 10, 2021

I've added the icon variation. Works well overall, except for sizes, i'm not comfortable with advanced scss yet 😞

@@ -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

@@ -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

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....)

@lubber-de lubber-de modified the milestones: 2.9.0, 2.9.x Dec 27, 2021
@lubber-de lubber-de removed the state/awaiting-reviews Pull requests which are waiting for reviews label Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang/css Anything involving CSS lang/javascript Anything involving JavaScript state/awaiting-changes Anything which is awaiting changes state/awaiting-docs Pull requests which need doc changes/additions tag/help-wanted Issues which need help to fix or implement type/discussion Anything which is up for discussion type/feat Any feature requests or improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants