Skip to content

Commit

Permalink
feat(toolbox): the color of the toolbox can be chosen
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed Oct 30, 2019
1 parent 105c833 commit 5ad989f
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/common/src/lib/tool/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './tool.interface';
export * from './tool.service';
export * from './tool-component';
export * from './toolbox.enums';
export * from './toolbox';
5 changes: 5 additions & 0 deletions packages/common/src/lib/tool/shared/toolbox.enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum ToolboxColor {
White = 'white',
Grey = 'grey',
Primary = 'primary'
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}

.igo-tool-container-with-toolbar {
left: 51px;
left: 50px;
}

igo-actionbar {
Expand Down
31 changes: 28 additions & 3 deletions packages/common/src/lib/tool/toolbox/toolbox.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Input,
OnDestroy,
OnInit,
HostBinding,
ChangeDetectionStrategy
} from '@angular/core';

Expand All @@ -11,6 +12,7 @@ import { map } from 'rxjs/operators';

import { Action, ActionStore } from '../../action';
import { Tool } from '../shared/tool.interface';
import { ToolboxColor } from '../shared/toolbox.enums';
import { Toolbox } from '../shared/toolbox';
import { toolSlideInOut } from './toolbox.animation';

Expand All @@ -22,7 +24,6 @@ import { toolSlideInOut } from './toolbox.animation';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ToolboxComponent implements OnInit, OnDestroy {

/**
* Observable of the active tool
*/
Expand Down Expand Up @@ -82,6 +83,27 @@ export class ToolboxComponent implements OnInit, OnDestroy {
*/
@Input() animate: boolean = false;

/**
* Color of Toolbox
*/
@Input() color: ToolboxColor = ToolboxColor.White;

/**
* @ignore
*/
@HostBinding('class.color-grey')
get classColorGrey() {
return this.color === ToolboxColor.Grey;
}

/**
* @ignore
*/
@HostBinding('class.color-primary')
get classColorPrimary() {
return this.color === ToolboxColor.Primary;
}

/**
* Initialize the toolbar and subscribe to the active tool
* @internal
Expand Down Expand Up @@ -200,8 +222,11 @@ export class ToolboxComponent implements OnInit, OnDestroy {
}

let childrenToolActivated = false;
if (activeTool !== undefined && _tool.name === activeTool.parent) {
childrenToolActivated = true;
if (
activeTool !== undefined &&
_tool.name === activeTool.parent
) {
childrenToolActivated = true;
}

return {
Expand Down
47 changes: 42 additions & 5 deletions packages/common/src/lib/tool/toolbox/toolbox.theming.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,50 @@
@mixin igo-toolbox-theming($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);


igo-toolbox > igo-actionbar igo-actionbar-item mat-list-item.tool-activated {
background-color: mat-color($accent);
igo-toolbox > igo-actionbar mat-list.mat-list-base igo-actionbar-item mat-list-item {
&:hover {
background-color: mat-color($accent, lighter);
}

&.tool-activated,
&.children-tool-activated {
background-color: mat-color($accent);
cursor: default;
button {
cursor: default;
}
}
}


igo-toolbox.color-primary > igo-actionbar:not(.with-title) {
box-shadow: unset;
background-color: mat-color($primary)
}

igo-toolbox > igo-actionbar igo-actionbar-item mat-list-item.children-tool-activated {
background-color: mat-color($accent);
igo-toolbox.color-grey > igo-actionbar:not(.with-title) {
box-shadow: unset;
background-color: #737475;
}


igo-toolbox.color-primary,
igo-toolbox.color-grey {
& > igo-actionbar:not(.with-title) mat-list.mat-list-base {
.mat-list-item.mat-list-item-with-avatar {
color: white;
&:hover {
color: black;
}

&.tool-activated,
&.children-tool-activated {
background-color: white;
color: black;
}
}
}
}

}

0 comments on commit 5ad989f

Please sign in to comment.