From 90ad47583623608128d22afe4d0ec221900e7ebf Mon Sep 17 00:00:00 2001
From: Brandy Carney
Date: Fri, 4 Dec 2015 15:44:37 -0500
Subject: [PATCH] refactor(button): changed button attributes to classes
references #689
---
ionic/components/button/button-clear.scss | 6 +-
ionic/components/button/button-outline.scss | 38 +++-----
ionic/components/button/button-size.scss | 25 ++---
ionic/components/button/button.scss | 91 ++++++++++++++++++-
ionic/components/button/test/basic/main.html | 20 ++--
ionic/components/button/test/block/main.html | 24 ++---
ionic/components/button/test/clear/main.html | 24 ++---
ionic/components/button/test/full/main.html | 16 ++--
.../components/button/test/outline/main.html | 32 +++----
ionic/components/button/test/round/main.html | 20 ++--
ionic/components/button/test/sizes/main.html | 24 ++---
11 files changed, 195 insertions(+), 125 deletions(-)
diff --git a/ionic/components/button/button-clear.scss b/ionic/components/button/button-clear.scss
index 408b77cc41..59b158a131 100644
--- a/ionic/components/button/button-clear.scss
+++ b/ionic/components/button/button-clear.scss
@@ -3,8 +3,7 @@
// Clear Button
// --------------------------------------------------
-button[clear],
-[button][clear] {
+.button-clear {
border-color: transparent;
background: transparent;
color: color-shade($button-color);
@@ -29,8 +28,7 @@ button[clear],
$fg-color: color-shade($color-value);
- button[clear][#{$color-name}],
- [button][clear][#{$color-name}] {
+ .button-clear-#{$color-name} {
border-color: transparent;
background: transparent;
color: $fg-color;
diff --git a/ionic/components/button/button-outline.scss b/ionic/components/button/button-outline.scss
index 0203fce104..3ec1f0a476 100644
--- a/ionic/components/button/button-outline.scss
+++ b/ionic/components/button/button-outline.scss
@@ -3,21 +3,16 @@
// Outline Button
// --------------------------------------------------
-button,
-[button] {
+.button-outline {
+ border: 1px solid $button-color;
+ background: transparent;
+ color: $button-color;
- &[outline] {
- border: 1px solid $button-color;
- background: transparent;
- color: $button-color;
-
- &.activated {
- opacity: 1;
- color: $background-color;
- background-color: $button-color;
- }
+ &.activated {
+ opacity: 1;
+ color: $background-color;
+ background-color: $button-color;
}
-
}
@@ -26,15 +21,13 @@ button,
@mixin button-outline($fg-color) {
- &[outline] {
- border-color: $fg-color;
- background: transparent;
- color: $fg-color;
+ border-color: $fg-color;
+ background: transparent;
+ color: $fg-color;
- &.activated {
- color: $background-color;
- background-color: $fg-color;
- }
+ &.activated {
+ color: $background-color;
+ background-color: $fg-color;
}
}
@@ -45,8 +38,7 @@ button,
@each $color-name, $color-value in auxiliary-colors() {
- button[#{$color-name}],
- [button][#{$color-name}] {
+ .button-outline-#{$color-name} {
$fg-color: color-shade($color-value, 5%);
@include button-outline($fg-color);
diff --git a/ionic/components/button/button-size.scss b/ionic/components/button/button-size.scss
index 3f68bd9844..646d1f3c32 100644
--- a/ionic/components/button/button-size.scss
+++ b/ionic/components/button/button-size.scss
@@ -12,19 +12,14 @@ $button-small-height: 2.1em !default;
$button-small-padding: 0.9em !default;
-button,
-[button] {
-
- &[large] {
- padding: 0 $button-large-padding;
- min-height: $button-large-height;
- font-size: $button-large-font-size;
- }
-
- &[small] {
- padding: 0 $button-small-padding;
- min-height: $button-small-height;
- font-size: $button-small-font-size;
- }
-
+.button-large {
+ padding: 0 $button-large-padding;
+ min-height: $button-large-height;
+ font-size: $button-large-font-size;
+}
+
+.button-small {
+ padding: 0 $button-small-padding;
+ min-height: $button-small-height;
+ font-size: $button-small-font-size;
}
diff --git a/ionic/components/button/button.scss b/ionic/components/button/button.scss
index 24f490093e..b4350f1a0a 100644
--- a/ionic/components/button/button.scss
+++ b/ionic/components/button/button.scss
@@ -14,9 +14,7 @@ $button-color-activated: color-shade($button-color) !default;
$button-text-color: inverse($button-color) !default;
$button-hover-opacity: 0.8 !default;
-
-button,
-[button] {
+.button {
position: relative;
display: inline-flex;
flex-shrink: 0;
@@ -44,8 +42,95 @@ button,
cursor: pointer;
@include user-select-none();
@include appearance(none);
+
+ // Button Types
+ // --------------------------------------------------
+
+ .button-block {
+ display: flex;
+ clear: both;
+ margin-right: 0;
+ margin-left: 0;
+ width: 100%;
+
+ &:after {
+ clear: both;
+ }
+ }
+
+ .button-full {
+ width: 100%;
+ margin-right: 0;
+ margin-left: 0;
+ border-radius: 0;
+ border-right-width: 0;
+ border-left-width: 0;
+ }
+
+ .button-round {
+ border-radius: $button-round-border-radius;
+ padding: $button-round-padding;
+ }
+
+ .button-disabled {
+ opacity: 0.4;
+ cursor: default !important;
+ pointer-events: none;
+ }
}
a[button] {
text-decoration: none;
}
+
+
+// TODO
+// button should have classes:
+// button, button-primary, button-secondary, etc.
+// button holds all styling with default primary color(will this affect outline/clear?) and
+// the other classes change the color
+//
+// button-clear should have classes:
+// button-clear, button-clear-primary, button-clear-secondary, etc.
+// button-clear holds all clear styling with default primary color and
+// the other classes change the color
+//
+// button-outline should have classes:
+// button-outline, button-outline-primary, button-outline-secondary, etc.
+// button-outline holds all outline styling with default primary color and
+// the other classes change the color
+//
+// button-block should stand alone
+// button-full should stand alone
+// button-round should stand alone
+// button-disabled should stand alone(?)
+// button-sizes should stand alone (button-small, button-large, etc)
+// button-fab errrrr
+
+
+// Default Button Color Mixin
+// --------------------------------------------------
+
+@mixin button-default($bg-color, $bg-color-activated, $text-color) {
+ background-color: $bg-color;
+ color: $text-color;
+
+ &.activated {
+ background-color: $bg-color-activated;
+ }
+}
+
+
+// Generate Default Button Colors
+// --------------------------------------------------
+
+@each $color-name, $color-value in $colors {
+
+ .button-#{$color-name} {
+ $bg-color: $color-value;
+ $bg-color-activated: color-shade($bg-color);
+ $text-color: inverse($bg-color);
+ @include button-default($bg-color, $bg-color-activated, $text-color);
+ }
+
+}
diff --git a/ionic/components/button/test/basic/main.html b/ionic/components/button/test/basic/main.html
index 28341090bb..74d078849e 100644
--- a/ionic/components/button/test/basic/main.html
+++ b/ionic/components/button/test/basic/main.html
@@ -11,28 +11,28 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/ionic/components/button/test/block/main.html b/ionic/components/button/test/block/main.html
index b99513a59d..389c58a396 100644
--- a/ionic/components/button/test/block/main.html
+++ b/ionic/components/button/test/block/main.html
@@ -6,33 +6,33 @@
- a[button][block]
-
+ a[button].button-block
+
- a[button][block] icon
-
+ a[button].button-block icon
+
- a[button][block][outline][secondary]
-
+ a[button].button-block.button-outline-secondary
+
- a[button][block][clear][dark]
-
+ a[button].button-block.button-clear-dark
+
- a[button][block][round]
-
+ a[button].button-block.button-round
+
- a[button][block][round][outline]
-
+ a[button].button-block.button-round.button-outline
+
diff --git a/ionic/components/button/test/clear/main.html b/ionic/components/button/test/clear/main.html
index eaf85b301a..2b3181ed21 100644
--- a/ionic/components/button/test/clear/main.html
+++ b/ionic/components/button/test/clear/main.html
@@ -6,33 +6,33 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/ionic/components/button/test/full/main.html b/ionic/components/button/test/full/main.html
index 15590211b5..30c2e902d4 100644
--- a/ionic/components/button/test/full/main.html
+++ b/ionic/components/button/test/full/main.html
@@ -6,23 +6,23 @@
diff --git a/ionic/components/button/test/outline/main.html b/ionic/components/button/test/outline/main.html
index 04b4037645..b2c5d69247 100644
--- a/ionic/components/button/test/outline/main.html
+++ b/ionic/components/button/test/outline/main.html
@@ -6,49 +6,49 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
diff --git a/ionic/components/button/test/round/main.html b/ionic/components/button/test/round/main.html
index f90d2f7b70..c163f7cdac 100644
--- a/ionic/components/button/test/round/main.html
+++ b/ionic/components/button/test/round/main.html
@@ -4,17 +4,17 @@
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
diff --git a/ionic/components/button/test/sizes/main.html b/ionic/components/button/test/sizes/main.html
index 0db997df5a..5f9fff318d 100644
--- a/ionic/components/button/test/sizes/main.html
+++ b/ionic/components/button/test/sizes/main.html
@@ -11,23 +11,23 @@
- a[button][small]
-
+ a[button].button-small
+
- a[button][outline][small]
-
+ a[button].button-outline.button-small
+
- a[button][clear][small]
-
+ a[button].button-clear.button-small
+
-
-
+
+
H
E
L
@@ -36,13 +36,13 @@
- a[button][outline][large]
-
+ a[button].button-outline.button-large
+
- a[clear][large]
-
+ a.button-clear.button-large
+