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:
@@ -6,8 +6,8 @@
|
|||||||
hämta authentication-token:
|
hämta authentication-token:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<digi-ng-button routerLink="/" [queryParams]="{ code: 'auth_code_from_CIAM_with_all_permissions'}">
|
<ui-link-button uiRouterLink="/" [uiQueryParams]="{ code: 'auth_code_from_CIAM_with_all_permissions'}">
|
||||||
Logga in med fullständiga rättigheter
|
Logga in med fullständiga rättigheter
|
||||||
</digi-ng-button>
|
</ui-link-button>
|
||||||
</section>
|
</section>
|
||||||
</digi-typography>
|
</digi-typography>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { DigiNgButtonModule } from '@af/digi-ng/_button/button';
|
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
|
import { UiLinkButtonModule } from '@ui/link-button/link-button.module';
|
||||||
import { MockLoginComponent } from './mock-login.component';
|
import { MockLoginComponent } from './mock-login.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -15,7 +15,7 @@ import { MockLoginComponent } from './mock-login.component';
|
|||||||
component: MockLoginComponent,
|
component: MockLoginComponent,
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
DigiNgButtonModule,
|
UiLinkButtonModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class MockLoginModule {}
|
export class MockLoginModule {}
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
font-weight: var(--digi-button--font-weight);
|
font-weight: var(--digi-button--font-weight);
|
||||||
font-size: var(--digi-button--font-size);
|
font-size: var(--digi-button--font-size);
|
||||||
width: var(--digi-button--width);
|
width: var(--digi-button--width);
|
||||||
display: flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.3rem;
|
gap: 0.5rem;
|
||||||
text-align: var(--digi-button--text-align);
|
text-align: var(--digi-button--text-align);
|
||||||
border: var(--digi-button--border);
|
border: var(--digi-button--border);
|
||||||
outline: var(--digi-button--outline);
|
outline: var(--digi-button--outline);
|
||||||
|
|||||||
5
libs/ui/link-button/link-button-type.enum.ts
Normal file
5
libs/ui/link-button/link-button-type.enum.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export enum UiLinkButtonType {
|
||||||
|
PRIMARY = 'primary',
|
||||||
|
SECONDARY = 'secondary',
|
||||||
|
TERTIARY = 'tertiary',
|
||||||
|
}
|
||||||
3
libs/ui/link-button/link-button.component.html
Normal file
3
libs/ui/link-button/link-button.component.html
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<a [ngClass]="linkButtonClass" [routerLink]="uiRouterLink" [queryParams]="uiQueryParams">
|
||||||
|
<ng-content></ng-content>
|
||||||
|
</a>
|
||||||
13
libs/ui/link-button/link-button.component.scss
Normal file
13
libs/ui/link-button/link-button.component.scss
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
26
libs/ui/link-button/link-button.component.spec.ts
Normal file
26
libs/ui/link-button/link-button.component.spec.ts
Normal 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
15
libs/ui/link-button/link-button.component.stories.ts
Normal file
15
libs/ui/link-button/link-button.component.stories.ts
Normal 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>',
|
||||||
|
});
|
||||||
24
libs/ui/link-button/link-button.component.ts
Normal file
24
libs/ui/link-button/link-button.component.ts
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
libs/ui/link-button/link-button.module.ts
Normal file
12
libs/ui/link-button/link-button.module.ts
Normal 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 {}
|
||||||
Reference in New Issue
Block a user