From 914f700d6bcfa59574d1e3c70c9ad8195fe1a614 Mon Sep 17 00:00:00 2001 From: Gabriel De Los Rios Date: Sun, 24 Aug 2025 00:40:57 -0300 Subject: [PATCH] refactor: improve stories, remove wrappers use styles instead --- .../src/stories/atoms/checkbox.stories.ts | 16 +++++++++- .../src/stories/atoms/svg.stories.ts | 19 +++++++----- .../src/stories/atoms/typography.stories.ts | 31 ++++++++++++------- ...come-category-by-account-detail.stories.ts | 31 +++++++++++-------- .../expense-income-category-detail.stories.ts | 11 +++++-- .../expense-income-date-detail.stories.ts | 11 +++++-- 6 files changed, 81 insertions(+), 38 deletions(-) diff --git a/projects/my-wallet-ds/src/stories/atoms/checkbox.stories.ts b/projects/my-wallet-ds/src/stories/atoms/checkbox.stories.ts index e40be17..a100589 100644 --- a/projects/my-wallet-ds/src/stories/atoms/checkbox.stories.ts +++ b/projects/my-wallet-ds/src/stories/atoms/checkbox.stories.ts @@ -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 = { title: 'Atoms/Checkbox', component: CheckboxComponent, @@ -16,6 +15,21 @@ const meta: Meta = { }, } }, + render: (args) => ({ + props: {...args, handler: (checked: boolean) => alert(`checked: ${checked}`)}, + styles: [ + ` + @import url('/assets/styles.css'); + :host { + display: flex; + justify-content: center; + } + ` + ], + template: ` + + `, + }) }; diff --git a/projects/my-wallet-ds/src/stories/atoms/svg.stories.ts b/projects/my-wallet-ds/src/stories/atoms/svg.stories.ts index 621d27b..991f8b9 100644 --- a/projects/my-wallet-ds/src/stories/atoms/svg.stories.ts +++ b/projects/my-wallet-ds/src/stories/atoms/svg.stories.ts @@ -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: ` -
-
` + [width]="width" + [height]="height" + [color]="color" + [symbol]="symbol" + /> + ` }); export const Svg = Template.bind({}); \ No newline at end of file diff --git a/projects/my-wallet-ds/src/stories/atoms/typography.stories.ts b/projects/my-wallet-ds/src/stories/atoms/typography.stories.ts index 4a8865b..7caae12 100644 --- a/projects/my-wallet-ds/src/stories/atoms/typography.stories.ts +++ b/projects/my-wallet-ds/src/stories/atoms/typography.stories.ts @@ -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,16 +74,25 @@ 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: ` Texto`, + [variant]="variant" + [ellipsis]="ellipsis" + [color]="color" + [letterSpacing]="letterSpacing" + [lineHeight]="lineHeight" + [maxWidth]="maxWidth" + [size]="size" + >Texto`, }); export const Paragraph = Template.bind({}); diff --git a/projects/my-wallet-ds/src/stories/molecules/expense-income-category-by-account-detail.stories.ts b/projects/my-wallet-ds/src/stories/molecules/expense-income-category-by-account-detail.stories.ts index b7bbb1d..8aafe3a 100644 --- a/projects/my-wallet-ds/src/stories/molecules/expense-income-category-by-account-detail.stories.ts +++ b/projects/my-wallet-ds/src/stories/molecules/expense-income-category-by-account-detail.stories.ts @@ -63,22 +63,27 @@ const Template: StoryObj = { 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: ` -
- -
+ `, }), }; diff --git a/projects/my-wallet-ds/src/stories/molecules/expense-income-category-detail.stories.ts b/projects/my-wallet-ds/src/stories/molecules/expense-income-category-detail.stories.ts index 47658a4..2abfcb2 100644 --- a/projects/my-wallet-ds/src/stories/molecules/expense-income-category-detail.stories.ts +++ b/projects/my-wallet-ds/src/stories/molecules/expense-income-category-detail.stories.ts @@ -45,11 +45,17 @@ const Template: StoryObj = { 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: ` -
= { [variant]="variant" [whom]="whom" /> -
`, }), }; diff --git a/projects/my-wallet-ds/src/stories/molecules/expense-income-date-detail.stories.ts b/projects/my-wallet-ds/src/stories/molecules/expense-income-date-detail.stories.ts index 2f757db..c66315a 100644 --- a/projects/my-wallet-ds/src/stories/molecules/expense-income-date-detail.stories.ts +++ b/projects/my-wallet-ds/src/stories/molecules/expense-income-date-detail.stories.ts @@ -49,11 +49,17 @@ const Template: StoryObj = { 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: ` -
= { [variant]="variant" [whom]="whom" /> -
`, }), };