Skip to content
This repository has been 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 MarcelCoding committed Mar 6, 2022
1 parent 1344edf commit 5724890
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 1 deletion.
31 changes: 31 additions & 0 deletions ComponentDocs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Cryptic Components


Style classes :
- primary
- success
- warning
- danger
- info

---

## Button

### Example

```html
<app-styled-button (click)="login()" flavor="primary" [disabled]="!form.valid">Log in</app-styled-button>
```

---

## Radio Button

### Example

```html
// ADD EXAMPLES FOR ALL THE DEFAULT COMPONENTS //
```

---
4 changes: 3 additions & 1 deletion src/app/design/design.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import {CommonModule} from '@angular/common';
import {ButtonComponent} from './button/button.component';
import {TextFieldComponent} from './text-field/text-field.component';
import {FormGroupComponent} from './form-group/form-group.component';
import {StyledButtonComponent} from './styled-button/styled-button.component';

@NgModule({
declarations: [
ButtonComponent,
TextFieldComponent,
FormGroupComponent
FormGroupComponent,
StyledButtonComponent
],
imports: [
CommonModule
Expand Down
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>();
}
24 changes: 24 additions & 0 deletions src/global-styles/_theme-colors.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*primary*/
$primary-default: #2ECC70;
$primary-hover: #1F8C4C;
$primary-disabled: #2E473E;
/*success*/
$success-default: #3ABB18;
$success-hover: #277A10;
$success-disabled: #2F5629;
/*warning*/
$warning-default: #F1C30E;
$warning-hover: #B3910B;
$warning-disabled: #675926;
/*danger*/
$danger-default: #F00040;
$danger-hover: #B0002F;
$danger-disabled: #671E35;
/*info*/
$info-default: #3281F6;
$info-hover: #245EB5;
$info-disabled: #2D456C;
/*etc*/
$logo-crypt: #27A036
/* ISSUE : #260 */

0 comments on commit 5724890

Please sign in to comment.