[AAE-5660] Reduce SCSS mixins and use CSS variables instead (#2255)

* optimise create menu theme

* optimise details component

* optimise sidenav component

* optimise search input theme

* optimise template dialog theme
This commit is contained in:
Denys Vuika
2021-08-11 14:31:30 +01:00
committed by GitHub
parent cd2aa173b8
commit 016bc0ac81
11 changed files with 244 additions and 299 deletions

View File

@@ -1,8 +1,3 @@
@mixin app-create-menu-theme($theme) {
$foreground: map-get($theme, foreground);
$accent: map-get($theme, accent);
$primary: map-get($theme, primary);
.app-create-menu:focus { .app-create-menu:focus {
outline: none; outline: none;
} }
@@ -15,8 +10,8 @@
display: block; display: block;
box-shadow: none !important; box-shadow: none !important;
height: 37.5px; height: 37.5px;
background-color: mat-color($accent); background-color: var(--theme-accent-color);
color: mat-color($primary, default-contrast) !important; color: var(--theme-primary-color-default-contrast);
border-radius: 4px; border-radius: 4px;
font-size: 12.7px; font-size: 12.7px;
font-weight: normal; font-weight: normal;
@@ -25,7 +20,7 @@
.mat-icon { .mat-icon {
width: 24px; width: 24px;
height: 25px; height: 25px;
color: mat-color($primary, default-contrast) !important; color: var(--theme-primary-color-default-contrast);
} }
&__text { &__text {
@@ -49,10 +44,10 @@
&--collapsed { &--collapsed {
outline: none; outline: none;
color: mat-color($foreground, secondary-text); color: var(--theme-secondary-text-color);
cursor: pointer; cursor: pointer;
&:hover { &:hover {
color: mat-color($accent); color: var(--theme-accent-color);
} }
margin: 0; margin: 0;
border: none; border: none;
@@ -60,7 +55,7 @@
} }
.app-create-menu--icon { .app-create-menu--icon {
color: mat-color($accent); color: var(--theme-accent-color);
} }
&__sub-menu { &__sub-menu {
@@ -69,7 +64,7 @@
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
font-size: 14px; font-size: 14px;
color: mat-color($foreground, secondary-text); color: var(--theme-secondary-text-color);
line-height: 48px; line-height: 48px;
box-shadow: none; box-shadow: none;
transform: none; transform: none;
@@ -77,17 +72,16 @@
font-weight: normal; font-weight: normal;
&:hover { &:hover {
color: mat-color($primary); color: var(--theme-primary-color);
} }
} }
.mat-menu-item[disabled], .mat-menu-item[disabled],
.mat-menu-item[disabled]:hover { .mat-menu-item[disabled]:hover {
color: mat-color($foreground, text, 0.38); color: var(--theme-text-disabled-color);
.mat-icon { .mat-icon {
color: mat-color($foreground, text, 0.38); color: var(--theme-text-disabled-color);
}
} }
} }
} }

View File

@@ -34,6 +34,7 @@ import { AppExtensionService } from '@alfresco/aca-shared';
@Component({ @Component({
selector: 'app-create-menu', selector: 'app-create-menu',
templateUrl: './create-menu.component.html', templateUrl: './create-menu.component.html',
styleUrls: ['./create-menu.component.scss'],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
host: { class: 'app-create-menu' } host: { class: 'app-create-menu' }
}) })

View File

@@ -1,8 +1,5 @@
@mixin app-details-theme($theme) {
$background: map-get($theme, background);
.acs-details-container { .acs-details-container {
background-color: mat-color($background, card); background-color: var(--theme-card-background-color);
width: 100%; width: 100%;
} }
@@ -42,4 +39,3 @@
font-weight: 100; font-weight: 100;
} }
} }
}

View File

@@ -35,6 +35,7 @@ import { Subject } from 'rxjs';
@Component({ @Component({
selector: 'app-details-manager', selector: 'app-details-manager',
templateUrl: './details.component.html', templateUrl: './details.component.html',
styleUrls: ['./details.component.scss'],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class DetailsComponent extends PageComponent implements OnInit, OnDestroy { export class DetailsComponent extends PageComponent implements OnInit, OnDestroy {

View File

@@ -4,20 +4,15 @@ $search-background: #f5f6f5;
$search-border-radius: 4px; $search-border-radius: 4px;
$top-margin: 12px; $top-margin: 12px;
@mixin aca-search-input-theme($theme) {
$background: map-get($theme, background);
$foreground: map-get($theme, foreground);
$border: 1px solid mat-color($foreground, divider, 0.07);
.app-search-container { .app-search-container {
color: mat-color($foreground, text, 0.72); color: var(--theme-foreground-text-color);
.app-input-form-field { .app-input-form-field {
.mat-input-element { .mat-input-element {
caret-color: mat-color($foreground, text, 0.54); caret-color: var(--theme-text-color);
&:disabled { &:disabled {
color: mat-color($foreground, text, 0.54); color: var(--theme-text-color);
} }
} }
} }
@@ -29,18 +24,27 @@ $top-margin: 12px;
.app-search-options-menu { .app-search-options-menu {
&.mat-menu-panel { &.mat-menu-panel {
background-color: mat-color($background, dialog); background-color: var(--theme-dialog-background-color);
width: $search-width;
max-width: unset;
border-radius: $search-border-radius;
margin-top: $top-margin;
}
.mat-menu-content:not(:empty) {
padding-top: 0;
padding-bottom: 0;
} }
} }
#search-options { #search-options {
color: mat-color($foreground, text, 0.54); color: var(--theme-text-color);
border-top: $border; border-top: 1px solid var(--theme-divider-color);
} }
mat-checkbox { mat-checkbox {
.mat-checkbox-frame { .mat-checkbox-frame {
border-color: mat-color($foreground, text, 0.54); border-color: var(--theme-text-color);
}
} }
} }
@@ -62,20 +66,6 @@ $top-margin: 12px;
margin-top: -$top-margin; margin-top: -$top-margin;
} }
.app-search-options-menu {
&.mat-menu-panel {
width: $search-width;
max-width: unset;
border-radius: $search-border-radius;
margin-top: $top-margin;
}
.mat-menu-content:not(:empty) {
padding-top: 0;
padding-bottom: 0;
}
}
#search-options { #search-options {
padding: 20px 0; padding: 20px 0;
font-size: 16px; font-size: 16px;
@@ -107,7 +97,7 @@ $top-margin: 12px;
padding-left: 17px; padding-left: 17px;
} }
@media screen and ($mat-small) { @media screen and (max-width: 959px) {
$search-width-small: 400px; $search-width-small: 400px;
.aca-search-input { .aca-search-input {
@@ -141,7 +131,7 @@ $top-margin: 12px;
} }
} }
@media screen and ($mat-xsmall) { @media screen and (max-width: 599px) {
$search-width-xsmall: 220px; $search-width-xsmall: 220px;
.aca-search-input { .aca-search-input {

View File

@@ -39,6 +39,7 @@ import { SearchLibrariesQueryBuilderService } from '../search-libraries-results/
@Component({ @Component({
selector: 'aca-search-input', selector: 'aca-search-input',
templateUrl: './search-input.component.html', templateUrl: './search-input.component.html',
styleUrls: ['./search-input.component.scss'],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
host: { class: 'aca-search-input' } host: { class: 'aca-search-input' }
}) })

View File

@@ -6,11 +6,26 @@
overflow-y: hidden; overflow-y: hidden;
} }
.aca-menu-panel {
.action-button--active {
color: var(--theme-accent-color) !important;
}
.action-button {
color: var(--theme-primary-color);
}
.action-button:hover {
color: var(--theme-accent-color);
}
}
.sidenav { .sidenav {
display: flex; display: flex;
flex: 1; flex: 1;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
background-color: var(--theme-background-color);
.section:last-child { .section:last-child {
border-bottom: 0; border-bottom: 0;
@@ -34,6 +49,7 @@
.section { .section {
padding: 8px 6px; padding: 8px 6px;
border-bottom: 1px solid var(--theme-divider-color);
} }
.section--collapsed { .section--collapsed {
@@ -60,6 +76,14 @@
width: 100%; width: 100%;
} }
.action-button--active {
color: var(--theme-primary-color) !important;
}
.action-button {
color: var(--theme-text-color);
}
.action-button .action-button__label { .action-button .action-button__label {
margin: 0 8px !important; margin: 0 8px !important;
} }
@@ -82,14 +106,25 @@
user-select: none; user-select: none;
} }
.item:hover .action-button__label {
color: var(--theme-primary-color);
}
.mat-expansion-panel-header { .mat-expansion-panel-header {
padding: 0 8px 0 0 !important; padding: 0 8px 0 0 !important;
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 14px !important;
} }
.mat-expansion-panel { .mat-expansion-panel {
width: 100%; width: 100%;
background-color: unset;
box-shadow: none !important;
}
.mat-expansion-panel:not(.mat-expanded) .mat-expansion-panel-header:not([aria-disabled='true']):hover {
background: none !important;
} }
.mat-expansion-indicator { .mat-expansion-indicator {

View File

@@ -1,58 +0,0 @@
@mixin sidenav-component-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$foreground: map-get($theme, foreground);
$background: map-get($theme, background);
$border: 1px solid mat-color($foreground, divider, 0.07);
.aca-menu-panel {
.action-button--active {
color: mat-color($accent) !important;
}
.action-button {
color: mat-color($primary);
}
.action-button:hover {
color: mat-color($accent);
}
}
.sidenav {
background-color: mat-color($background, background);
.item:hover .action-button__label {
color: mat-color($primary);
}
.mat-expansion-panel {
background-color: unset;
}
.mat-expansion-panel {
box-shadow: none !important;
}
.mat-expansion-panel:not(.mat-expanded) .mat-expansion-panel-header:not([aria-disabled='true']):hover {
background: none !important;
}
.mat-expansion-panel-header {
font-size: 14px !important;
}
.action-button--active {
color: mat-color($primary) !important;
}
.action-button {
color: mat-color($foreground, text, 0.54);
}
.section {
border-bottom: $border;
}
}
}

View File

@@ -1,9 +1,3 @@
@mixin app-create-from-template-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$foreground: map-get($theme, foreground);
$background: map-get($theme, background);
.aca-create-from-template-dialog { .aca-create-from-template-dialog {
ng-component { ng-component {
overflow: visible; overflow: visible;
@@ -17,7 +11,7 @@
font-stretch: normal; font-stretch: normal;
line-height: 1.6; line-height: 1.6;
letter-spacing: -0.5px; letter-spacing: -0.5px;
color: mat-color($foreground, text, 0.87); color: var(--theme-text-bold-color);
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
@@ -45,7 +39,7 @@
padding: 8px 22px; padding: 8px 22px;
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
color: mat-color($foreground, secondary-text); color: var(--theme-secondary-text-color);
button { button {
text-transform: uppercase; text-transform: uppercase;
@@ -57,8 +51,7 @@
} }
.create:enabled { .create:enabled {
color: mat-color($accent); color: var(--theme-accent-color);
}
} }
} }
} }

View File

@@ -33,6 +33,7 @@ import { TranslationService } from '@alfresco/adf-core';
@Component({ @Component({
templateUrl: './create-from-template.dialog.html', templateUrl: './create-from-template.dialog.html',
styleUrls: ['./create-from-template.dialog.scss'],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class CreateFromTemplateDialogComponent implements OnInit { export class CreateFromTemplateDialogComponent implements OnInit {

View File

@@ -1,14 +1,6 @@
@import '~@angular/material/theming'; @import '~@angular/material/theming';
@import '~@alfresco/adf-content-services/theming'; @import '~@alfresco/adf-content-services/theming';
@import '../components/sidenav/sidenav.component.theme';
@import '../components/search/search-input/search-input.component.theme';
@import '../components/create-menu/create-menu.component.scss';
@import '../dialogs/node-template/create-from-template.dialog.scss';
@import '../components/details/details.component.scss';
@import './overrides/adf-style-fixes.theme'; @import './overrides/adf-style-fixes.theme';
@import 'colors'; @import 'colors';
@include mat-core(); @include mat-core();
@@ -27,12 +19,6 @@ $primary: map-get($custom-theme, primary);
@include angular-material-theme($theme); @include angular-material-theme($theme);
@include adf-content-services-theme($theme); @include adf-content-services-theme($theme);
@include adf-core-theme($theme); @include adf-core-theme($theme);
@include aca-search-input-theme($theme);
@include sidenav-component-theme($theme);
@include app-create-from-template-theme($theme);
@include app-details-theme($theme);
@include app-create-menu-theme($theme);
@include adf-style-fixes($theme); @include adf-style-fixes($theme);
.mat-toolbar { .mat-toolbar {
@@ -69,8 +55,10 @@ $adf-permission-list-width: 100%;
$defaults: ( $defaults: (
--theme-primary-color: mat-color($primary), --theme-primary-color: mat-color($primary),
--theme-primary-color-default-contrast: mat-color($primary, default-contrast),
--theme-warn-color: mat-color($warn), --theme-warn-color: mat-color($warn),
--theme-accent-color: mat-color($accent), --theme-accent-color: mat-color($accent),
--theme-background-color: mat-color($background, background),
--theme-text-color: mat-color($foreground, text, 0.54), --theme-text-color: mat-color($foreground, text, 0.54),
--theme-text-bold-color: mat-color($foreground, text, 0.87), --theme-text-bold-color: mat-color($foreground, text, 0.87),
--theme-title-color: mat-color($foreground, text, 0.87), --theme-title-color: mat-color($foreground, text, 0.87),
@@ -79,7 +67,10 @@ $defaults: (
--header-background-image: url('/assets/images/mastHead-bg-shapesPattern.svg'), --header-background-image: url('/assets/images/mastHead-bg-shapesPattern.svg'),
--theme-card-background-color: mat-color($background, card), --theme-card-background-color: mat-color($background, card),
--theme-foreground-text-color: mat-color($foreground, text, 0.72), --theme-foreground-text-color: mat-color($foreground, text, 0.72),
--theme-foreground-text-bold-color: mat-color($foreground, text, 0.87) --theme-foreground-text-bold-color: mat-color($foreground, text, 0.87),
--theme-secondary-text-color: mat-color($foreground, secondary-text),
--theme-divider-color: mat-color($foreground, divider, 0.07),
--theme-dialog-background-color: mat-color($background, dialog)
); );
// propagates SCSS variables into the CSS variables scope // propagates SCSS variables into the CSS variables scope