Skip to content

Commit

Permalink
feat(stark-ui): action Bar Component
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #481
  • Loading branch information
catlabs committed Jul 13, 2018
1 parent 34af0ae commit 5fc32cd
Show file tree
Hide file tree
Showing 51 changed files with 969 additions and 97 deletions.
2 changes: 1 addition & 1 deletion packages/stark-build/config/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"use-view-encapsulation": false,
"trackBy-function": true,
"no-unused-css": true,
"template-cyclomatic-complexity": [true, 5],
"template-cyclomatic-complexity": [true, 10],
"template-conditional-complexity": [true, 4],

// TSlint rules
Expand Down
15 changes: 15 additions & 0 deletions packages/stark-core/src/common/translations/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ export const translationsEn: object = {
SORTING: {
ASC: "Ascending",
DESC: "Descending"
},
ICONS: {
ADD_ITEM: "Add",
EDIT_ITEM: "Edit",
DELETE_ITEM: "Delete",
APPROVE_ITEM: "Approve",
REJECT_ITEM: "Reject",
RELOAD_PAGE: "Reload page",
OPEN_SELECTION: "Open selection",
SAVE_ITEM: "Save",
CLOSE_ITEM: "Close",
RESET: "Reset",
SEARCH: "Search",
NEW_ITEM: "New",
SAVE_AND_NEXT: "Save And Next"
}
}
};
15 changes: 15 additions & 0 deletions packages/stark-core/src/common/translations/translations/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ export const translationsFr: object = {
SORTING: {
ASC: "Ascendant",
DESC: "Descendant"
},
ICONS: {
ADD_ITEM: "Ajouter",
EDIT_ITEM: "Modifier",
DELETE_ITEM: "Supprimer",
APPROVE_ITEM: "Approuver",
REJECT_ITEM: "Rejeter",
RELOAD_PAGE: "Recharger la page",
OPEN_SELECTION: "Ouvrir la sélection",
SAVE_ITEM: "Sauver",
CLOSE_ITEM: "Fermer",
RESET: "Réinitialiser",
SEARCH: "Chercher",
NEW_ITEM: "Nouveau",
SAVE_AND_NEXT: "Sauver et Suivant"
}
}
};
15 changes: 15 additions & 0 deletions packages/stark-core/src/common/translations/translations/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ export const translationsNl: object = {
SORTING: {
ASC: "Oplopend",
DESC: "Aflopend"
},
ICONS: {
ADD_ITEM: "Toevoegen",
EDIT_ITEM: "Wijzig",
DELETE_ITEM: "Verwijder",
APPROVE_ITEM: "Goedkeuren",
REJECT_ITEM: "Afkeuren",
RELOAD_PAGE: "Pagina vernieuwen",
OPEN_SELECTION: "Open selectie",
SAVE_ITEM: "Bewaren",
CLOSE_ITEM: "Sluiten",
RESET: "Reset",
SEARCH: "Zoeken",
NEW_ITEM: "Nieuw",
SAVE_AND_NEXT: "Bewaar en volgende"
}
}
};
6 changes: 1 addition & 5 deletions packages/stark-ui/assets/styles/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
}

@media screen {
html,
body {
overflow: hidden;
}

.stark-app {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -68,6 +63,7 @@ body {
/* system sans-serif font stack */
font-family: mat-font-family($typography-config);
font-size: mat-font-size($typography-config, body-1);
line-height: mat-line-height($typography-config, body-1);
}

h1,
Expand Down
6 changes: 6 additions & 0 deletions packages/stark-ui/assets/styles/_colors.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
$mat-light-theme-background: $backgrounds;
$mat-light-theme-foreground: $foregrounds;

@if variable-exists(stark-base-theme) {
$base-theme: map-merge($base-theme, $stark-base-theme);

@if map-has-key($stark-base-theme, backgrounds) {
$mat-light-theme-background: map-merge($backgrounds, map-get($stark-base-theme, backgrounds));
}

@if map-has-key($stark-base-theme, foregrounds) {
$mat-light-theme-foreground: map-merge($foregrounds, map-get($stark-base-theme, foregrounds));
}
}

$stark-color-theme: mat-light-theme(
Expand Down
8 changes: 8 additions & 0 deletions packages/stark-ui/assets/styles/_media-queries.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$tablet-query: "(min-width: 600px)";
$tablet-screen-query: "screen and (min-width: 600px)";
$desktop-query: "(min-width: 960px)";
$desktop-screen-query: "screen and (min-width: 960px)";
$mobile-only-query: "(max-width: 599px)";
$mobile-only-screen-query: "screen and (max-width: 599px)";
$tablet-only-query: "(min-width: 600px) and (max-width: 959px)";
$tablet-only-screen-query: "screen and (min-width: 600px) and (max-width: 959px)";
10 changes: 0 additions & 10 deletions packages/stark-ui/assets/styles/_old-variables.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// Old Stark vars
$tablet-query: "(min-width: 600px)";
$tablet-screen-query: "screen and (min-width: 600px)";
$desktop-query: "(min-width: 960px)";
$desktop-screen-query: "screen and (min-width: 960px)";
$mobile-only-query: "(max-width: 599px)";
$mobile-only-screen-query: "screen and (max-width: 599px)";
$tablet-only-query: "(min-width: 600px) and (max-width: 959px)";
$tablet-only-screen-query: "screen and (min-width: 600px) and (max-width: 959px)";

$elevation-1: 0 1px 3px 0 rgba(0, 0, 0, 0.2), 0 1px 1px 0 rgba(0, 0, 0, 0.14), 0 2px 1px -1px rgba(0, 0, 0, 0.12);
$elevation-2: 0 1px 5px 0 rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.12);
$elevation-3: 0 1px 8px 0 rgba(0, 0, 0, 0.2), 0 3px 4px 0 rgba(0, 0, 0, 0.14), 0 3px 3px -2px rgba(0, 0, 0, 0.12);
Expand Down
2 changes: 1 addition & 1 deletion packages/stark-ui/assets/styles/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $typography-config: mat-typography-config(
$display-1: mat-typography-level-create(map-get($typography-theme, display-1)),
$headline: mat-typography-level-create(map-get($typography-theme, headline)),
$title: mat-typography-level-create(map-get($typography-theme, title)),
$subheading-2: mat-typography-level-create(map-get($typography-theme, subheading-2)),
$subheading-2: mat-typography-level-create(map-get($typography-theme, subheading-2)), /*Menu, List, Option*/
$subheading-1: mat-typography-level-create(map-get($typography-theme, subheading-1)),
$body-2: mat-typography-level-create(map-get($typography-theme, body-2)),
$body-1: mat-typography-level-create(map-get($typography-theme, body-1)),
Expand Down
4 changes: 2 additions & 2 deletions packages/stark-ui/assets/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ $typography-theme: (
500
),
subheading-2: (
13px,
16px,
28px,
400
500
),
subheading-1: (
15px,
Expand Down
10 changes: 10 additions & 0 deletions packages/stark-ui/assets/themes/_button-theme.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
@mixin stark-button-color($color) {
color: $color;
.mat-button-focus-overlay {
background-color: rgba($color: $color, $alpha: 0.12);
}
.mat-ripple-element {
background-color: rgba($color: $color, $alpha: 0.1);
}
}

@if variable-exists(stark-button-theme) {
$button-theme: map-merge($button-theme, $stark-button-theme);
}
Expand Down
13 changes: 13 additions & 0 deletions packages/stark-ui/assets/themes/_menu-theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.mat-menu-content .mat-menu-item {
color: mat-color(map-get($base-theme, primary-palette));
.mat-icon {
color: inherit;
svg {
height: 20px;
width: 20px;
}
}
&[disabled] {
color: map-get($mat-light-theme-foreground, disabled-button);
}
}
1 change: 1 addition & 0 deletions packages/stark-ui/assets/themes/_theming.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
@import "../styles/variables";
@import "../styles/colors";
@import "../styles/typography";
@import "../styles/media-queries";
@import "../styles/old-variables";
@import "../styles/base";
1 change: 1 addition & 0 deletions packages/stark-ui/src/modules.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./modules/action-bar";
export * from "./modules/app-logo";
export * from "./modules/slider";
export * from "./modules/svg-view-box";
2 changes: 2 additions & 0 deletions packages/stark-ui/src/modules/action-bar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./action-bar/action-bar.module";
export * from "./action-bar/components";
13 changes: 13 additions & 0 deletions packages/stark-ui/src/modules/action-bar/action-bar.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { MatButtonModule, MatIconModule, MatMenuModule, MatTooltipModule } from "@angular/material";
import { StarkSvgViewBoxModule } from "../svg-view-box/svg-view-box.module";
import { StarkActionBarComponent } from "./components";
import { TranslateModule } from "@ngx-translate/core";

@NgModule({
declarations: [StarkActionBarComponent],
imports: [BrowserModule, StarkSvgViewBoxModule, MatButtonModule, MatIconModule, MatMenuModule, MatTooltipModule, TranslateModule],
exports: [StarkActionBarComponent]
})
export class StarkActionBarModule {}
3 changes: 3 additions & 0 deletions packages/stark-ui/src/modules/action-bar/components.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./components/action-bar.component";
export * from "./components/action.intf";
export * from "./components/action-bar-config.intf";
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.stark-action-bar {
.mat-icon-button {
@include stark-button-color(mat-color(map-get($base-theme, primary-palette)));
}
&.stark-action-bar-full {
background-color: rgba(0, 0, 0, 0.85);
color: rgba(255, 255, 255, 0.8);
.mat-icon-button {
@include stark-button-color(rgba($color: #fff, $alpha: 0.8));
}
.action-label {
&.disabled {
color: rgba($color: #fff, $alpha: 0.25);
}
}
}
}

@media #{$tablet-query} {
.stark-action-bar {
color: $md-primary;
&.stark-action-bar-full {
background: none;
color: mat-color(map-get($base-theme, primary-palette));
.mat-icon-button:not([disabled]) {
@include stark-button-color(mat-color(map-get($base-theme, primary-palette)));
}
[disabled].mat-icon-button {
@include stark-button-color(map-get($mat-light-theme-foreground, disabled-button));
}
.action-label {
&.disabled {
color: map-get($mat-light-theme-foreground, disabled-button);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.stark-action-bar {
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
max-height: 40px;
overflow: hidden;
transform-origin: bottom;
.action-bar-wrapper {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.mat-icon-button {
.mat-icon svg {
height: 20px;
width: 20px;
}
}
&.stark-action-bar-full {
bottom: 0;
left: 0;
margin-bottom: 0;
padding: 4px 0;
position: fixed;
right: 0;
z-index: 4;
&.extended {
transition: 0.3s ease;
height: auto;
max-height: 280px;
overflow-y: scroll;
.action-bar-wrapper {
display: flex;
align-items: flex-start;
flex-direction: column;
flex-wrap: nowrap;
}
}
.action-label {
font-size: 13px;
padding-left: 15px;
}
}
}

@media #{$tablet-query} {
.stark-action-bar {
position: relative;
height: auto;
transition: 0.7s ease;
&.stark-action-bar-full {
position: relative;
&.extended {
max-height: 900px;
}
}
}
.stark-action-bar-compact {
flex-wrap: nowrap;
padding: 0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { StarkAction } from "./action.intf";

/**
* Stark Action interface
*/
export interface StarkActionBarConfig {
/**
* Array of actions (StarkAction config objects) to be included in the action bar
*/
actions: StarkAction[];

/**
* If false, then action bar will not be present on the page (optional)
*/
isPresent?: boolean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div *ngIf="(actionBarConfig.isPresent === undefined || actionBarConfig.isPresent === true)" class="stark-action-bar"
[ngClass]="{'extended': isExtended, 'stark-action-bar-full': mode === 'full', 'stark-action-bar-compact': mode === 'compact'}" [id]="actionBarId">
<div class="action-bar-wrapper">
<div *ngFor="let action of actionBarConfig.actions; trackBy: trackAction" [id]="actionBarId + '-' + action.id"
(click)="onClick(action, $event)" class="stark-action-bar--action">
<ng-container *ngIf="action.isVisible !== false">
<button [ngClass]="action.className" [matTooltip]="action.labelSwitchFunction ? action.labelActivated : action.label" [disabled]="!action.isEnabled" mat-icon-button>
<mat-icon starkSvgViewBox [svgIcon]="action.iconSwitchFunction ? action.iconActivated : action.icon"></mat-icon>
</button>
<label class="action-label" [ngClass]="{'disabled': !action.isEnabled}" *ngIf="isExtended" translate>{{ action.label }}</label>
</ng-container>
</div>
</div>

<div *ngIf="mode === 'full' || alternativeActions" class="alt-actions">
<button class="extend-action-bar" mat-icon-button *ngIf="mode === 'full'" (click)="toggleExtendedActionBar()">
<mat-icon starkSvgViewBox svgIcon="dots-horizontal"></mat-icon>
</button>
<button class="open-alt-actions" mat-icon-button *ngIf="alternativeActions" [matMenuTriggerFor]="menu">
<mat-icon starkSvgViewBox svgIcon="dots-vertical"></mat-icon>
</button>
<mat-menu #menu="matMenu" xPosition="before">
<div *ngFor="let action of alternativeActions; trackBy: trackAction" mat-menu-item [id]="actionBarId + '-alt-' + action.id" [disabled]="!action.isEnabled"
(click)="onClick(action, $event)">
<ng-container *ngIf="action.isVisible !== false">
<div [ngClass]="action.className">
<mat-icon starkSvgViewBox [svgIcon]="action.icon"></mat-icon>
<span translate>{{ action.label }}</span>
</div>
</ng-container>
</div>
</mat-menu>
</div>
</div>
Loading

0 comments on commit 5fc32cd

Please sign in to comment.