diff --git a/alfa-client/apps/demo/src/app/app.component.html b/alfa-client/apps/demo/src/app/app.component.html index f7f8e26ea4dbf313f8287e677283b1d2afa1b4af..c6aceee8705c27127d21f12dfa3ea23979f65fa6 100644 --- a/alfa-client/apps/demo/src/app/app.component.html +++ b/alfa-client/apps/demo/src/app/app.component.html @@ -83,22 +83,26 @@ <hr /> <div class="flex flex-col gap-4 bg-background-200 p-6"> <div class="mt-4"> - <ods-button-card class="w-72" [isLoading]="false"> + <ods-button-card + class="w-72" + [isLoading]="false" + text="Bescheid-Dokument" + subText="automatisch erstellen" + > <ods-icon icon name="file-generate" class="size-10 fill-primary" /> <ods-spinner-icon spinner class="size-10" /> - <p text class="text-center"> - Bescheid-Dokument<br />automatisch erstellen - </p></ods-button-card - > + </ods-button-card> </div> <div class="mt-4"> - <ods-button-card class="w-72" [isLoading]="true"> + <ods-button-card + class="w-72" + [isLoading]="true" + text="Bescheid-Dokument" + subText="automatisch erstellen" + > <ods-icon icon name="file-generate" class="size-10 fill-primary" /> <ods-spinner-icon spinner class="size-10" /> - <p text class="text-center"> - Bescheid-Dokument<br />automatisch erstellen - </p></ods-button-card - > + </ods-button-card> </div> <div class="mt-4"> diff --git a/alfa-client/libs/design-system/src/index.ts b/alfa-client/libs/design-system/src/index.ts index 2178e0d97fc8f76053a402b3203a571deda2be09..f7dfe57c3c143a8bc2a794e782028532c578adda 100644 --- a/alfa-client/libs/design-system/src/index.ts +++ b/alfa-client/libs/design-system/src/index.ts @@ -1,5 +1,5 @@ export * from './lib/attachment/attachment.component'; -export * from './lib/form/button-card/button-card.component'; +export * from './lib/button-card/button-card.component'; export * from './lib/button/button.component'; export * from './lib/form/file-upload-button/file-upload-button.component'; export * from './lib/form/radio-button-card/radio-button-card.component'; diff --git a/alfa-client/libs/design-system/src/lib/form/button-card/button-card.component.spec.ts b/alfa-client/libs/design-system/src/lib/button-card/button-card.component.spec.ts similarity index 100% rename from alfa-client/libs/design-system/src/lib/form/button-card/button-card.component.spec.ts rename to alfa-client/libs/design-system/src/lib/button-card/button-card.component.spec.ts diff --git a/alfa-client/libs/design-system/src/lib/button-card/button-card.component.ts b/alfa-client/libs/design-system/src/lib/button-card/button-card.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..78e1f935fae35d9f835fce86bac135cf5acab994 --- /dev/null +++ b/alfa-client/libs/design-system/src/lib/button-card/button-card.component.ts @@ -0,0 +1,26 @@ +import { CommonModule } from '@angular/common'; +import { Component, Input } from '@angular/core'; + +@Component({ + selector: 'ods-button-card', + standalone: true, + imports: [CommonModule], + styles: [':host {@apply inline-flex}'], + template: `<button + type="button" + class="flex flex-grow items-center justify-center gap-4 whitespace-nowrap rounded-md bg-background-50 py-3 pl-6 pr-6 text-text hover:bg-background-100 focus:outline-none focus:ring-2 focus:ring-primary" + [disabled]="isLoading" + > + <ng-content *ngIf="!isLoading" select="[icon]"></ng-content> + <ng-content *ngIf="isLoading" select="[spinner]"></ng-content> + <div class="flex flex-grow flex-col gap-1"> + <div class="leading-none">{{ text }}</div> + <div class="leading-none">{{ subText }}</div> + </div> + </button>`, +}) +export class ButtonCardComponent { + @Input() text: string = ''; + @Input() subText: string = ''; + @Input() isLoading: boolean = false; +} diff --git a/alfa-client/libs/design-system/src/lib/button/button.component.html b/alfa-client/libs/design-system/src/lib/button/button.component.html deleted file mode 100644 index 52f3f2125385f52d1c2b8eb712ecaac9dd826708..0000000000000000000000000000000000000000 --- a/alfa-client/libs/design-system/src/lib/button/button.component.html +++ /dev/null @@ -1,10 +0,0 @@ -<button - type="button" - [ngClass]="buttonVariants({ size, type })" - [disabled]="isLoading" - (click)="clickEmitter.emit()" -> - <ng-content *ngIf="!isLoading" select="[icon]"></ng-content> - <ods-spinner-icon *ngIf="isLoading" class="h-full"></ods-spinner-icon> - <div class="flex-grow" [innerHTML]="text | safe: 'html'"></div> -</button> diff --git a/alfa-client/libs/design-system/src/lib/button/button.component.ts b/alfa-client/libs/design-system/src/lib/button/button.component.ts index 477e76f9af2e2b9de384b588fb16026d00a6739f..d9ade06f5569c600a98622ba1158d26d4cf7e18d 100644 --- a/alfa-client/libs/design-system/src/lib/button/button.component.ts +++ b/alfa-client/libs/design-system/src/lib/button/button.component.ts @@ -3,7 +3,6 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; import { VariantProps, cva } from 'class-variance-authority'; import { SpinnerIconComponent } from '../icons/spinner-icon/spinner-icon.component'; -import { SafePipe } from '../utils/safe.pipe'; const buttonVariants = cva( 'flex cursor-pointer items-center gap-4 rounded-md font-medium disabled:cursor-wait text-sm min-w-32', @@ -15,8 +14,8 @@ const buttonVariants = cva( 'border border-primary bg-background-50 text-primary hover:enabled:bg-background-100', }, size: { - small: 'h-9 py-1 px-2', - medium: 'h-12 py-2 px-4', + small: 'h-9 py-2 px-4', + medium: 'h-12 py-3 px-6', }, }, defaultVariants: { @@ -30,8 +29,17 @@ type ButtonVariants = VariantProps<typeof buttonVariants>; @Component({ selector: 'ods-button', standalone: true, - imports: [CommonModule, SpinnerIconComponent, SafePipe], - templateUrl: './button.component.html', + imports: [CommonModule, SpinnerIconComponent], + template: `<button + type="button" + [ngClass]="buttonVariants({ size, type })" + [disabled]="isLoading" + (click)="clickEmitter.emit()" + > + <ng-content *ngIf="!isLoading" select="[icon]"></ng-content> + <ods-spinner-icon *ngIf="isLoading" class="h-full"></ods-spinner-icon> + <div class="flex-grow">{{ text }}</div> + </button>`, }) export class ButtonComponent { @Input() text: string = ''; diff --git a/alfa-client/libs/design-system/src/lib/button/button.stories.ts b/alfa-client/libs/design-system/src/lib/button/button.stories.ts index bd6947bf414762ec445a1fdb0916af89e0f53614..e888d33210d18004683b1b12bf945eb84a0680b2 100644 --- a/alfa-client/libs/design-system/src/lib/button/button.stories.ts +++ b/alfa-client/libs/design-system/src/lib/button/button.stories.ts @@ -1,10 +1,17 @@ -import type { Meta, StoryObj } from '@storybook/angular'; +import { argsToTemplate, moduleMetadata, type Meta, type StoryObj } from '@storybook/angular'; +import { IconComponent } from '../icon/icon.component'; import { ButtonComponent } from './button.component'; const meta: Meta<ButtonComponent> = { title: 'Button', component: ButtonComponent, + subcomponents: { IconComponent }, + decorators: [ + moduleMetadata({ + imports: [ButtonComponent, IconComponent], + }), + ], excludeStories: /.*Data$/, tags: ['autodocs'], }; @@ -25,3 +32,12 @@ export const Default: Story = { }, }, }; +export const WithIcon: Story = { + args: { text: 'I have an icon', isLoading: false, type: 'secondary', size: 'medium' }, + render: (args: ButtonComponent) => ({ + props: args, + template: `<ods-button ${argsToTemplate(args)}> + <ods-icon icon name="file-pdf" class="h-full"></ods-icon> + </ods-button>`, + }), +}; diff --git a/alfa-client/libs/design-system/src/lib/form/button-card/button-card.component.html b/alfa-client/libs/design-system/src/lib/form/button-card/button-card.component.html deleted file mode 100644 index 623e97f8ca245b2b9db3d62a2544037348cb9659..0000000000000000000000000000000000000000 --- a/alfa-client/libs/design-system/src/lib/form/button-card/button-card.component.html +++ /dev/null @@ -1,11 +0,0 @@ -<button - type="button" - class="flex flex-grow items-center justify-center gap-4 whitespace-nowrap rounded-md bg-background-50 py-3 pl-6 pr-6 text-text hover:bg-background-100 focus:outline-none focus:ring-2 focus:ring-primary" - [disabled]="isLoading" -> - <ng-content *ngIf="!isLoading" select="[icon]"></ng-content> - <ng-content *ngIf="isLoading" select="[spinner]"></ng-content> - <div class="flex-grow"> - <ng-content select="[text]"></ng-content> - </div> -</button> diff --git a/alfa-client/libs/design-system/src/lib/form/button-card/button-card.component.ts b/alfa-client/libs/design-system/src/lib/form/button-card/button-card.component.ts deleted file mode 100644 index 8a3e40783947b21d050886008c2e165e7d321573..0000000000000000000000000000000000000000 --- a/alfa-client/libs/design-system/src/lib/form/button-card/button-card.component.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { Component, Input } from '@angular/core'; - -@Component({ - selector: 'ods-button-card', - standalone: true, - imports: [CommonModule], - styles: [':host {@apply inline-flex}'], - templateUrl: './button-card.component.html', -}) -export class ButtonCardComponent { - @Input() text: string = ''; - @Input() isLoading: boolean = false; -} diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-steps/vorgang-detail-bescheiden-steps-content/vorgang-detail-bescheiden-dokumente-hinzufuegen/vorgang-detail-bescheiden-bescheid-automatisch-erstellen/vorgang-detail-bescheiden-bescheid-automatisch-erstellen.component.html b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-steps/vorgang-detail-bescheiden-steps-content/vorgang-detail-bescheiden-dokumente-hinzufuegen/vorgang-detail-bescheiden-bescheid-automatisch-erstellen/vorgang-detail-bescheiden-bescheid-automatisch-erstellen.component.html index 30c6c4eef92fc4a3de7e72253614ff141d8485a3..48123d83e5fa79f385ef0751bc05bec5013ccb45 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-steps/vorgang-detail-bescheiden-steps-content/vorgang-detail-bescheiden-dokumente-hinzufuegen/vorgang-detail-bescheiden-bescheid-automatisch-erstellen/vorgang-detail-bescheiden-bescheid-automatisch-erstellen.component.html +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-steps/vorgang-detail-bescheiden-steps-content/vorgang-detail-bescheiden-dokumente-hinzufuegen/vorgang-detail-bescheiden-bescheid-automatisch-erstellen/vorgang-detail-bescheiden-bescheid-automatisch-erstellen.component.html @@ -1,17 +1,15 @@ -<ng-container *ngIf="bescheidDraftStateResource.resource as bescheidDraft"> +<ng-container> <div class="mt-4"> <ods-button-card - *ngIf="bescheidDraft | hasLink: bescheidLinkRel.CREATE_DOCUMENT" class="w-72" [isLoading]="(createBescheidDocumentInProgress$ | async).loading" (click)="createBescheidDocument()" data-test-id="create-bescheid-document-button" + text="Bescheid-Dokument" + subText="automatisch erstellen" > <ods-bescheid-generate-icon icon /> <ods-spinner-icon spinner class="size-10" /> - <div text class="text-center"> - Bescheid-Dokument<br />automatisch erstellen - </div></ods-button-card - > + </ods-button-card> </div> </ng-container>