Skip to content

Commit

Permalink
feat(styling): add extra SASS utilities and icon colors (#562)
Browse files Browse the repository at this point in the history
* feat(styling): add extra SASS utilities and icon colors
- add few colors CSS classes to help with coloring SVG icons, they simply add colors to icons via the CSS `filter` trick
  • Loading branch information
ghiscoding authored Aug 19, 2020
1 parent 0222d09 commit 529a15c
Show file tree
Hide file tree
Showing 16 changed files with 476 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h2 [innerHTML]="title"></h2>
<div class="row">
<div class="col-md-7">
<button (click)="addNewFile()" class="btn btn-info btn-sm">
<span class="icon mdi mdi-plus"></span>
<span class="icon mdi mdi-plus color-white"></span>
<span>Add New Pop Song</span>
</button>
<button (click)="collapseAll()" class="btn btn-default btn-sm">
Expand Down
38 changes: 20 additions & 18 deletions src/app/examples/grid-tree-data-hierarchical.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,25 @@ $icon-width-mdi-close-thick: 12px;
width: 1.5rem;
}

.icon.mdi-file-pdf-outline {
/** 1. use `filter` color */
// filter: invert(62%) sepia(93%) saturate(5654%) hue-rotate(325deg) brightness(100%) contrast(90%);
/** You can use the following code OR use the .color-x CSS classes */

/** 2. or use the SASS @mixin (from Angular-Slickgrid "sass-utilities.scss") that will produce the `filter` color */
@include recolor(#f14668, 0.9);
}
// .icon.mdi-file-pdf-outline {
// /** 1. use `filter` color */
// // filter: invert(62%) sepia(93%) saturate(5654%) hue-rotate(325deg) brightness(100%) contrast(90%);

.icon.mdi-folder, .icon.mdi-folder-open {
@include recolor(#ffa500, 0.9);
}
.icon.mdi-file-music-outline {
@include recolor(#3298dc, 0.9);
}
.icon.mdi-file-excel-outline {
@include recolor(#1E9F75, 0.9);
}
.icon.mdi-file-document-outline {
@include recolor(#686868, 0.9);
}
// /** 2. or use the SASS @mixin (from Angular-Slickgrid "sass-utilities.scss") that will produce the `filter` color */
// @include recolor(#f14668, 0.9);
// }

// .icon.mdi-folder, .icon.mdi-folder-open {
// @include recolor(#ffa500, 0.9);
// }
// .icon.mdi-file-music-outline {
// @include recolor(#3298dc, 0.9);
// }
// .icon.mdi-file-excel-outline {
// @include recolor(#1E9F75, 0.9);
// }
// .icon.mdi-file-document-outline {
// @include recolor(#686868, 0.9);
// }
10 changes: 5 additions & 5 deletions src/app/examples/grid-tree-data-hierarchical.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class GridTreeDataHierarchicalComponent implements OnInit {
const spacer = `<span style="display:inline-block; width:${(15 * dataContext[treeLevelPropName])}px;"></span>`;

if (data[idx + 1] && data[idx + 1][treeLevelPropName] > data[idx][treeLevelPropName]) {
const folderPrefix = `<span class="mdi icon ${dataContext.__collapsed ? 'mdi-folder' : 'mdi-folder-open'}"></span>`;
const folderPrefix = `<span class="mdi icon color-alt-warning ${dataContext.__collapsed ? 'mdi-folder' : 'mdi-folder-open'}"></span>`;
if (dataContext.__collapsed) {
return `${spacer} <span class="slick-group-toggle collapsed" level="${dataContext[treeLevelPropName]}"></span>${folderPrefix} ${prefix}&nbsp;${value}`;
} else {
Expand All @@ -169,13 +169,13 @@ export class GridTreeDataHierarchicalComponent implements OnInit {
getFileIcon(value: string) {
let prefix = '';
if (value.includes('.pdf')) {
prefix = '<span class="mdi icon mdi-file-pdf-outline"></span>';
prefix = '<span class="mdi icon mdi-file-pdf-outline color-danger"></span>';
} else if (value.includes('.txt')) {
prefix = '<span class="mdi icon mdi-file-document-outline"></span>';
prefix = '<span class="mdi icon mdi-file-document-outline color-muted-light"></span>';
} else if (value.includes('.xls')) {
prefix = '<span class="mdi icon mdi-file-excel-outline"></span>';
prefix = '<span class="mdi icon mdi-file-excel-outline color-success"></span>';
} else if (value.includes('.mp3')) {
prefix = '<span class="mdi icon mdi-file-music-outline"></span>';
prefix = '<span class="mdi icon mdi-file-music-outline color-info"></span>';
}
return prefix;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h2 [innerHTML]="title"></h2>
<div class="row">
<div class="col-md-12">
<button (click)="addNewRow()" class="btn btn-info btn-sm">
<span class="icon mdi mdi-plus"></span>
<span class="icon mdi mdi-plus color-white"></span>
<span>Add New Item (in 1st group)</span>
</button>
<button (click)="collapseAll()" data-test="collapse-all" class="btn btn-default btn-sm">
Expand Down
10 changes: 6 additions & 4 deletions src/app/modules/angular-slickgrid/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ $column-picker-close-btn-padding: 0px !default;
$column-picker-close-btn-opacity: 0.9 !default;
$column-picker-close-btn-position-right: 5px !default;
$column-picker-close-btn-position-top: 0px !default;
$column-picker-padding-right-patch: 24px !default; /* trick to cheat the width to include extra scrollbar width in addition to auto width */
$column-picker-divider-width: calc(100% + #{$column-picker-padding-right-patch} - 10px) !default;
$column-picker-item-border: 1px solid transparent !default;
$column-picker-item-border-radius: 0px !default;
$column-picker-item-font-size: $icon-font-size !default;
Expand Down Expand Up @@ -330,7 +332,7 @@ $grid-menu-min-width: 200px !default;
$grid-menu-divider-height: 1px !default;
$grid-menu-divider-margin: 8px 5px !default;
$grid-menu-divider-color: #e7e7e7 !default;
$grid-menu-divider-width: calc(100% - 40px) !default;
$grid-menu-divider-width: calc(100% - 10px) !default;
$grid-menu-title-border-bottom: solid 1px #d6d6d6 !default;
$grid-menu-title-font-size: calc(#{$grid-menu-item-font-size} + 2px) !default;
$grid-menu-title-font-weight: normal !default;
Expand Down Expand Up @@ -368,7 +370,7 @@ $cell-menu-icon-width: 16px !default;
$cell-menu-divider-height: 1px !default;
$cell-menu-divider-margin: 8px 5px !default;
$cell-menu-divider-color: #e7e7e7 !default;
$cell-menu-divider-width: calc(100% - 40px) !default;
$cell-menu-divider-width: calc(100% - 10px) !default;
$cell-menu-option-list-margin-bottom: 10px !default;
$cell-menu-title-border-bottom: 1px solid #d6d6d6 !default;
$cell-menu-title-font-size: calc(#{$cell-menu-item-font-size} + 2px) !default;
Expand Down Expand Up @@ -406,7 +408,7 @@ $context-menu-icon-width: 16px !default;
$context-menu-divider-height: 1px !default;
$context-menu-divider-margin: 8px 5px !default;
$context-menu-divider-color: #e7e7e7 !default;
$context-menu-divider-width: calc(100% - 40px) !default;
$context-menu-divider-width: calc(100% - 10px) !default;
$context-menu-option-list-margin-bottom: 10px !default;
$context-menu-title-border-bottom: 1px solid #d6d6d6 !default;
$context-menu-title-font-size: calc(#{$context-menu-item-font-size} + 2px) !default;
Expand Down Expand Up @@ -448,7 +450,7 @@ $header-menu-icon-width: 16px !default;
$header-menu-divider-height: 1px !default;
$header-menu-divider-margin: 8px 3px !default;
$header-menu-divider-color: #e7e7e7 !default;
$header-menu-divider-width: 95% !default;
$header-menu-divider-width: calc(100% - 10px) !default;
$header-menu-display: none !default; /* can be none or inline-block */

/* Checkbox Selector / Row Selection */
Expand Down
66 changes: 66 additions & 0 deletions src/app/modules/angular-slickgrid/styles/colors.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@import './sass-utilities';

/* icon/text colors */
// we'll use the same color set as text-colors defined in Bootstrap 4 (ref: https://getbootstrap.com/docs/4.5/utilities/colors/)
// we also use the "recolor" @mixin to add CSS "filter" color on top of SVG icons

// NOTE: remember that we are using CSS "filter" and that is NOT the same as a using color/background-color, it behaves differently

$color-lighten-percentage: 6% !default;
$color-darken-percentage: 6% !default;

$color-primary: $primary-color !default;
$color-secondary: #6c757d !default;
$color-success: #28a745 !default;
$color-danger: #dc3545 !default;
$color-warning: #ffc107 !default;
$color-info: #17a2b8 !default;
$color-light: #f8f9fa !default;
$color-dark: #343a40 !default;
$color-body: #212529 !default;
$color-muted: #6c757d !default;
$color-white: #ffffff !default;
$color-alt-default: #1e87f0 !default;
$color-alt-warning: #faa05a !default;
$color-alt-danger: #f0506e !default;
$color-alt-success: #32d296 !default;

.color-primary { @include recolor($color-primary, 1); }
.color-secondary { @include recolor($color-secondary, 1); }
.color-success { @include recolor($color-success, 1); }
.color-danger { @include recolor($color-danger, 1); }
.color-warning { @include recolor($color-warning, 1); }
.color-info { @include recolor($color-info, 1); }
.color-light { @include recolor($color-light, 1); }
.color-dark { @include recolor($color-dark, 1); }
.color-body { @include recolor($color-body, 1); }
.color-muted { @include recolor($color-muted, 1); }
.color-white { @include recolor($color-white, 1); }
.color-alt-default { @include recolor($color-alt-default, 1); }
.color-alt-warning { @include recolor($color-alt-warning, 1); }
.color-alt-danger { @include recolor($color-alt-danger, 1); }
.color-alt-success { @include recolor($color-alt-success, 1); }
.color-primary-light { @include recolor(lighten($color-primary, $color-lighten-percentage), 1); }
.color-primary-dark { @include recolor(darken($color-primary, $color-darken-percentage), 1); }
.color-secondary-light { @include recolor(lighten($color-secondary, $color-lighten-percentage), 1); }
.color-secondary-dark { @include recolor(darken($color-secondary, $color-darken-percentage), 1); }
.color-success-light { @include recolor(lighten($color-success, $color-lighten-percentage), 1); }
.color-success-dark { @include recolor(darken($color-success, $color-darken-percentage), 1); }
.color-danger-light { @include recolor(lighten($color-danger, $color-lighten-percentage), 1); }
.color-danger-dark { @include recolor(darken($color-danger, $color-darken-percentage), 1); }
.color-warning-light { @include recolor(lighten($color-warning, $color-lighten-percentage), 1); }
.color-warning-dark { @include recolor(darken($color-warning, $color-darken-percentage), 1); }
.color-info-light { @include recolor(lighten($color-info, $color-lighten-percentage), 1); }
.color-info-dark { @include recolor(darken($color-info, $color-darken-percentage), 1); }
.color-body-light { @include recolor(lighten($color-body, $color-lighten-percentage), 1); }
.color-body-dark { @include recolor(darken($color-body, $color-darken-percentage), 1); }
.color-muted-light { @include recolor(lighten($color-muted, $color-lighten-percentage), 1); }
.color-muted-dark { @include recolor(darken($color-muted, $color-darken-percentage), 1); }
.color-alt-warning-light { @include recolor(lighten($color-alt-warning, $color-lighten-percentage), 1); }
.color-alt-warning-dark { @include recolor(darken($color-alt-warning, $color-darken-percentage), 1); }
.color-alt-default-light { @include recolor(lighten($color-alt-default, $color-lighten-percentage), 1); }
.color-alt-default-dark { @include recolor(darken($color-alt-default, $color-darken-percentage), 1); }
.color-alt-danger-light { @include recolor(lighten($color-alt-danger, $color-lighten-percentage), 1); }
.color-alt-danger-dark { @include recolor(darken($color-alt-danger, $color-darken-percentage), 1); }
.color-alt-success-light { @include recolor(lighten($color-alt-success, $color-lighten-percentage), 1); }
.color-alt-success-dark { @include recolor(darken($color-alt-success, $color-darken-percentage), 1); }
71 changes: 25 additions & 46 deletions src/app/modules/angular-slickgrid/styles/extra-styling.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
$editable-field-bg-color: #e3f0fb !default;
$unsaved-editable-field-color: #fbfdd1 !default;
$font-size-count: 50;

.pointer {
cursor: pointer;
}

.cell-effort-driven {
text-align: center;
}
.pointer { cursor: pointer; }
.bold { font-weight: bold; }

.grid-canvas {
.slick-row, .slick-row.odd {
Expand All @@ -20,7 +17,7 @@ $editable-field-bg-color: #e3f0fb !default;
background-color: $editable-field-bg-color
}
.unsaved-editable-field {
background-color: #fbfdd1 !important;
background-color: $unsaved-editable-field-color !important;
}

.fake-hyperlink {
Expand All @@ -43,45 +40,27 @@ $editable-field-bg-color: #e3f0fb !default;
}
}

.font-10px {
font-size: 10px;
}
.font-12px {
font-size: 12px;
}
.font-14px {
font-size: 14px;
}
.font-16px {
font-size: 16px;
}
.font-18px {
font-size: 18px;
// font-5px equals a font-size of 5px, from 5px to 50px
@for $i from 5 through $font-size-count {
.font-#{$i}px { font-size: #{$i}px; }
}
.font-20px {
font-size: 20px;
}
.font-22px {
font-size: 22px;
}
.font-24px {
font-size: 24px;
}
.font-26px {
font-size: 26px;
}
.font-28px {
font-size: 28px;
}
.font-30px {
font-size: 30px;
}
.font-32px {
font-size: 32px;

/* Text and Alignment Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-uppercase { text-transform: uppercase; }
.text-underline { text-decoration: underline; }

.vertical-align-bottom {
display: inline-block;
vertical-align: bottom;
}
.font-34px {
font-size: 34px;
.vertical-align-middle {
display: inline-block;
vertical-align: middle;
}
.font-36px {
font-size: 36px;
.vertical-align-top {
display: inline-block;
vertical-align: top;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$icon-width-size-count: 50;

@-webkit-keyframes md-spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
Expand Down Expand Up @@ -33,25 +35,8 @@
&.mdi-rotate-45, .mdi-rotate-90, .mdi-rotate-135, .mdi-rotate-180, .mdi-rotate-220 .mdi-rotate-270, .mdi-rotate-315 {
filter: none;
}
&.mdi-10px:before { width: 10px; }
&.mdi-12px:before { width: 12px; }
&.mdi-14px:before { width: 14px; }
&.mdi-16px:before { width: 16px; }
&.mdi-18px:before { width: 18px; }
&.mdi-20px:before { width: 20px; }
&.mdi-22px:before { width: 22px; }
&.mdi-24px:before { width: 24px; }
&.mdi-26px:before { width: 26px; }
&.mdi-28px:before { width: 28px; }
&.mdi-30px:before { width: 30px; }
&.mdi-32px:before { width: 32px; }
&.mdi-34px:before { width: 34px; }
&.mdi-36px:before { width: 36px; }
&.mdi-38px:before { width: 38px; }
&.mdi-40px:before { width: 40px; }
&.mdi-42px:before { width: 42px; }
&.mdi-44px:before { width: 44px; }
&.mdi-46px:before { width: 46px; }
&.mdi-48px:before { width: 48px; }
&.mdi-50px:before { width: 50px; }

@for $i from 5 through $icon-width-size-count {
&.mdi-#{$i}px:before { width: #{$i}px; }
}
}
11 changes: 10 additions & 1 deletion src/app/modules/angular-slickgrid/styles/slick-controls.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
overflow: auto;
resize: both;
width: auto;
padding-right: 24px; /* trick to cheat the width to include extra scrollbar width in addition to auto width */
padding-right: $column-picker-padding-right-patch; /* trick to cheat the width to include extra scrollbar width in addition to auto width */

> .close {
float: right;
Expand Down Expand Up @@ -100,6 +100,9 @@
margin: 6px 0;
border: 0;
border-top: 1px solid #d5d5d5;
width: $column-picker-divider-width;
margin-left: auto;
margin-right: auto;
}

/* replace checkboxes by Font-Awesome icons */
Expand Down Expand Up @@ -242,6 +245,9 @@
margin: $grid-menu-divider-margin;
background-color: $grid-menu-divider-color;
width: $grid-menu-divider-width;
margin-left: auto;
margin-right: auto;

&:hover {
border: none;
background-color: $grid-menu-item-disabled-color;
Expand Down Expand Up @@ -306,6 +312,9 @@
margin: 6px 0;
border: 0;
border-top: 1px solid #dddddd;
width: $grid-menu-divider-width;
margin-left: auto;
margin-right: auto;
}

/* replace checkboxes by Font-Awesome icons */
Expand Down
9 changes: 9 additions & 0 deletions src/app/modules/angular-slickgrid/styles/slick-plugins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
margin: $cell-menu-divider-margin;
background-color: $cell-menu-divider-color;
width: $cell-menu-divider-width;
margin-left: auto;
margin-right: auto;

&:hover {
border: none;
background-color: $cell-menu-divider-color;
Expand Down Expand Up @@ -193,6 +196,9 @@
margin: $context-menu-divider-margin;
background-color: $context-menu-divider-color;
width: $context-menu-divider-width;
margin-left: auto;
margin-right: auto;

&:hover {
border: none;
background-color: $context-menu-divider-color;
Expand Down Expand Up @@ -382,6 +388,9 @@
margin: $header-menu-divider-margin;
background-color: $header-menu-divider-color;
width: $header-menu-divider-width;
margin-left: auto;
margin-right: auto;

&:hover {
border: none;
background-color: $header-menu-item-disabled-color;
Expand Down
Loading

0 comments on commit 529a15c

Please sign in to comment.