This repository was archived by the owner on Sep 20, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 14
Added Button Base Component #275
Merged
Tristan-H11
merged 42 commits into
cryptic-game:issue/260-base-components
from
ClientCrash:base-components-button
Mar 6, 2022
Merged
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 626d36b
created new component
ClientCrash d6d810b
added logic and StandartStyle Enum
ClientCrash ff2bb8e
added html
ClientCrash 4faddaf
added class
ClientCrash 9e3d0b4
changed component structure
ClientCrash 28de0bb
removed useless file StandartStyle.ts
ClientCrash 46ab827
fixed naming issue
ClientCrash e90d379
removed useless onInit
ClientCrash 2cd2738
readded onInit
ClientCrash 0275188
fixed bug
ClientCrash 8d02ffc
removed empty on init
ClientCrash 3dc6f54
Update src/app/design/styled-button/styled-button.component.ts sugges…
ClientCrash cc507a9
made scss prettier
ClientCrash 9bfd3ea
Apply suggestions from Marcel
ClientCrash 26aa0f1
changed theme colors file location
ClientCrash b0dad58
deleted duplicate theme colors
ClientCrash 66a445d
removed false import
ClientCrash 9a7875e
fixed typo
ClientCrash 85b5f41
importet variables
ClientCrash 4a29d94
changed imports
ClientCrash 1fdbd5f
fixed scss import
ClientCrash 0943e7d
fixed import
ClientCrash 28bf7c9
removed useless import
ClientCrash 815a64c
switched import from variables to theme colors
ClientCrash d971209
made theme colors import more optional
ClientCrash d00acb6
changed the way onClick works to event emitter
ClientCrash 7958977
updated styling
ClientCrash 562e617
added imports
ClientCrash 512c1f5
added spacing
ClientCrash ed11d55
Apply some of the suggestions from code review
ClientCrash 780f5d0
improved button styling
ClientCrash 8bb1dc7
improved button design
ClientCrash 302b7cb
added "app-" to StyledButtonComponent selector
ClientCrash abff23e
Create ComponentDocs.md
ClientCrash ae1c23f
renamed styleClass to flavor
ClientCrash 864759e
Update ComponentDocs.md
ClientCrash 8bf6c5c
linted styled-button scss
ClientCrash 951093f
updated styled button scss
ClientCrash 5e0f297
reformated styled button scss
ClientCrash 15f7ea8
moved styled button component registration from app module to design …
ClientCrash 92399c2
Slightly improved Button Component
MarcelCoding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 // | ||
``` | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
25
src/app/design/styled-button/styled-button.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ | ||
|
||
Tristan-H11 marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything else is fine