feat(ui): Added link-button to ui-libs. (TV-855)

Squashed commit of the following:

commit 1aab96d7f243c77adbd806196f76b931f4445976
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Thu Oct 28 11:38:05 2021 +0200

    Added digi-link component to ui lib
This commit is contained in:
Erik Tiekstra
2021-10-28 12:08:07 +02:00
parent b2ff020edf
commit f857b1ae20
10 changed files with 104 additions and 6 deletions

View File

@@ -8,9 +8,9 @@
font-weight: var(--digi-button--font-weight);
font-size: var(--digi-button--font-size);
width: var(--digi-button--width);
display: flex;
display: inline-flex;
align-items: center;
gap: 0.3rem;
gap: 0.5rem;
text-align: var(--digi-button--text-align);
border: var(--digi-button--border);
outline: var(--digi-button--outline);

View File

@@ -0,0 +1,5 @@
export enum UiLinkButtonType {
PRIMARY = 'primary',
SECONDARY = 'secondary',
TERTIARY = 'tertiary',
}

View File

@@ -0,0 +1,3 @@
<a [ngClass]="linkButtonClass" [routerLink]="uiRouterLink" [queryParams]="uiQueryParams">
<ng-content></ng-content>
</a>

View File

@@ -0,0 +1,13 @@
@import 'mixins/buttons';
.ui-link-button {
&--primary {
@include msfa__button;
}
&--secondary {
@include msfa__button('secondary');
}
&--tertiary {
@include msfa__button('tertiary');
}
}

View File

@@ -0,0 +1,26 @@
/* tslint:disable:no-unused-variable */
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LinkButtonComponent } from './link-button.component';
describe('LinkButtonComponent', () => {
let component: LinkButtonComponent;
let fixture: ComponentFixture<LinkButtonComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [LinkButtonComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(LinkButtonComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { LinkButtonComponent } from './link-button.component';
import { UiLinkButtonModule } from './link-button.module';
export default { title: 'LinkButton', component: LinkButtonComponent };
const componentModule = {
moduleMetadata: {
imports: [UiLinkButtonModule],
},
};
export const standard = () => ({
...componentModule,
template: '<ui-link-button></ui-link-button>',
});

View File

@@ -0,0 +1,24 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { Params } from '@angular/router';
import { UiLinkButtonType } from './link-button-type.enum';
@Component({
selector: 'ui-link-button',
templateUrl: './link-button.component.html',
styleUrls: ['./link-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LinkButtonComponent {
private readonly _defaultClass = 'ui-link-button';
@Input() uiType: UiLinkButtonType = UiLinkButtonType.PRIMARY;
@Input() uiSize: 's' | 'm' = 'm';
@Input() uiRouterLink: string | string[];
@Input() uiQueryParams: Params = null;
get linkButtonClass(): string {
if (this.uiType) {
return `${this._defaultClass} ${this._defaultClass}--${this.uiType as string}`;
}
return this._defaultClass;
}
}

View File

@@ -0,0 +1,12 @@
import { CommonModule } from '@angular/common';
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { LinkButtonComponent } from './link-button.component';
@NgModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [LinkButtonComponent],
imports: [CommonModule, RouterModule],
exports: [LinkButtonComponent],
})
export class UiLinkButtonModule {}