mediawiki.ui: Add radio buttons
authorPrateek Saxena <prtksxna@gmail.com>
Wed, 5 Nov 2014 10:33:57 +0000 (16:03 +0530)
committerPrateek Saxena <prtksxna@gmail.com>
Wed, 26 Nov 2014 04:50:18 +0000 (10:20 +0530)
Design specification on Trello-
https://trello.com/c/df2N2KJx/8-radio-buttons

Change-Id: Idb3d5177b6b2e9374de02416447fee9286e10a65

docs/kss/Makefile
resources/Resources.php
resources/src/mediawiki.ui/components/images/radio_checked.png [new file with mode: 0644]
resources/src/mediawiki.ui/components/images/radio_checked.svg [new file with mode: 0644]
resources/src/mediawiki.ui/components/images/radio_disabled.png [new file with mode: 0644]
resources/src/mediawiki.ui/components/images/radio_disabled.svg [new file with mode: 0644]
resources/src/mediawiki.ui/components/radio.less [new file with mode: 0644]

index a28bf3e..31feec1 100644 (file)
@@ -6,7 +6,7 @@ kss: kssnodecheck
        $(eval KSS_RL_TMP := $(shell mktemp /tmp/tmp.XXXXXXXXXX))
 # Keep module names in strict alphabetical order, so CSS loads in the same order as ResourceLoader's addModuleStyles does; this can affect rendering.
 # See OutputPage::makeResourceLoaderLink.
-       @curl -sG "${MEDIAWIKI_LOAD_URL}?modules=mediawiki.legacy.commonPrint|mediawiki.legacy.shared|mediawiki.ui|mediawiki.ui.anchor|mediawiki.ui.button|mediawiki.ui.checkbox|mediawiki.ui.icon|mediawiki.ui.input|mediawiki.ui.text&only=styles" > $(KSS_RL_TMP)
+       @curl -sG "${MEDIAWIKI_LOAD_URL}?modules=mediawiki.legacy.commonPrint|mediawiki.legacy.shared|mediawiki.ui|mediawiki.ui.anchor|mediawiki.ui.button|mediawiki.ui.checkbox|mediawiki.ui.radio|mediawiki.ui.icon|mediawiki.ui.input|mediawiki.ui.text&only=styles" > $(KSS_RL_TMP)
        @node_modules/.bin/kss-node ../../resources/src/mediawiki.ui static/ --css $(KSS_RL_TMP) -t styleguide-template
        @rm $(KSS_RL_TMP)
 
index c39ba3b..88965d0 100644 (file)
@@ -1524,6 +1524,15 @@ return array(
                'position' => 'top',
                'targets' => array( 'desktop', 'mobile' ),
        ),
+       'mediawiki.ui.radio' => array(
+               'skinStyles' => array(
+                       'default' => array(
+                               'resources/src/mediawiki.ui/components/radio.less',
+                       ),
+               ),
+               'position' => 'top',
+               'targets' => array( 'desktop', 'mobile' ),
+       ),
        // Lightweight module for anchor styles
        'mediawiki.ui.anchor' => array(
                'skinStyles' => array(
diff --git a/resources/src/mediawiki.ui/components/images/radio_checked.png b/resources/src/mediawiki.ui/components/images/radio_checked.png
new file mode 100644 (file)
index 0000000..1361ba6
Binary files /dev/null and b/resources/src/mediawiki.ui/components/images/radio_checked.png differ
diff --git a/resources/src/mediawiki.ui/components/images/radio_checked.svg b/resources/src/mediawiki.ui/components/images/radio_checked.svg
new file mode 100644 (file)
index 0000000..8a57732
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->\r
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\r
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\r
+        viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">\r
+<circle fill="#00AF89" cx="12" cy="12" r="6"/>\r
+</svg>\r
diff --git a/resources/src/mediawiki.ui/components/images/radio_disabled.png b/resources/src/mediawiki.ui/components/images/radio_disabled.png
new file mode 100644 (file)
index 0000000..5a1959f
Binary files /dev/null and b/resources/src/mediawiki.ui/components/images/radio_disabled.png differ
diff --git a/resources/src/mediawiki.ui/components/images/radio_disabled.svg b/resources/src/mediawiki.ui/components/images/radio_disabled.svg
new file mode 100644 (file)
index 0000000..e062895
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->\r
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\r
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\r
+        viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">\r
+<circle fill="#ffffff" cx="12" cy="12" r="6"/>\r
+</svg>\r
diff --git a/resources/src/mediawiki.ui/components/radio.less b/resources/src/mediawiki.ui/components/radio.less
new file mode 100644 (file)
index 0000000..6d8978e
--- /dev/null
@@ -0,0 +1,109 @@
+@import "mediawiki.mixins";
+@import "mediawiki.ui/variables";
+
+// Radio
+//
+// Styling radios in a way that works cross browser is a tricky problem to solve.
+// In MediaWiki UI put a radio and label inside a mw-ui-radio div.
+// This renders in all browsers except IE6-8 which do not support the :checked selector;
+// these are kept backwards-compatible using the :not(#noop) selector.
+// You should give the radio and label matching "id" and "for" attributes, respectively.
+//
+// Markup:
+// <div class="mw-ui-radio">
+//   <input type="radio" id="kss-example-7" name="kss-example-7">
+//   <label for="kss-example-7">Standard radio</label>
+// </div>
+// <div class="mw-ui-radio">
+//   <input type="radio" id="kss-example-7-checked" name="kss-example-7" checked>
+//   <label for="kss-example-7-checked">Standard checked radio</label>
+// </div>
+// <div class="mw-ui-radio">
+//   <input type="radio" id="kss-example-7-disabled" name="kss-example-7-disabled" disabled>
+//   <label for="kss-example-7-disabled">Disabled radio</label>
+// </div>
+// <div class="mw-ui-radio">
+//   <input type="radio" id="kss-example-7-disabled-checked" name="kss-example-7-disabled" disabled checked>
+//   <label for="kss-example-7-disabled-checked">Disabled checked radio</label>
+// </div>
+//
+// Styleguide 7.
+.mw-ui-radio {
+       display: inline-block;
+       vertical-align: middle;
+}
+
+@radioSize: 2em;
+
+// We use the not selector to cancel out styling on IE 8 and below
+.mw-ui-radio:not(#noop) {
+       // Position relatively so we can make use of absolute pseudo elements
+       position: relative;
+       line-height: @radioSize;
+
+       * {
+               font: inherit;
+               vertical-align: middle;
+       }
+
+       input[type="radio"] {
+               // we hide the input element as instead we will style the label that follows
+               // we use opacity so that VoiceOver software can still identify it
+               opacity: 0;
+               // ensure the invisible radio takes up the required width
+               width: @radioSize;
+               height: @radioSize;
+               // This is needed for Firefox mobile (See bug 71750 to workaround default Firefox stylesheet)
+               max-width: none;
+               margin-right: 0.4em;
+
+               // the pseudo before element of the label after the radio now looks like a radio
+               & + label::before {
+                       cursor: pointer;
+                       content: '';
+                       .box-sizing(border-box);
+                       position: absolute;
+                       left: 0;
+                       border-radius: 100%;
+                       width: @radioSize;
+                       height: @radioSize;
+                       background-color: #fff;
+                       border: 1px solid @colorGray7;
+               }
+
+               // when the input is checked, style the label pseudo before element that followed as a checked radio
+               &:checked + label::before {
+                       .background-image-svg('images/radio_checked.svg', 'images/radio_checked.png');
+                       .background-size( @radioSize, @radioSize );
+                       background-repeat: no-repeat;
+                       background-position: center center;
+                       background-origin: border-box;
+               }
+
+               &:focus + label::before {
+                       border-width: 2px;
+               }
+
+               &:focus:hover + label::before,
+               &:hover + label::before {
+                       border-bottom-width: 3px;
+               }
+
+               &:active + label::before {
+                       background-color: @colorGray13;
+                       border-color: @colorGray13;
+               }
+
+               // disabled checked boxes have a gray background
+               &:disabled + label::before {
+                       cursor: default;
+                       border-color: @colorGray14;
+                       background-color: @colorGray14;
+               }
+
+               // disabled and checked boxes have a white circle
+               &:disabled:checked + label::before {
+                       .background-image-svg('images/radio_disabled.svg', 'images/radio_disabled.png');
+               }
+       }
+}