Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
Added Button Base Component (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClientCrash authored and Tristan-H11 committed Mar 21, 2022
1 parent 529d501 commit c69a13d
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/design/styled-button/styled-button.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<button [disabled]="disabled" (click)="onClick.emit($event)" [class]="flavor"><ng-content></ng-content></button>
59 changes: 59 additions & 0 deletions src/app/design/styled-button/styled-button.component.scss
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
25 changes: 25 additions & 0 deletions src/app/design/styled-button/styled-button.component.spec.ts
Original file line number Diff line number Diff line change
@@ -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<StyledButtonComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ StyledButtonComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(StyledButtonComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
17 changes: 17 additions & 0 deletions src/app/design/styled-button/styled-button.component.ts
Original file line number Diff line number Diff line change
@@ -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<MouseEvent>();
}

0 comments on commit c69a13d

Please sign in to comment.