summaryrefslogtreecommitdiff
path: root/resources/src/mediawiki.ui/components/checkbox.less
diff options
context:
space:
mode:
Diffstat (limited to 'resources/src/mediawiki.ui/components/checkbox.less')
-rw-r--r--resources/src/mediawiki.ui/components/checkbox.less120
1 files changed, 73 insertions, 47 deletions
diff --git a/resources/src/mediawiki.ui/components/checkbox.less b/resources/src/mediawiki.ui/components/checkbox.less
index e39646bc..4829f5f6 100644
--- a/resources/src/mediawiki.ui/components/checkbox.less
+++ b/resources/src/mediawiki.ui/components/checkbox.less
@@ -11,27 +11,42 @@
//
// Markup:
// <div class="mw-ui-checkbox">
-// <input type="checkbox" id="kss-example-5"><label for="kss-example-5">Standard checkbox</label>
+// <input type="checkbox" id="kss-example-3">
+// <label for="kss-example-3">Standard checkbox</label>
// </div>
// <div class="mw-ui-checkbox">
-// <input type="checkbox" id="kss-example-5-2" disabled><label for="kss-example-5-2">Disabled checkbox</label>
+// <input type="checkbox" id="kss-example-3-checked" checked>
+// <label for="kss-example-3-checked">Standard checked checkbox</label>
+// </div>
+// <div class="mw-ui-checkbox">
+// <input type="checkbox" id="kss-example-3-disabled" disabled>
+// <label for="kss-example-3-disabled">Disabled checkbox</label>
+// </div>
+// <div class="mw-ui-checkbox">
+// <input type="checkbox" id="kss-example-3-disabled-checked" disabled checked>
+// <label for="kss-example-3-disabled-checked">Disabled checked checkbox</label>
// </div>
//
-// Styleguide 5.
+// Styleguide 3.
.mw-ui-checkbox {
display: inline-block;
vertical-align: middle;
}
-@checkboxSize: 24px;
+@checkboxSize: 2em;
// We use the not selector to cancel out styling on IE 8 and below
-.mw-ui-checkbox:not(#noop) {
+// We also disable this styling on javascript disabled devices. This fixes the issue with
+// Opera Mini where checking/unchecking doesn't apply styling but potentially leaves other
+// more capable browsers with unstyled checkboxes.
+.client-js .mw-ui-checkbox:not(#noop) {
// Position relatively so we can make use of absolute pseudo elements
position: relative;
- line-height: @checkboxSize;
+ display: table;
* {
+ // reset font sizes (see bug 72727)
+ font: inherit;
vertical-align: middle;
}
@@ -42,59 +57,70 @@
// ensure the invisible checkbox takes up the required width
width: @checkboxSize;
height: @checkboxSize;
+ // This is needed for Firefox mobile (See bug 71750 to workaround default Firefox stylesheet)
+ max-width: none;
+ margin: 0;
+ margin-right: 0.4em;
+ display: table-cell;
- // the pseudo before element of the label after the checkbox now looks like a checkbox
& + label {
- cursor: pointer;
+ display: table-cell;
+ }
- &::before {
- content: '';
- position: absolute;
- left: 0;
- display: inline-block;
- border-radius: @borderRadius;
- margin-right: 18px;
- width: @checkboxSize;
- height: @checkboxSize;
- background-color: #fff;
- border: 1px solid grey;
- }
+ // the pseudo before element of the label after the checkbox now looks like a checkbox
+ & + label::before {
+ .transition( 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) );
+ content: '';
+ cursor: pointer;
+ .box-sizing(border-box);
+ position: absolute;
+ left: 0;
+ border-radius: @borderRadius;
+ width: @checkboxSize;
+ height: @checkboxSize;
+ line-height: @checkboxSize;
+ background-color: #fff;
+ border: 1px solid @colorGray7;
+ // align the checkbox to middle of the text
+ top: 50%;
+ margin-top: -1em;
+ .background-image-svg('images/checked.svg', 'images/checked.png');
+ .background-size( @checkboxSize - 0.2em, @checkboxSize - 0.2em );
+ background-repeat: no-repeat;
+ background-position: center center;
+ background-origin: border-box;
+ background-size: 0 0;
}
// when the input is checked, style the label pseudo before element that followed as a checked checkbox
- &:checked {
- + label {
- &::before {
- .background-image-svg('images/checked.svg', 'images/checked.png');
- background-repeat: no-repeat;
- background-position: center top;
- }
- }
+ &:checked + label::before {
+ background-size: 100% 100%;
+ }
+
+ &:active + label::before {
+ background-color: @colorGray13;
+ border-color: @colorGray13;
}
- @focusBottomBorderSize: 3px;
- &:active,
- &:focus {
- + label {
- &::after {
- content: '';
- position: absolute;
- width: @checkboxSize;
- height: @checkboxSize - @focusBottomBorderSize + 1; // offset by bottom border
- // offset from the checkbox by 1px to account for left border
- left: 1px;
- border-bottom: solid @focusBottomBorderSize lightgrey;
- }
- }
+ &:focus + label::before {
+ border-width: 2px;
}
- // disabled checked boxes have a gray background
- &:disabled + label {
+ &:focus:hover + label::before,
+ &:hover + label::before {
+ border-bottom-width: 3px;
+ }
+
+ // disabled checkboxes have a gray background
+ &:disabled + label::before {
cursor: default;
+ background-color: @colorGray14;
+ border-color: @colorGray14;
+ }
- &::before {
- background-color: lightgrey;
- }
+ // disabled and checked checkboxes have a white circle
+ &:disabled:checked + label::before {
+ .background-image-svg('images/checked_disabled.svg', 'images/checked_disabled.png');
}
}
}