From 5d5cac1abfce9fbcf516751e757172463810c9b9 Mon Sep 17 00:00:00 2001 From: Jenn Medellin <54321jenn@gmail.com> Date: Thu, 25 Jan 2018 15:34:04 -0800 Subject: [PATCH] feat(patterns): FAB design pattern (#1056) * feature()/fab pattern - add fab pattern - add stackblitz links * chore/fix error - fix error * feature(docs): fab pattern - add fab pattern - link to Stackblitz demo * chore()/update wording - modify guidance based on how we use it (per view, not application-wide) * chore()/fix lint fix lint error * feature(docs): fab pattern updates - remove unused CSS - fix dividers with [inset]="true" - update pattern description - fix iframe layout * feat(patterns): update FAB markup * chore(patterns): missing divider * fix(theme): lint issue --- .../design-patterns.component.ts | 5 + .../design-patterns/design-patterns.module.ts | 2 + .../design-patterns/design-patterns.routes.ts | 4 + .../design-patterns/fab/fab.component.html | 99 +++++++++++++++++++ .../design-patterns/fab/fab.component.scss | 0 .../design-patterns/fab/fab.component.ts | 23 +++++ .../steppers/steppers.component.html | 1 + src/theme.scss | 2 +- 8 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/app/components/design-patterns/fab/fab.component.html create mode 100644 src/app/components/design-patterns/fab/fab.component.scss create mode 100644 src/app/components/design-patterns/fab/fab.component.ts diff --git a/src/app/components/design-patterns/design-patterns.component.ts b/src/app/components/design-patterns/design-patterns.component.ts index db018875ed..49994fad4f 100644 --- a/src/app/components/design-patterns/design-patterns.component.ts +++ b/src/app/components/design-patterns/design-patterns.component.ts @@ -28,6 +28,11 @@ export class DesignPatternsComponent { icon: 'kitchen', route: 'navigation-drawer', title: 'Navigation Drawer Patterns', + }, { + description: 'Floating action button', + icon: 'add_circle', + route: 'fab', + title: 'FAB Patterns', }, { description: 'Wizard-like pattern', icon: 'looks_one', diff --git a/src/app/components/design-patterns/design-patterns.module.ts b/src/app/components/design-patterns/design-patterns.module.ts index 4c62f32bf9..30607886b9 100644 --- a/src/app/components/design-patterns/design-patterns.module.ts +++ b/src/app/components/design-patterns/design-patterns.module.ts @@ -9,6 +9,7 @@ import { CardsComponent } from './cards/cards.component'; import { AlertsComponent } from './alerts/alerts.component'; import { ManagementListComponent } from './management-list/management-list.component'; import { NavigationDrawerComponent } from './navigation-drawer/navigation-drawer.component'; +import { FABComponent } from './fab/fab.component'; import { SteppersComponent } from './steppers/steppers.component'; import { EmptyStatesComponent } from './empty-states/empty-states.component'; @@ -42,6 +43,7 @@ import { ToolbarModule } from '../../components/toolbar/toolbar.module'; AlertsComponent, ManagementListComponent, NavigationDrawerComponent, + FABComponent, SteppersComponent, EmptyStatesComponent, ], diff --git a/src/app/components/design-patterns/design-patterns.routes.ts b/src/app/components/design-patterns/design-patterns.routes.ts index 16e5514d2d..c24241fc9a 100644 --- a/src/app/components/design-patterns/design-patterns.routes.ts +++ b/src/app/components/design-patterns/design-patterns.routes.ts @@ -5,6 +5,7 @@ import { CardsComponent } from './cards/cards.component'; import { AlertsComponent } from './alerts/alerts.component'; import { ManagementListComponent } from './management-list/management-list.component'; import { NavigationDrawerComponent } from './navigation-drawer/navigation-drawer.component'; +import { FABComponent } from './fab/fab.component'; import { SteppersComponent } from './steppers/steppers.component'; import { EmptyStatesComponent } from './empty-states/empty-states.component'; @@ -21,6 +22,9 @@ const routes: Routes = [{ }, { component: NavigationDrawerComponent, path: 'navigation-drawer', + }, { + component: FABComponent, + path: 'fab', }, { component: SteppersComponent, path: 'steppers', diff --git a/src/app/components/design-patterns/fab/fab.component.html b/src/app/components/design-patterns/fab/fab.component.html new file mode 100644 index 0000000000..01900b2fb2 --- /dev/null +++ b/src/app/components/design-patterns/fab/fab.component.html @@ -0,0 +1,99 @@ +
+ + FAB Patterns + + +

When to use

+

The floating action button (FAB) provides access to the primary action for the current view.

+
+
+ + +
+ Example + + + launch + +
+
+ +
+
+

Usage

+ + +

Position

+

Bottom right for lists

+
+ + +

Color

+

Use theme accent color

+
+ + +

Tooltip

+

Include a tooltip for a11y

+
+ +
+

Guidelines

+ + + launch +

Material Design

+

FAB Guidelines

+
+ + + launch +

Angular Material

+

Button Component

+
+
+
+
+ +
+
+
+
+
+ + + Do. + + + + + looks_one +

Only one FAB per page

+
+ + looks_two +

Contextual primary action

+
+
+
+
+
+ + + Don't. + + + + + looks_one +

Don't use for negative actions like delete

+
+ + looks_3 +

Don't embellish with custom styles

+
+
+
+
+
+
diff --git a/src/app/components/design-patterns/fab/fab.component.scss b/src/app/components/design-patterns/fab/fab.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/components/design-patterns/fab/fab.component.ts b/src/app/components/design-patterns/fab/fab.component.ts new file mode 100644 index 0000000000..8600bd5f51 --- /dev/null +++ b/src/app/components/design-patterns/fab/fab.component.ts @@ -0,0 +1,23 @@ +import { Component, HostBinding } from '@angular/core'; +import { BrowserModule, DomSanitizer } from '@angular/platform-browser'; +import { slideInDownAnimation } from '../../../app.animations'; + +@Component({ + selector: 'fab', + styleUrls: ['./fab.component.scss'], + templateUrl: './fab.component.html', + animations: [ + slideInDownAnimation, + ], +}) +export class FABComponent { + + @HostBinding('@routeAnimation') routeAnimation: boolean = true; + @HostBinding('class.td-route-animation') classAnimation: boolean = true; + + source: any = ''; + + constructor(private sanitizer: DomSanitizer) { + this.source = sanitizer.bypassSecurityTrustResourceUrl('https://fab-patterns.stackblitz.io/'); + } +} diff --git a/src/app/components/design-patterns/steppers/steppers.component.html b/src/app/components/design-patterns/steppers/steppers.component.html index aef809350e..d78fcc7c10 100644 --- a/src/app/components/design-patterns/steppers/steppers.component.html +++ b/src/app/components/design-patterns/steppers/steppers.component.html @@ -55,6 +55,7 @@

Guidelines

Material Design

Stepper Guidelines

+ launch

Angular Material

diff --git a/src/theme.scss b/src/theme.scss index 1ddb088cdb..9a9001d868 100644 --- a/src/theme.scss +++ b/src/theme.scss @@ -110,7 +110,7 @@ $theme: mat-light-theme($primary, $accent, $warn); .tc-warn { color: mat-color($warn-alt); } - a:not([class^="mat-"]) { + a:not([class^='mat-']) { color: mat-color($accent-alt); &:hover { color: darken(mat-color($accent-alt), 10%);