Skip to content
Snippets Groups Projects
Commit b89623ae authored by OZGCloud's avatar OZGCloud
Browse files

OZG-5590 OZG-5595 refactor button variants

parent 0a310d82
No related branches found
No related tags found
No related merge requests found
...@@ -58,10 +58,9 @@ ...@@ -58,10 +58,9 @@
</form> </form>
<app-bescheid-dialog-button></app-bescheid-dialog-button> <app-bescheid-dialog-button></app-bescheid-dialog-button>
<div class="my-4 flex gap-4"> <div class="my-4 flex gap-4">
<ods-button size="small" text="Button 1" /> <ods-button text="Button 1" />
<ods-button size="medium" [isLoading]="true" text="Button 2" /> <ods-button size="medium" [isLoading]="true" text="Button 2" />
<ods-button size="small" type="secondary" text="Button 3" /> <ods-button type="outline" text="Button 3" />
<ods-button size="medium" />
</div> </div>
<div class="text-warning">Achtung</div> <div class="text-warning">Achtung</div>
<div class="text-primary">Achtung</div> <div class="text-primary">Achtung</div>
......
...@@ -10,12 +10,11 @@ const buttonVariants = cva( ...@@ -10,12 +10,11 @@ const buttonVariants = cva(
variants: { variants: {
type: { type: {
primary: 'hover:enabled:bg-primary-hover bg-primary text-white shadow-sm', primary: 'hover:enabled:bg-primary-hover bg-primary text-white shadow-sm',
secondary: outline:
'border border-primary bg-background-50 text-primary hover:enabled:bg-background-100', 'border border-primary bg-background-50 text-primary hover:enabled:bg-background-100',
}, },
size: { size: {
small: 'h-9 py-2 px-4', medium: 'h-9 py-2 px-4',
medium: 'h-12 py-3 px-6',
}, },
}, },
defaultVariants: { defaultVariants: {
...@@ -34,6 +33,8 @@ type ButtonVariants = VariantProps<typeof buttonVariants>; ...@@ -34,6 +33,8 @@ type ButtonVariants = VariantProps<typeof buttonVariants>;
type="button" type="button"
[ngClass]="buttonVariants({ size, type })" [ngClass]="buttonVariants({ size, type })"
[disabled]="isLoading" [disabled]="isLoading"
[attr.aria-disabled]="isLoading"
[attr.aria-label]="text"
(click)="clickEmitter.emit()" (click)="clickEmitter.emit()"
> >
<ng-content *ngIf="!isLoading" select="[icon]"></ng-content> <ng-content *ngIf="!isLoading" select="[icon]"></ng-content>
...@@ -45,7 +46,7 @@ export class ButtonComponent { ...@@ -45,7 +46,7 @@ export class ButtonComponent {
@Input() text: string = ''; @Input() text: string = '';
@Input() isLoading: boolean = false; @Input() isLoading: boolean = false;
@Input() type: ButtonVariants['type'] = 'primary'; @Input() type: ButtonVariants['type'] = 'primary';
@Input() size: ButtonVariants['size'] = 'small'; @Input() size: ButtonVariants['size'] = 'medium';
@Output() public clickEmitter: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>(); @Output() public clickEmitter: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();
......
...@@ -20,20 +20,16 @@ export default meta; ...@@ -20,20 +20,16 @@ export default meta;
type Story = StoryObj<ButtonComponent>; type Story = StoryObj<ButtonComponent>;
export const Default: Story = { export const Default: Story = {
args: { text: 'Hello world!', isLoading: false, type: 'primary', size: 'small' }, args: { text: 'Hello world!', isLoading: false, type: 'primary' },
argTypes: { argTypes: {
type: { type: {
options: ['primary', 'secondary'], options: ['primary', 'outline'],
control: { type: 'radio' },
},
size: {
options: ['small', 'medium'],
control: { type: 'radio' }, control: { type: 'radio' },
}, },
}, },
}; };
export const WithIcon: Story = { export const WithIcon: Story = {
args: { text: 'I have an icon', isLoading: false, type: 'secondary', size: 'medium' }, args: { text: 'I have an icon', isLoading: false, type: 'outline' },
render: (args: ButtonComponent) => ({ render: (args: ButtonComponent) => ({
props: args, props: args,
template: `<ods-button ${argsToTemplate(args)}> template: `<ods-button ${argsToTemplate(args)}>
......
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
"cypress:version": "npx cypress version", "cypress:version": "npx cypress version",
"cypress:install": "npx cypress install", "cypress:install": "npx cypress install",
"cypress:open": "npx cypress open --project apps/alfa-e2e", "cypress:open": "npx cypress open --project apps/alfa-e2e",
"workspace-generator": "nx workspace-generator" "workspace-generator": "nx workspace-generator",
"storybook": "nx storybook design-system"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment