From 41139cbd421ac342e92b1114555aabed9d548e86 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Wed, 18 Sep 2013 16:05:11 -0500 Subject: [PATCH] starting toggle --- scss/_variables.scss | 25 +++++++++++++++ scss/ionic.scss | 1 + scss/ionic/_button.scss | 1 - scss/ionic/_scaffolding.scss | 8 ++--- scss/ionic/_toggle.scss | 59 ++++++++++++++++++++++++++++++++++++ test/input-toggle.html | 25 +++++++++++++-- 6 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 scss/ionic/_toggle.scss diff --git a/scss/_variables.scss b/scss/_variables.scss index 5b46496535..67adb0d154 100644 --- a/scss/_variables.scss +++ b/scss/_variables.scss @@ -303,6 +303,31 @@ $info-bg: #d9edf7; $info-border: darken(adjust-hue($info-bg, -10), 7%); +// Toggle +// ------------------------------- + +$toggle-width: 54px; +$toggle-height: 32px; +$toggle-border-width: 2px; +$toggle-border-radius: 20px; + +$toggle-switch-width: $toggle-height - 4px; +$toggle-switch-height: $toggle-switch-width; +$toggle-switch-radius: 50%; +$toggle-switch-on-position: $toggle-width - $toggle-switch-width - ($toggle-border-width * 2); + +$toggle-off-bg-color: $gray-light; +$toggle-off-border-color: $toggle-off-bg-color; + +$toggle-on-bg-color: $blue-dark; +$toggle-on-border-color: $toggle-on-bg-color; + +$toggle-switch-off-bg-color: $white; +$toggle-switch-on-bg-color: $toggle-switch-off-bg-color; + +$toggle-transition-duration: .1s; + + // Menus // ------------------------------- diff --git a/scss/ionic.scss b/scss/ionic.scss index 4d22309c04..eb6e7e0bdc 100644 --- a/scss/ionic.scss +++ b/scss/ionic.scss @@ -32,6 +32,7 @@ "ionic/card", "ionic/form", "ionic/table", + "ionic/toggle", // Animations "ionic/animations"; diff --git a/scss/ionic/_button.scss b/scss/ionic/_button.scss index 94efa04d8e..13214cdfe1 100644 --- a/scss/ionic/_button.scss +++ b/scss/ionic/_button.scss @@ -20,7 +20,6 @@ &.button-block { display: block; margin: $button-block-margin; - width: 100%; } &.button-default { diff --git a/scss/ionic/_scaffolding.scss b/scss/ionic/_scaffolding.scss index 6d0b640849..cb8883b257 100644 --- a/scss/ionic/_scaffolding.scss +++ b/scss/ionic/_scaffolding.scss @@ -49,6 +49,10 @@ body { padding: $content-padding; } +.inset { + margin: $inset-margin; +} + // Pad top/bottom of content so it doesn't hide behind .bar-title and .bar-tab. // Note: For these to work, content must come after both bars in the markup .has-header { @@ -64,10 +68,6 @@ body { bottom: $tabs-height; } -.inset { - margin: $inset-margin; -} - .rounded { border-radius: $border-radius-base; } diff --git a/scss/ionic/_toggle.scss b/scss/ionic/_toggle.scss new file mode 100644 index 0000000000..383209319c --- /dev/null +++ b/scss/ionic/_toggle.scss @@ -0,0 +1,59 @@ + +/* the overall container of the toggle */ +.toggle { + display: inline-block; +} + +/* hide the actual checkbox */ +.toggle input { + display: none; +} + +/* the background of the toggle's slide area */ +/* also the appearance when the slide is "off" */ +.toggle .slide { + display: inline-block; + box-sizing: border-box; + width: $toggle-width; + height: $toggle-height; + border: solid $toggle-border-width $toggle-off-border-color; + border-radius: $toggle-border-radius; + background-color: $toggle-off-bg-color; + cursor: pointer; + + -webkit-transition-property: background-color, border; + -webkit-transition-duration: $toggle-transition-duration; + -webkit-transition-timing-function: ease-in-out; + + transition-property: background-color, border; + transition-duration: $toggle-transition-duration; + transition-timing-function: ease-in-out; +} + +/* the switch (dot) thats inside the toggle's slide area */ +/* also the appearance when the switch is "off" */ +.toggle .switch { + position: absolute; + display: block; + width: $toggle-switch-width; + height: $toggle-switch-height; + border-radius: $toggle-switch-radius; + background-color: $toggle-switch-off-bg-color; + -webkit-transition: -webkit-transform $toggle-transition-duration ease-in-out; + transition: -webkit-transform $toggle-transition-duration ease-in-out; +} + + +/* When the toggle is "on" */ +.toggle :checked + .slide { + + /* the slide when the toggle is "on" */ + border-color: $toggle-on-border-color; + background-color: $toggle-on-bg-color; + + /* the switch when the toggle is "on" */ + .switch { + background-color: $toggle-switch-on-bg-color; + -webkit-transform: translate3d($toggle-switch-on-position,0,0); + } +} diff --git a/test/input-toggle.html b/test/input-toggle.html index f359424f7b..c79530e29d 100644 --- a/test/input-toggle.html +++ b/test/input-toggle.html @@ -16,8 +16,29 @@

Input: Toggle

-
- todo +
+ +
    +
  • + Airplane Mode + +
  • +
  • + Do Not Disturb + +
  • +
+

Homepage