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

Commit e89f955

Browse files
ClientCrashTristan-H11
authored andcommitted
Added Button Base Component (#275)
1 parent 23d7599 commit e89f955

File tree

6 files changed

+157
-0
lines changed

6 files changed

+157
-0
lines changed

ComponentDocs.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Cryptic Components
2+
3+
4+
Style classes :
5+
- primary
6+
- success
7+
- warning
8+
- danger
9+
- info
10+
11+
---
12+
13+
## Button
14+
15+
### Example
16+
17+
```html
18+
<app-styled-button (click)="login()" flavor="primary" [disabled]="!form.valid">Log in</app-styled-button>
19+
```
20+
21+
---
22+
23+
## Radio Button
24+
25+
### Example
26+
27+
```html
28+
// ADD EXAMPLES FOR ALL THE DEFAULT COMPONENTS //
29+
```
30+
31+
---
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<button [disabled]="disabled" (click)="onClick.emit($event)" [class]="flavor"><ng-content></ng-content></button>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@use "sass:list";
2+
@import "theme-colors";
3+
4+
$flavors: (
5+
primary: (
6+
$primary-default,
7+
$primary-hover,
8+
$primary-disabled,
9+
),
10+
success: (
11+
$success-default,
12+
$success-hover,
13+
$success-disabled,
14+
),
15+
warning: (
16+
$warning-default,
17+
$warning-hover,
18+
$warning-disabled,
19+
),
20+
danger: (
21+
$danger-default,
22+
$danger-hover,
23+
$danger-disabled,
24+
),
25+
info: (
26+
$info-default,
27+
$info-hover,
28+
$info-disabled,
29+
),
30+
);
31+
32+
button {
33+
padding: 10px;
34+
border-radius: 10px;
35+
width: 100%;
36+
color: white;
37+
border: none;
38+
font-size: 16px;
39+
margin-right: 10px;
40+
&:last-child {
41+
margin-right: 0;
42+
}
43+
44+
@each $name, $colors in $flavors {
45+
&.#{$name} {
46+
color: #2f2f36;
47+
background: list.nth($colors, 1);
48+
49+
&:disabled {
50+
background-color: list.nth($colors, 3);
51+
}
52+
53+
&:hover {
54+
background-color: list.nth($colors, 2);
55+
color: white;
56+
}
57+
}
58+
}
59+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { StyledButtonComponent } from './styled-button.component';
4+
5+
describe('StyledButtonComponent', () => {
6+
let component: StyledButtonComponent;
7+
let fixture: ComponentFixture<StyledButtonComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ StyledButtonComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(StyledButtonComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Component, EventEmitter, Input, Output } from '@angular/core';
2+
3+
export type ButtonFlavor = 'primary' | 'success' | 'warning' | 'danger' | 'info';
4+
5+
@Component({
6+
selector: 'app-styled-button',
7+
templateUrl: './styled-button.component.html',
8+
styleUrls: ['./styled-button.component.scss']
9+
})
10+
export class StyledButtonComponent {
11+
12+
@Input() public disabled = false;
13+
@Input() public flavor: ButtonFlavor = 'primary';
14+
15+
// tslint:disable-next-line: no-output-on-prefix
16+
@Output() public onClick = new EventEmitter<MouseEvent>();
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*primary*/
2+
$primary-default: #2ECC70;
3+
$primary-hover: #1F8C4C;
4+
$primary-disabled: #2E473E;
5+
/*success*/
6+
$success-default: #3ABB18;
7+
$success-hover: #277A10;
8+
$success-disabled: #2F5629;
9+
/*warning*/
10+
$warning-default: #F1C30E;
11+
$warning-hover: #B3910B;
12+
$warning-disabled: #675926;
13+
/*danger*/
14+
$danger-default: #F00040;
15+
$danger-hover: #B0002F;
16+
$danger-disabled: #671E35;
17+
/*info*/
18+
$info-default: #3281F6;
19+
$info-hover: #245EB5;
20+
$info-disabled: #2D456C;
21+
/*etc*/
22+
$logo-crypt: #27A036
23+
/* ISSUE : #260 */
24+

0 commit comments

Comments
 (0)