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

Added Button Base Component #275

Merged
merged 42 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
cd99573
#260 added theme colors
ClientCrash Sep 12, 2021
626d36b
created new component
ClientCrash Sep 18, 2021
d6d810b
added logic and StandartStyle Enum
ClientCrash Sep 18, 2021
ff2bb8e
added html
ClientCrash Sep 18, 2021
4faddaf
added class
ClientCrash Sep 18, 2021
9e3d0b4
changed component structure
ClientCrash Sep 18, 2021
28de0bb
removed useless file StandartStyle.ts
ClientCrash Sep 18, 2021
46ab827
fixed naming issue
ClientCrash Sep 18, 2021
e90d379
removed useless onInit
ClientCrash Sep 18, 2021
2cd2738
readded onInit
ClientCrash Sep 18, 2021
0275188
fixed bug
ClientCrash Sep 18, 2021
8d02ffc
removed empty on init
ClientCrash Sep 18, 2021
3dc6f54
Update src/app/design/styled-button/styled-button.component.ts sugges…
ClientCrash Sep 18, 2021
cc507a9
made scss prettier
ClientCrash Sep 18, 2021
9bfd3ea
Apply suggestions from Marcel
ClientCrash Sep 18, 2021
26aa0f1
changed theme colors file location
ClientCrash Sep 19, 2021
b0dad58
deleted duplicate theme colors
ClientCrash Sep 19, 2021
66a445d
removed false import
ClientCrash Sep 19, 2021
9a7875e
fixed typo
ClientCrash Sep 19, 2021
85b5f41
importet variables
ClientCrash Sep 19, 2021
4a29d94
changed imports
ClientCrash Sep 19, 2021
1fdbd5f
fixed scss import
ClientCrash Sep 19, 2021
0943e7d
fixed import
ClientCrash Sep 19, 2021
28bf7c9
removed useless import
ClientCrash Sep 19, 2021
815a64c
switched import from variables to theme colors
ClientCrash Sep 19, 2021
d971209
made theme colors import more optional
ClientCrash Sep 19, 2021
d00acb6
changed the way onClick works to event emitter
ClientCrash Sep 19, 2021
7958977
updated styling
ClientCrash Sep 19, 2021
562e617
added imports
ClientCrash Oct 14, 2021
512c1f5
added spacing
ClientCrash Oct 14, 2021
ed11d55
Apply some of the suggestions from code review
ClientCrash Oct 14, 2021
780f5d0
improved button styling
ClientCrash Oct 14, 2021
8bb1dc7
improved button design
ClientCrash Oct 14, 2021
302b7cb
added "app-" to StyledButtonComponent selector
ClientCrash Oct 14, 2021
abff23e
Create ComponentDocs.md
ClientCrash Oct 14, 2021
ae1c23f
renamed styleClass to flavor
ClientCrash Feb 28, 2022
864759e
Update ComponentDocs.md
ClientCrash Mar 5, 2022
8bf6c5c
linted styled-button scss
ClientCrash Mar 5, 2022
951093f
updated styled button scss
ClientCrash Mar 5, 2022
5e0f297
reformated styled button scss
ClientCrash Mar 6, 2022
15f7ea8
moved styled button component registration from app module to design …
ClientCrash Mar 6, 2022
92399c2
Slightly improved Button Component
MarcelCoding Mar 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 //
```

---
5 changes: 3 additions & 2 deletions src/app/design/design.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ 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', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With version 3, we want to encourage the use of unit tests. Some basic tests for the flavors and the "disabled"-property would be nice and won't take much time! :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else is fine

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 */