Skip to content

Commit

Permalink
run lint and prettier again
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixTJDietrich committed Aug 6, 2024
1 parent 92c6c68 commit abf9d04
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 62 deletions.
14 changes: 1 addition & 13 deletions webapp/src/app/ui/input/input.component.html
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
<input
[class]="computedClass()"
[type]="type()"
[placeholder]="placeholder()"
[disabled]="disabled()"
[value]="value()"
[id]="id()"
(input)="onInput($event)"
>




<input [class]="computedClass()" [type]="type()" [placeholder]="placeholder()" [disabled]="disabled()" [value]="value()" [id]="id()" (input)="onInput($event)" />
16 changes: 7 additions & 9 deletions webapp/src/app/ui/input/input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const [inputVariants, args, argTypes] = cva(
size: {
default: 'h-10 px-4 py-2',
sm: 'h-9 px-2 py-1',
lg: 'h-11 px-4 py-3',
},
lg: 'h-11 px-4 py-3'
}
},
defaultVariants: {
size: 'default',
},
},
size: 'default'
}
}
);

export { args, argTypes };
Expand All @@ -27,7 +27,7 @@ interface InputVariants extends VariantProps<typeof inputVariants> {}
@Component({
selector: 'app-input',
standalone: true,
templateUrl: './input.component.html',
templateUrl: './input.component.html'
})
export class AppInputComponent {
class = input<ClassValue>('');
Expand All @@ -45,7 +45,5 @@ export class AppInputComponent {
this.valueChange.emit(inputValue);
}

computedClass = computed(() =>
cn(inputVariants({ size: this.size() }), this.class()),
);
computedClass = computed(() => cn(inputVariants({ size: this.size() }), this.class()));
}
41 changes: 18 additions & 23 deletions webapp/src/app/ui/input/input.stories.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
argsToTemplate,
moduleMetadata,
type Meta,
type StoryObj,
} from '@storybook/angular';
import { argsToTemplate, moduleMetadata, type Meta, type StoryObj } from '@storybook/angular';
import { AppInputComponent, args, argTypes } from './input.component';
import { action } from '@storybook/addon-actions';
import { AppButtonComponent } from '@app/ui/button/button/button.component';
Expand All @@ -17,22 +12,22 @@ const meta: Meta<AppInputComponent> = {
...args,
value: '',
disabled: false,
size: 'default',
size: 'default'
},
argTypes: {
...argTypes,
disabled: {
control: 'boolean',
control: 'boolean'
},
onInput: {
action: 'onInput',
},
action: 'onInput'
}
},
decorators: [
moduleMetadata({
imports: [AppButtonComponent, AppLabelComponent],
}),
],
imports: [AppButtonComponent, AppLabelComponent]
})
]
};

export default meta;
Expand All @@ -41,18 +36,18 @@ type Story = StoryObj<AppInputComponent>;
export const Default: Story = {
render: (args) => ({
props: args,
template: `<app-input ${argsToTemplate(args)} placeholder="Enter text here"/>`,
}),
template: `<app-input ${argsToTemplate(args)} placeholder="Enter text here"/>`
})
};

export const Disabled: Story = {
args: {
disabled: true,
disabled: true
},
render: (args) => ({
props: args,
template: `<app-input ${argsToTemplate(args)} placeholder="Disabled input"/>`,
}),
template: `<app-input ${argsToTemplate(args)} placeholder="Disabled input"/>`
})
};

export const WithLabel: Story = {
Expand All @@ -63,8 +58,8 @@ export const WithLabel: Story = {
<app-label [for]="input-field" size="sm">Label</app-label>
<app-input ${argsToTemplate(args)} [id]="input-field" placeholder="Enter text here" class="grow"></app-input>
</div>
`,
}),
`
})
};

export const WithButton: Story = {
Expand All @@ -74,13 +69,13 @@ export const WithButton: Story = {
userInput: '',
onButtonClick(value: string) {
action('Button Clicked')(`Input Value: ${value}`);
},
}
},
template: `
<div class="flex gap-2 flex-row">
<app-input ${argsToTemplate(args)} [size]="args.size" [(value)]="userInput" placeholder="Enter text here" class="grow"/>
<app-button (onClick)="onButtonClick(userInput)" size="${args.size ?? 'default'}" [disabled]="!userInput">Submit</app-button>
</div>
`,
}),
`
})
};
7 changes: 2 additions & 5 deletions webapp/src/app/ui/label/label.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<label
[class]="computedClass()"
[for]="for()"
>
<ng-content/>
<label [class]="computedClass()" [for]="for()">
<ng-content />
</label>
9 changes: 2 additions & 7 deletions webapp/src/app/ui/label/label.component.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import { Component, computed, input } from '@angular/core';
import type { ClassValue } from 'clsx';
import { VariantProps } from 'class-variance-authority';
import { cn } from 'app/utils';
import { cva } from 'app/storybook.helper';

const [labelVariants, args, argTypes] = cva('text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70');

export { args, argTypes };

interface LabelVariants extends VariantProps<typeof labelVariants> {}

@Component({
selector: 'app-label',
standalone: true,
templateUrl: './label.component.html',
templateUrl: './label.component.html'
})
export class AppLabelComponent {
class = input<ClassValue>('');
for = input<string>('');

computedClass = computed(() =>
cn(labelVariants({}), this.class()),
);
computedClass = computed(() => cn(labelVariants({}), this.class()));
}
10 changes: 5 additions & 5 deletions webapp/src/app/ui/label/label.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const meta: Meta<AppLabelComponent> = {
tags: ['autodocs'],
args: {
...args,
for: 'example-input',
for: 'example-input'
},
argTypes: {
...argTypes,
},
...argTypes
}
};

export default meta;
Expand All @@ -20,6 +20,6 @@ type Story = StoryObj<AppLabelComponent>;
export const Default: Story = {
render: (args) => ({
props: args,
template: `<app-label ${argsToTemplate(args)}>Label</app-label>`,
}),
template: `<app-label ${argsToTemplate(args)}>Label</app-label>`
})
};

0 comments on commit abf9d04

Please sign in to comment.