From c69a13d039f314bd1a425d1905242db3e10a6bf6 Mon Sep 17 00:00:00 2001 From: ClientCrash <40364569+ClientCrash@users.noreply.github.com> Date: Sun, 6 Mar 2022 11:20:17 +0100 Subject: [PATCH] Added Button Base Component (#275) --- .../styled-button.component.html | 1 + .../styled-button.component.scss | 59 +++++++++++++++++++ .../styled-button.component.spec.ts | 25 ++++++++ .../styled-button/styled-button.component.ts | 17 ++++++ 4 files changed, 102 insertions(+) create mode 100644 src/app/design/styled-button/styled-button.component.html create mode 100644 src/app/design/styled-button/styled-button.component.scss create mode 100644 src/app/design/styled-button/styled-button.component.spec.ts create mode 100644 src/app/design/styled-button/styled-button.component.ts diff --git a/src/app/design/styled-button/styled-button.component.html b/src/app/design/styled-button/styled-button.component.html new file mode 100644 index 00000000..a8821237 --- /dev/null +++ b/src/app/design/styled-button/styled-button.component.html @@ -0,0 +1 @@ + diff --git a/src/app/design/styled-button/styled-button.component.scss b/src/app/design/styled-button/styled-button.component.scss new file mode 100644 index 00000000..1175d014 --- /dev/null +++ b/src/app/design/styled-button/styled-button.component.scss @@ -0,0 +1,59 @@ +@use "sass:list"; +@import "theme-colors"; + +$flavors: ( + primary: ( + $primary-default, + $primary-hover, + $primary-disabled, + ), + success: ( + $success-default, + $success-hover, + $success-disabled, + ), + warning: ( + $warning-default, + $warning-hover, + $warning-disabled, + ), + danger: ( + $danger-default, + $danger-hover, + $danger-disabled, + ), + info: ( + $info-default, + $info-hover, + $info-disabled, + ), +); + +button { + padding: 10px; + border-radius: 10px; + width: 100%; + color: white; + border: none; + font-size: 16px; + margin-right: 10px; + &:last-child { + margin-right: 0; + } + + @each $name, $colors in $flavors { + &.#{$name} { + color: #2f2f36; + background: list.nth($colors, 1); + + &:disabled { + background-color: list.nth($colors, 3); + } + + &:hover { + background-color: list.nth($colors, 2); + color: white; + } + } + } +} diff --git a/src/app/design/styled-button/styled-button.component.spec.ts b/src/app/design/styled-button/styled-button.component.spec.ts new file mode 100644 index 00000000..ca36cb31 --- /dev/null +++ b/src/app/design/styled-button/styled-button.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { StyledButtonComponent } from './styled-button.component'; + +describe('StyledButtonComponent', () => { + let component: StyledButtonComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ StyledButtonComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(StyledButtonComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/design/styled-button/styled-button.component.ts b/src/app/design/styled-button/styled-button.component.ts new file mode 100644 index 00000000..f3521984 --- /dev/null +++ b/src/app/design/styled-button/styled-button.component.ts @@ -0,0 +1,17 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; + +export type ButtonFlavor = 'primary' | 'success' | 'warning' | 'danger' | 'info'; + +@Component({ + selector: 'app-styled-button', + templateUrl: './styled-button.component.html', + styleUrls: ['./styled-button.component.scss'] +}) +export class StyledButtonComponent { + + @Input() public disabled = false; + @Input() public flavor: ButtonFlavor = 'primary'; + + // tslint:disable-next-line: no-output-on-prefix + @Output() public onClick = new EventEmitter(); +}