From 2225ace5be369ea0a132bbe08034da3049a40974 Mon Sep 17 00:00:00 2001 From: Sercan Yemen Date: Mon, 31 Jul 2017 12:24:41 +0300 Subject: [PATCH] color.scss generator refactor --- src/app/core/scss/partials/_colors.scss | 206 +++++++----------- .../sidenavs/main/main-sidenav.component.html | 4 +- .../sidenavs/main/main-sidenav.component.html | 4 +- src/app/main/apps/todo/todo.component.html | 2 +- src/app/main/ui/colors/colors.component.html | 2 +- .../fullwidth-2/fullwidth-2.component.html | 4 +- .../carded/fullwidth/fullwidth.component.html | 1 - .../left-sidenav-2.component.html | 6 +- .../left-sidenav/left-sidenav.component.html | 6 +- .../right-sidenav-2.component.html | 4 +- .../right-sidenav.component.html | 6 +- .../simple/fullwidth/fullwidth.component.html | 2 +- .../left-sidenav-2.component.html | 2 +- .../left-sidenav/left-sidenav.component.html | 2 +- .../right-sidenav-2.component.html | 2 +- .../right-sidenav.component.html | 2 +- .../simple/tabbed/tabbed.component.html | 2 +- 17 files changed, 106 insertions(+), 151 deletions(-) diff --git a/src/app/core/scss/partials/_colors.scss b/src/app/core/scss/partials/_colors.scss index 3dddc712..9dda2e02 100644 --- a/src/app/core/scss/partials/_colors.scss +++ b/src/app/core/scss/partials/_colors.scss @@ -1,30 +1,83 @@ +// Material colors map $matColorsMap: ( - red: $mat-red, - pink:$mat-pink, - purple:$mat-purple, - deep-purple:$mat-deep-purple, - indigo:$mat-indigo, - blue:$mat-blue, - light-blue:$mat-light-blue, - cyan:$mat-cyan, - teal:$mat-teal, - green:$mat-green, - light-green:$mat-light-green, - lime:$mat-lime, - yellow:$mat-yellow, - amber:$mat-amber, - orange:$mat-orange, - deep-orange:$mat-deep-orange, - brown:$mat-brown, - grey:$mat-grey, - blue-grey:$mat-blue-grey, - primary:$primary, - accent: $accent, - warn: $warn + red: $mat-red, + pink: $mat-pink, + purple: $mat-purple, + deep-purple: $mat-deep-purple, + indigo: $mat-indigo, + blue: $mat-blue, + light-blue: $mat-light-blue, + cyan: $mat-cyan, + teal: $mat-teal, + green: $mat-green, + light-green: $mat-light-green, + lime: $mat-lime, + yellow: $mat-yellow, + amber: $mat-amber, + orange: $mat-orange, + deep-orange: $mat-deep-orange, + brown: $mat-brown, + grey: $mat-grey, + blue-grey: $mat-blue-grey, + primary: $primary, + accent: $accent, + warn: $warn ); +// Material color hues list $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400, A700; +// Color classes generator mixin +@mixin generateColorClasses($colorName, $bgColor, $fgColor, $hue) { + + .#{$colorName}#{$hue}-bg { + background-color: $bgColor !important; + } + + .md-#{$colorName}#{$hue}-bg { + background-color: $bgColor !important; + color: $fgColor; + + .secondary-text { + color: rgba($fgColor, .7); + } + + .hint-text { + color: rgba($fgColor, .3); + } + + .fade-text { + color: rgba($fgColor, .12); + } + + } + + .#{$colorName}#{$hue}-fg { + color: $bgColor !important; + } + + .#{$colorName}#{$hue}-border { + border-color: $bgColor !important; + } + + .#{$colorName}#{$hue}-border-top { + border-top-color: $bgColor !important; + } + + .#{$colorName}#{$hue}-border-right { + border-right-color: $bgColor !important; + } + + .#{$colorName}#{$hue}-border-bottom { + border-bottom-color: $bgColor !important; + } + + .#{$colorName}#{$hue}-border-left { + border-left-color: $bgColor !important; + } +} + +// Generate the color classes... @each $colorName, $colorMap in $matColorsMap { @each $hue in $matColorHues { @@ -32,99 +85,11 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400 $bgColor: map-get($colorMap, $hue); $fgColor: map-get(map-get($colorMap, 'contrast'), $hue); - .#{$colorName}-#{$hue}-bg { - background-color: $bgColor !important; - } - - .md-#{$colorName}-#{$hue}-bg { - background-color: $bgColor !important; - color: $fgColor; - - .secondary-text { - color: rgba($fgColor, .7); - } - - .hint-text { - color: rgba($fgColor, .3); - } - - .fade-text { - color: rgba($fgColor, .12); - } - - } - - .#{$colorName}-#{$hue}-fg { - color: $bgColor !important; - } - - .#{$colorName}-#{$hue}-border { - border-color: $bgColor !important; - } - - .#{$colorName}-#{$hue}-border-top { - border-top-color: $bgColor !important; - } - - .#{$colorName}-#{$hue}-border-right { - border-right-color: $bgColor !important; - } - - .#{$colorName}-#{$hue}-border-bottom { - border-bottom-color: $bgColor !important; - } - - .#{$colorName}-#{$hue}-border-left { - border-left-color: $bgColor !important; - } + @include generateColorClasses($colorName, $bgColor, $fgColor, '-#{$hue}'); + // Run the generator one more time for default values (500) @if ($hue == 500) { - - .md-#{$colorName}-bg { - background-color: $bgColor !important; - color: $fgColor; - - .secondary-text { - color: rgba($fgColor, .7); - } - - .hint-text { - color: rgba($fgColor, .3); - } - - .fade-text { - color: rgba($fgColor, .12); - } - - } - - .#{$colorName}-bg { - background-color: $bgColor !important; - } - - .#{$colorName}-fg { - color: $bgColor !important; - } - - .#{$colorName}-border { - border-color: $bgColor !important; - } - - .#{$colorName}-border-top { - border-top-color: $bgColor !important; - } - - .#{$colorName}-border-right { - border-right-color: $bgColor !important; - } - - .#{$colorName}-border-bottom { - border-bottom-color: $bgColor !important; - } - - .#{$colorName}-border-left { - border-left-color: $bgColor !important; - } + @include generateColorClasses($colorName, $bgColor, $fgColor, ''); } } } @@ -147,7 +112,7 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400 .hint-text, &.disabled-text, .disabled-text { - color: rgba(0, 0, 0, 0.26) !important; + color: rgba(0, 0, 0, 0.38) !important; } &.divider, @@ -164,11 +129,7 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400 color: rgb(255, 255, 255) !important; &.secondary-text, - .secondary-text, - &.mat-icon, - .mat-icon, - &.icon, - .icon { + .secondary-text { color: rgba(255, 255, 255, 0.70) !important; } @@ -176,7 +137,7 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400 .hint-text, &.disabled-text, .disabled-text { - color: rgba(255, 255, 255, 0.30) !important; + color: rgba(255, 255, 255, 0.50) !important; } &.divider, @@ -186,9 +147,4 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400 color: rgba(255, 255, 255, 0.12) !important; } - // Angular material element color override - .mat-icon { - color: #FFFFFF; - } - } diff --git a/src/app/main/apps/mail/sidenavs/main/main-sidenav.component.html b/src/app/main/apps/mail/sidenavs/main/main-sidenav.component.html index 040b3808..f28c856a 100644 --- a/src/app/main/apps/mail/sidenavs/main/main-sidenav.component.html +++ b/src/app/main/apps/mail/sidenavs/main/main-sidenav.component.html @@ -1,7 +1,7 @@ -
+
diff --git a/src/app/main/apps/todo/sidenavs/main/main-sidenav.component.html b/src/app/main/apps/todo/sidenavs/main/main-sidenav.component.html index a7e8448e..bf652a66 100644 --- a/src/app/main/apps/todo/sidenavs/main/main-sidenav.component.html +++ b/src/app/main/apps/todo/sidenavs/main/main-sidenav.component.html @@ -1,7 +1,7 @@ -
+
diff --git a/src/app/main/apps/todo/todo.component.html b/src/app/main/apps/todo/todo.component.html index d2bf6100..044ee103 100644 --- a/src/app/main/apps/todo/todo.component.html +++ b/src/app/main/apps/todo/todo.component.html @@ -1,7 +1,7 @@
-
+
diff --git a/src/app/main/ui/colors/colors.component.html b/src/app/main/ui/colors/colors.component.html index 3ee816ac..afbcb104 100644 --- a/src/app/main/ui/colors/colors.component.html +++ b/src/app/main/ui/colors/colors.component.html @@ -1,7 +1,7 @@
-
+

Colors

-
+
-
+

Fullwidth with page scroll

diff --git a/src/app/main/ui/page-layouts/carded/fullwidth/fullwidth.component.html b/src/app/main/ui/page-layouts/carded/fullwidth/fullwidth.component.html index 4932e962..30340713 100644 --- a/src/app/main/ui/page-layouts/carded/fullwidth/fullwidth.component.html +++ b/src/app/main/ui/page-layouts/carded/fullwidth/fullwidth.component.html @@ -10,7 +10,6 @@

Fullwidth with content scroll

-
diff --git a/src/app/main/ui/page-layouts/carded/left-sidenav-2/left-sidenav-2.component.html b/src/app/main/ui/page-layouts/carded/left-sidenav-2/left-sidenav-2.component.html index 0021af6a..576e24fa 100644 --- a/src/app/main/ui/page-layouts/carded/left-sidenav-2/left-sidenav-2.component.html +++ b/src/app/main/ui/page-layouts/carded/left-sidenav-2/left-sidenav-2.component.html @@ -1,7 +1,7 @@
-
+
@@ -11,7 +11,7 @@ fuseMdSidenavHelper="carded-left-sidenav" md-is-locked-open="gt-md"> -
+

Sidenav header

@@ -29,7 +29,7 @@
-
+

Left sidenav with page scroll

diff --git a/src/app/main/ui/page-layouts/carded/left-sidenav/left-sidenav.component.html b/src/app/main/ui/page-layouts/carded/left-sidenav/left-sidenav.component.html index 3e39f3f0..4fbe7da7 100644 --- a/src/app/main/ui/page-layouts/carded/left-sidenav/left-sidenav.component.html +++ b/src/app/main/ui/page-layouts/carded/left-sidenav/left-sidenav.component.html @@ -1,7 +1,7 @@
-
+
@@ -11,7 +11,7 @@ fuseMdSidenavHelper="carded-left-sidenav" md-is-locked-open="gt-md"> -
+

Sidenav header

@@ -29,7 +29,7 @@
-
+

Left sidenav with content scroll

diff --git a/src/app/main/ui/page-layouts/carded/right-sidenav-2/right-sidenav-2.component.html b/src/app/main/ui/page-layouts/carded/right-sidenav-2/right-sidenav-2.component.html index 7c57fd9f..ca052e35 100644 --- a/src/app/main/ui/page-layouts/carded/right-sidenav-2/right-sidenav-2.component.html +++ b/src/app/main/ui/page-layouts/carded/right-sidenav-2/right-sidenav-2.component.html @@ -11,7 +11,7 @@ fuseMdSidenavHelper="carded-right-sidenav" md-is-locked-open="gt-md"> -
+

Sidenav header

@@ -29,7 +29,7 @@
-
+

Right sidenav with page scroll

diff --git a/src/app/main/ui/page-layouts/carded/right-sidenav/right-sidenav.component.html b/src/app/main/ui/page-layouts/carded/right-sidenav/right-sidenav.component.html index 9d2bedfa..df12b273 100644 --- a/src/app/main/ui/page-layouts/carded/right-sidenav/right-sidenav.component.html +++ b/src/app/main/ui/page-layouts/carded/right-sidenav/right-sidenav.component.html @@ -1,7 +1,7 @@
-
+
@@ -11,7 +11,7 @@ fuseMdSidenavHelper="carded-right-sidenav" md-is-locked-open="gt-md"> -
+

Sidenav header

@@ -29,7 +29,7 @@
-
+

Right sidenav with content scroll

diff --git a/src/app/main/ui/page-layouts/simple/fullwidth/fullwidth.component.html b/src/app/main/ui/page-layouts/simple/fullwidth/fullwidth.component.html index c0c8f050..b03eecd3 100644 --- a/src/app/main/ui/page-layouts/simple/fullwidth/fullwidth.component.html +++ b/src/app/main/ui/page-layouts/simple/fullwidth/fullwidth.component.html @@ -1,7 +1,7 @@
-
+

Fullwidth

diff --git a/src/app/main/ui/page-layouts/simple/left-sidenav-2/left-sidenav-2.component.html b/src/app/main/ui/page-layouts/simple/left-sidenav-2/left-sidenav-2.component.html index 3725f8f9..796caaf5 100644 --- a/src/app/main/ui/page-layouts/simple/left-sidenav-2/left-sidenav-2.component.html +++ b/src/app/main/ui/page-layouts/simple/left-sidenav-2/left-sidenav-2.component.html @@ -15,7 +15,7 @@
-
+