refactor: improve stories, remove wrappers use styles instead

This commit is contained in:
2025-08-24 00:40:57 -03:00
parent a9363a37ec
commit 914f700d6b
6 changed files with 81 additions and 38 deletions

View File

@@ -2,7 +2,6 @@ import type { Meta, StoryObj } from '@storybook/angular';
import { CheckboxComponent } from './../../lib/atoms/checkbox/checkbox.component';
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
const meta: Meta<CheckboxComponent> = {
title: 'Atoms/Checkbox',
component: CheckboxComponent,
@@ -16,6 +15,21 @@ const meta: Meta<CheckboxComponent> = {
},
}
},
render: (args) => ({
props: {...args, handler: (checked: boolean) => alert(`checked: ${checked}`)},
styles: [
`
@import url('/assets/styles.css');
:host {
display: flex;
justify-content: center;
}
`
],
template: `
<mw-checkbox (checked)="handler($event)"/>
`,
})
};

View File

@@ -30,15 +30,20 @@ export default meta;
const Template = (args: { width: string, height: string, color: string, symbol: string,}) => ({
props: args,
styles: `
:host {
display:flex;
justify-content: center;
}
`,
template: `
<div style="display:flex; justify-content: center;">
<mw-svg
width="${args.width}"
height="${args.height}"
color="${args.color}"
symbol="${args.symbol}"
></mw-svg>
</div>`
[width]="width"
[height]="height"
[color]="color"
[symbol]="symbol"
/>
`
});
export const Svg = Template.bind({});

View File

@@ -10,8 +10,8 @@ export default {
color: "#000000",
ellipsis: false,
letterSpacing: "normal",
lineHeight: null,
maxWidth: null,
lineHeight: '',
maxWidth: '',
size: '1.4rem',
variant: 0,
},
@@ -23,7 +23,7 @@ export default {
ellipsis: {
type: 'boolean',
description: "If true, turns overflowing text into ellipsis (...) when the maxWidth attr is set",
table: {'defaultValue':{'detail': 'Defaults to false', 'summary': 'false'}}
table: {defaultValue:{detail: 'Defaults to false', summary: 'false'} },
},
letterSpacing: {
description: "Sets the horizontal spacing behavior between text characters",
@@ -74,15 +74,24 @@ export default {
const Template = (args: {variant: TypographyVariants, ellipsis: boolean, letterSpacing: string, lineHeight: null|string, size: string, color: string, maxWidth: null|string}) => ({
props: args,
styles: [
`
@import url('/assets/styles.css');
:host {
display: flex;
justify-content: center;
}
`
],
template: `
<mw-typography
[variant]="${args.variant}"
[ellipsis]="${args.ellipsis}"
color="${args.color}"
letterSpacing="${args.letterSpacing}"
lineHeight="${args.lineHeight}"
maxWidth="${args.maxWidth}"
size="${args.size}"
[variant]="variant"
[ellipsis]="ellipsis"
[color]="color"
[letterSpacing]="letterSpacing"
[lineHeight]="lineHeight"
[maxWidth]="maxWidth"
[size]="size"
>Texto</mw-typography>`,
});

View File

@@ -63,11 +63,17 @@ const Template: StoryObj<ExpenseIncomeCategoryByAccountDetailComponent> = {
props: args,
styles: [
`
@import url('/assets/styles.css')
@import url('/assets/styles.css');
:host {
display: block;
height: 40px;
margin: auto;
padding: 0 4px;
width: 375px;
}
`
],
template: `
<div style="width: 375px; height: 40px; margin: auto; padding: 0 4px;">
<mw-expense-income-category-by-account-detail
[acumAmount]="acumAmount"
[amount]="amount"
@@ -78,7 +84,6 @@ const Template: StoryObj<ExpenseIncomeCategoryByAccountDetailComponent> = {
[variant]="variant"
[whom]="whom"
/>
</div>
`,
}),
};

View File

@@ -45,11 +45,17 @@ const Template: StoryObj<ExpenseIncomeCategoryDetailComponent> = {
props: args,
styles: [
`
@import url('/assets/styles.css')
@import url('/assets/styles.css');
:host {
display: block;
height: 40px;
margin: auto;
padding: 0 4px;
width: 375px;
}
`
],
template: `
<div style="width: 375px; height: 40px; margin: auto; padding: 0 4px;">
<mw-expense-income-category-detail
[amount]="amount"
[iconProps]="{ symbol: symbol, color: color, backgroundColor: backgroundColor }"
@@ -58,7 +64,6 @@ const Template: StoryObj<ExpenseIncomeCategoryDetailComponent> = {
[variant]="variant"
[whom]="whom"
/>
</div>
`,
}),
};

View File

@@ -49,11 +49,17 @@ const Template: StoryObj<ExpenseIncomeDateDetailComponent> = {
props: args,
styles: [
`
@import url('/assets/styles.css')
@import url('/assets/styles.css');
:host {
display: block;
height: 40px;
margin: auto;
padding: 0 4px;
width: 375px;
}
`
],
template: `
<div style="width: 375px; height: 40px; margin: auto; padding: 0 4px;">
<mw-expense-income-date-detail
[amount]="amount"
[date]="date"
@@ -62,7 +68,6 @@ const Template: StoryObj<ExpenseIncomeDateDetailComponent> = {
[variant]="variant"
[whom]="whom"
/>
</div>
`,
}),
};