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

Fixing RadioButton and Checkbox styles, solves #442 #299 #415 #489 #488 #508

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 9 additions & 3 deletions Checkbox/Checkbox.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<template class="d-reset d-inline" role="presentation">
<input type="checkbox" role="checkbox" attach-point="focusNode,valueNode"
checked="{{checked}}" value="{{value}}" name="{{name}}"/>
<template role="presentation">

<input class="d-reset" type="checkbox" attach-point="focusNode,valueNode"
Copy link
Member

Choose a reason for hiding this comment

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

d-reset set font, line-height and color. This looks not needed here if only padding and margin must be set. Same comment for radiobutton.

Copy link
Member Author

Choose a reason for hiding this comment

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

oversight on my part.

checked="{{checked}}" value="{{value}}" name="{{name}}"/>
<svg class="d-checkbox-visual" viewBox="0 0 2048 2048" xmlns="http://www.w3.org/2000/svg">
<rect class="d-checkbox-visual-outer" x="0" y="0" width="2048" height="2048" stroke-width="204"/>
<!-- TODO: credit font-awesome for the svg path below. http://fontawesome.io/icon/check/ -->
<path class="d-checkbox-visual-inner" d="M1799 694q0 40-28 68l-724 724-136 136q-28 28-68 28t-68-28l-136-136-362-362q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 295 656-657q28-28 68-28t68 28l136 136q28 28 28 68z"/>
</svg>
</template>
85 changes: 42 additions & 43 deletions Checkbox/themes/Checkbox_template.less
Original file line number Diff line number Diff line change
@@ -1,56 +1,55 @@
label[for] {
// fixes a ios bug that makes it so that the handler set on document,
// listening for clicks on label, is never called.
cursor: pointer;
}

.d-checkbox {
position: relative;
.d-checkbox-styles();
&.d-focused { // from tab-focus()
.d-checkbox-focused();
display: inline-block;
/* #408 Enforce content-box to ensure correctly centered check mark */
/* even if border-box is used everywhere else for instance */
/* via delite/themes/defaultapp.css */
box-sizing: content-box;
Copy link
Member

Choose a reason for hiding this comment

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

Enforcing box-sizing looks obsolete with this refactoring. Same comment for radiobutton.

Copy link
Member Author

Choose a reason for hiding this comment

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

true. I'll remove it


&.d-disabled *, fieldset[disabled] & * {
cursor: not-allowed;
}
&::before {
overflow: hidden;

&-visual {
overflow: visible;
Copy link
Member

Choose a reason for hiding this comment

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

I noticed that overflow visible make the border stronger. But I don't understand how it works, could you comment?
The border of the radiobutton is lighter with the same directive.
I wonder if removing overflow on both would solve the question: more consistency between checkbox and radiobutton and less CSS.

Copy link
Member Author

Choose a reason for hiding this comment

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

<svg> has by default overflow:hidden. At some sizes it hides the borders of the graphic inside or thinners it.

display: inline-block;
position:absolute;
top:0px;
content:"";
.d-checkbox-before-styles();
}
&.d-rtl::before {
right: 0px;
}
&.d-checked::before {
content: "\2714";
.d-checkbox-checked-before-styles();
position: relative;
&-inner {
position: absolute;
visibility: hidden;

}
.d-checked &-inner {
visibility: visible;
}
}
&:active::before {
.d-checkbox-active-styles();

&-visual {
.d-checkbox-styles(normal);
}
&.d-disabled {
color: @d-checkbox-disabled-color;
&::before {
.d-checkbox-before-disabled-styles();
}

.d-disabled &-visual {
.d-checkbox-styles(disabled);
}
&.d-disabled,
fieldset[disabled] & {
cursor: not-allowed;

.d-focused &-visual {
.d-checkbox-styles(focused);
}
}

.d-checkbox > input[type=checkbox] {
.d-checkbox-input-styles();
opacity: 0.01;
position: relative;
overflow: hidden;
font: inherit;
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
&[disabled],
fieldset[disabled] & {
cursor: not-allowed;
}
/* The input is not stretched so that is spans
* all over the space available inside d-checkbox */
width: 100%; height: 100%;
/* NOTE: we could have used opacity: 0 here but it breaks the focus */
opacity: .01;
position: absolute;
z-index: 1;
}

label[for] {
// fixes a ios bug that makes it so that the handler set on document,
// listening for clicks on label, is never called.
cursor: pointer;
}
142 changes: 92 additions & 50 deletions Checkbox/themes/bootstrap/Checkbox.css
Original file line number Diff line number Diff line change
@@ -1,65 +1,107 @@
.d-checkbox {
position: relative;
margin-left: 4px;
margin-right: 4px;
margin-top: 3px;
margin-bottom: 3px;
}
.d-checkbox.d-focused {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
/* interoperability with bootstrap form layouts */
.checkbox .d-checkbox,
.checkbox-inline .d-checkbox {
margin-left: -20px;
margin-right: 0;
position: absolute;
}
label[for] {
cursor: pointer;
}
.d-checkbox::before {
overflow: hidden;
.d-checkbox {
position: relative;
display: inline-block;
/* #408 Enforce content-box to ensure correctly centered check mark */
/* even if border-box is used everywhere else for instance */
/* via delite/themes/defaultapp.css */
box-sizing: content-box;
}
.d-checkbox.d-disabled *,
fieldset[disabled] .d-checkbox * {
cursor: not-allowed;
}
.d-checkbox-visual {
overflow: visible;
display: inline-block;
position: relative;
}
.d-checkbox-visual-inner {
position: absolute;
top: 0px;
content: "";
border-color: #cccccc;
border-style: solid;
border-width: 1px;
border-radius: 4px;
background-image: linear-gradient(to bottom, #ededed 0%, #dedede 100%);
height: 1em;
width: 100%;
color: #555555;
visibility: hidden;
}
.d-checkbox.d-rtl::before {
right: 0px;
.d-checked .d-checkbox-visual-inner {
visibility: visible;
}
.d-checkbox.d-checked::before {
content: "\2714";
.d-checkbox-visual {
width: 11px;
height: 11px;
}
.d-checkbox.d-disabled {
color: #eeeeee;
.d-checkbox-visual-inner {
fill: #555555;
}
.d-checkbox.d-disabled::before {
color: #999999;
background-color: #eeeeee;
.d-checkbox-visual-outer {
stroke: #cccccc;
fill: white;
}
.d-checkbox.d-disabled,
fieldset[disabled] .d-checkbox {
cursor: not-allowed;
.d-disabled .d-checkbox-visual-outer {
fill: #eeeeee;
}
.d-checkbox > input[type=checkbox] {
width: 1em;
height: 1em;
margin: 0px;
margin-top: 1px \9;
/* IE8-9 */
opacity: 0.01;
position: relative;
overflow: hidden;
font: inherit;
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
.d-disabled .d-checkbox-visual-inner {
fill: #999999;
}
.d-checkbox > input[type=checkbox][disabled],
fieldset[disabled] .d-checkbox > input[type=checkbox] {
cursor: not-allowed;
.d-focused .d-checkbox-visual {
/* NOTE: from http://github.com/twbs/bootstrap/blob/49519e9/less/mixins/forms.less#L56 */
-webkit-box-shadow: 0 0 8px rgba(102, 175, 233, 0.6);
-moz-box-shadow: 0 0 8px rgba(102, 175, 233, 0.6);
box-shadow: 0 0 8px rgba(102, 175, 233, 0.6);
/* interoperability with bootstrap validation states */
/* NOTE: from http://github.com/twbs/bootstrap/blob/49519e9/less/mixins/forms.less#L26 */
}
label[for] {
cursor: pointer;
.d-focused .d-checkbox-visual-outer {
stroke: #66afe9;
}
.has-success .d-focused .d-checkbox-visual {
-webkit-box-shadow: 0 0 6px #67b168;
-moz-box-shadow: 0 0 6px #67b168;
box-shadow: 0 0 6px #67b168;
}
.has-success .d-focused .d-checkbox-visual-outer {
stroke: #3c763d;
}
.has-info .d-focused .d-checkbox-visual {
-webkit-box-shadow: 0 0 6px #5ea5c8;
-moz-box-shadow: 0 0 6px #5ea5c8;
box-shadow: 0 0 6px #5ea5c8;
}
.has-info .d-focused .d-checkbox-visual-outer {
stroke: #31708f;
}
.has-warning .d-focused .d-checkbox-visual {
-webkit-box-shadow: 0 0 6px #c0a16b;
-moz-box-shadow: 0 0 6px #c0a16b;
box-shadow: 0 0 6px #c0a16b;
}
.has-warning .d-focused .d-checkbox-visual-outer {
stroke: #8a6d3b;
}
.has-error .d-focused .d-checkbox-visual {
-webkit-box-shadow: 0 0 6px #ce8483;
-moz-box-shadow: 0 0 6px #ce8483;
box-shadow: 0 0 6px #ce8483;
}
.has-error .d-focused .d-checkbox-visual-outer {
stroke: #a94442;
}
.d-checkbox > input[type=checkbox] {
/* The input is not stretched so that is spans
* all over the space available inside d-checkbox */
width: 100%;
height: 100%;
/* NOTE: we could have used opacity: 0 here but it breaks the focus */
opacity: .01;
position: absolute;
z-index: 1;
}
89 changes: 50 additions & 39 deletions Checkbox/themes/bootstrap/Checkbox.less
Original file line number Diff line number Diff line change
@@ -1,49 +1,60 @@
@import "../../../../delite/themes/common/mixins";
@import "../../../../delite/themes/bootstrap/variables";

.d-checkbox-styles () {
margin-left: 4px;
margin-right: 4px;
margin-top: 3px;
margin-bottom: 3px;
}

.d-checkbox-active-styles () {
}

.d-checkbox-focused () {
outline: thin dotted;
//WebKit
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
.d-checkbox {
margin-right: 4px;
}

.d-checkbox-before-styles () {
border-color: @input-border;
border-style: solid;
border-width: 1px;
border-radius: @input-border-radius;
background-image: linear-gradient(to bottom, #ededed 0%, #dedede 100%);
height: 1em;
width: 100%;
color: @input-color;
.d-checkbox-styles(@state) when (@state = normal) {
@size: round(.8*@font-size-base);
width: @size; height: @size;
&-inner {
fill: @input-color;
}
&-outer {
stroke: @input-border;
fill: white;
}
}

@d-checkbox-disabled-color: @input-bg-disabled;

.d-checkbox-checked-before-styles () {
.d-checkbox-styles(@state) when (@state = focused) {
@color-rgba: rgba(red(@input-border-focus), green(@input-border-focus), blue(@input-border-focus), .6);
/* NOTE: from http://github.com/twbs/bootstrap/blob/49519e9/less/mixins/forms.less#L56 */
.box-shadow(0 0 8px @color-rgba); // TODO: factorize into one CSS class
&-outer {
stroke: @input-border-focus;
}

/* interoperability with bootstrap validation states */
/* NOTE: from http://github.com/twbs/bootstrap/blob/49519e9/less/mixins/forms.less#L26 */
.has-state(@validation-state, @color) {
.has-@{validation-state} & {
.box-shadow(0 0 6px lighten(@color, 20%));
&-outer {
stroke: @color;
}
}
}

.has-state(success, @state-success-text);
.has-state(info, @state-info-text);
.has-state(warning, @state-warning-text);
.has-state(error, @state-danger-text);
}

.d-checkbox-before-disabled-styles () {
color: @btn-link-disabled-color;
background-color: @input-bg-disabled;
.d-checkbox-styles(@state) when (@state = disabled) {
&-outer {
fill: @input-bg-disabled;
}
&-inner {
fill: @btn-link-disabled-color;
}
}

.d-checkbox-input-styles () {
width:1em;
height:1em;
margin: 0px;
margin-top: 1px \9; /* IE8-9 */
/* interoperability with bootstrap form layouts */
.checkbox, .checkbox-inline {
.d-checkbox {
margin-left: -20px;
margin-right: 0;
position: absolute;
}
}

@import "../Checkbox_template";
@import "../Checkbox_template";
Loading