RLH-12 | Start implementing /account page
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-link"
|
||||
[disabled]="buttonDisabled()"
|
||||
(click)="button.click()">
|
||||
{{button.text}}
|
||||
</button>
|
||||
23
src/app/libraries/components/button/button.component.spec.ts
Normal file
23
src/app/libraries/components/button/button.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ButtonComponent } from './button.component';
|
||||
|
||||
describe('ButtonComponent', () => {
|
||||
let component: ButtonComponent;
|
||||
let fixture: ComponentFixture<ButtonComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ButtonComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ButtonComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
40
src/app/libraries/components/button/button.component.ts
Normal file
40
src/app/libraries/components/button/button.component.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import {booleanAttribute, Component, Input, OnInit} from '@angular/core';
|
||||
import {ButtonModel} from "./models/button.model";
|
||||
|
||||
@Component({
|
||||
selector: 'rlh-button',
|
||||
standalone: true,
|
||||
imports: [],
|
||||
templateUrl: './button.component.html',
|
||||
styleUrl: './button.component.scss'
|
||||
})
|
||||
export class ButtonComponent implements OnInit
|
||||
{
|
||||
|
||||
@Input() button: ButtonModel = {
|
||||
text: 'text',
|
||||
disabled: () => false,
|
||||
click: () => {}
|
||||
};
|
||||
|
||||
buttonDisabled: () => boolean = () => {
|
||||
return false;
|
||||
// tslint:disable-next-line: semicolon
|
||||
};
|
||||
|
||||
ngOnInit() {
|
||||
this.button.disabled = this.button.disabled
|
||||
? this.button.disabled
|
||||
: () => false;
|
||||
//
|
||||
setTimeout(() => {
|
||||
this.buttonDisabled = () => {
|
||||
return this.button.disabled();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export class ButtonModel {
|
||||
text: string = "text";
|
||||
disabled: () => boolean;
|
||||
click: () => void;
|
||||
}
|
||||
Reference in New Issue
Block a user