refactor: common controls for multiple stories

This commit is contained in:
2025-08-23 16:24:01 -03:00
parent 64e2269455
commit 02cbf183b3
6 changed files with 77 additions and 77 deletions

View File

@@ -1,6 +1,6 @@
import type { Meta } from '@storybook/angular'; import type { Meta } from '@storybook/angular';
import { SvgComponent } from './../../lib/atoms/svg/svg.component'; import { SvgComponent } from './../../lib/atoms/svg/svg.component';
import { svgList } from './../svg-list'; import { color, symbol } from '../control-constants/svg';
const meta: Meta<SvgComponent> = { const meta: Meta<SvgComponent> = {
title: 'Atoms/Svg', title: 'Atoms/Svg',
@@ -21,16 +21,8 @@ const meta: Meta<SvgComponent> = {
description: 'Icon height with units (px, rem, etc)', description: 'Icon height with units (px, rem, etc)',
table: {defaultValue: {detail: 'Defaults to 24px', summary: '24px'}} table: {defaultValue: {detail: 'Defaults to 24px', summary: '24px'}}
}, },
color: { color,
description: 'Icon color', symbol,
table: {defaultValue: {detail: 'Defaults to black', summary: '#000000'}}
},
symbol: {
control: 'select',
options: svgList,
description: 'Icon name',
table: {defaultValue: {detail: 'Defaults to none (empty string)', summary: '(empty string)'}}
},
} }
} ; } ;

View File

@@ -0,0 +1,7 @@
import { InputType } from "storybook/internal/types";
export const backgroundColor: InputType = {
control: 'color',
description: 'Circle background color',
table: {defaultValue: {detail: 'Defaults to white', summary: '#fff'}},
}

View File

@@ -0,0 +1,35 @@
import { InputType } from "storybook/internal/types";
export const amount: InputType = {
control: 'number',
description: 'Income/expense amount',
table: {defaultValue: {detail: 'Defaults to 0', summary: '0'}},
}
export const category: InputType = {
control: 'text',
description: 'Expense/income category name',
table: {defaultValue: {detail: 'Defaults to none (empty string)', summary: '(empty string)'}},
}
export const description: InputType = {
control: 'text',
description: 'Expense/income description',
table: {defaultValue: {detail: 'Defaults to none (empty string)', summary: '(empty string)'}},
}
export const variant: InputType = {
control: 'select',
description: 'Kind of transaction',
options: [
'expense',
'income',
],
table: {defaultValue: {summary: "income", detail: "Income transaction"}},
}
export const whom: InputType = {
control: 'text',
description: 'Expense/income payer or payee',
table: {defaultValue: {detail: 'Defaults to none (empty string)', summary: '(empty string)'}},
}

View File

@@ -0,0 +1,14 @@
import { InputType } from "storybook/internal/types";
import { svgList } from "../svg-list"
export const color: InputType = {
description: 'Icon color',
table: {defaultValue: {detail: 'Defaults to black', summary: '#000000'}}
}
export const symbol: InputType = {
control: 'select',
options: svgList,
description: 'Icon name',
table: {defaultValue: {detail: 'Defaults to none (empty string)', summary: '(empty string)'}}
}

View File

@@ -1,6 +1,7 @@
import type { Meta } from '@storybook/angular'; import type { Meta } from '@storybook/angular';
import { CircledIconComponent } from '../../lib/molecules/circled-icon/circled-icon.component'; import { CircledIconComponent } from '../../lib/molecules/circled-icon/circled-icon.component';
import { svgList } from '../svg-list'; import { color, symbol } from '../control-constants/svg';
import { backgroundColor } from '../control-constants/circled-icon';
/** /**
* *
* **Sizing**: the circled icon takes all space available in it's parent component * **Sizing**: the circled icon takes all space available in it's parent component
@@ -17,22 +18,9 @@ const meta: Meta<CircledIconComponent> = {
symbol: 'stock-line', symbol: 'stock-line',
}, },
argTypes: { argTypes: {
backgroundColor: { backgroundColor,
control: 'color', color,
description: 'Circle background color', symbol
table: {defaultValue: {detail: 'Defaults to white', summary: '#fff'}},
},
color: {
control: 'color',
description: 'Icon color',
table: {defaultValue: {detail: 'Defaults to black', summary: '#000000'}},
},
symbol: {
control: 'select',
description: 'Icon name',
options: svgList,
table: {defaultValue: {detail: 'Defaults to none (empty string)', summary: '(empty string)'}}
}
}, },
}; };

View File

@@ -1,6 +1,8 @@
import type { Meta, StoryObj } from '@storybook/angular'; import type { Meta, StoryObj } from '@storybook/angular';
import { ExpenseIncomeCategoryByAccountDetailComponent } from '../../lib/molecules/expense-income-category-by-account-detail/expense-income-category-by-account-detail.component'; import { ExpenseIncomeCategoryByAccountDetailComponent } from '../../lib/molecules/expense-income-category-by-account-detail/expense-income-category-by-account-detail.component';
import { svgList } from '../svg-list'; import { amount, category, description, variant, whom } from '../control-constants/expense-income-detail';
import { backgroundColor } from '../control-constants/circled-icon';
import { color, symbol } from '../control-constants/svg';
const meta: Meta<ExpenseIncomeCategoryByAccountDetailComponent> = { const meta: Meta<ExpenseIncomeCategoryByAccountDetailComponent> = {
title: 'Molecules/ Expense Income Category By Account Detail', title: 'Molecules/ Expense Income Category By Account Detail',
@@ -13,33 +15,24 @@ const meta: Meta<ExpenseIncomeCategoryByAccountDetailComponent> = {
description: 'Urinary SO 1.5kg \nCuota 05/06', description: 'Urinary SO 1.5kg \nCuota 05/06',
variant: 'expense', variant: 'expense',
whom: 'Veterinaria', whom: 'Veterinaria',
/*iconProps */
iconProps: { iconProps: {
backgroundColor: '#f5ea42', backgroundColor: '#f5ea42',
color: '#ffffff', color: '#ffffff',
symbol: 'stethoscope-fill' symbol: 'stethoscope-fill'
}, },
/*iconProps */
backgroundColor: '#f5ea42', backgroundColor: '#f5ea42',
color: '#ffffff', color: '#ffffff',
symbol: 'stethoscope-fill', symbol: 'stethoscope-fill',
} as any, } as any,
argTypes: { argTypes: {
amount: { amount,
control: 'number',
description: 'Income/expense amount',
table: {defaultValue: {detail: 'Defaults to 0', summary: '0'}},
},
acumAmount: { acumAmount: {
control: 'number', control: 'number',
description: 'An accumulator for grouped income/expenses', description: 'An accumulator for grouped income/expenses',
table: {defaultValue: {detail: 'Defaults to 0', summary: '0'}}, table: {defaultValue: {detail: 'Defaults to 0', summary: '0'}},
}, },
category: { category,
control: 'text',
description: 'Expense/income category name',
table: {defaultValue: {detail: 'Defaults to none (empty string)', summary: '(empty string)'}},
},
checked: { checked: {
description: 'Emitted when the checkbox is clicked', description: 'Emitted when the checkbox is clicked',
table: { table: {
@@ -47,11 +40,7 @@ const meta: Meta<ExpenseIncomeCategoryByAccountDetailComponent> = {
type: { summary: 'EventEmitter<Boolean>', detail: 'Emits true if checked, false otherwise' }, type: { summary: 'EventEmitter<Boolean>', detail: 'Emits true if checked, false otherwise' },
}, },
}, },
description: { description,
control: 'text',
description: 'Expense/income description',
table: {defaultValue: {detail: 'Defaults to none (empty string)', summary: '(empty string)'}},
},
iconProps: { iconProps: {
control: 'object', control: 'object',
description: 'Properties for the rendered icon' description: 'Properties for the rendered icon'
@@ -61,37 +50,12 @@ const meta: Meta<ExpenseIncomeCategoryByAccountDetailComponent> = {
description: 'Whether or not the element should show a checkbox', description: 'Whether or not the element should show a checkbox',
table: {defaultValue: {detail: 'Defaults to false', summary: 'false'}} table: {defaultValue: {detail: 'Defaults to false', summary: 'false'}}
}, },
variant: { variant,
control: 'select', whom,
description: 'Kind of transaction',
options: [
'expense',
'income',
],
table: {defaultValue: {summary: "income", detail: "Income transaction"}},
},
whom: {
control: 'text',
description: 'Expense/income payer or payee',
table: {defaultValue: {detail: 'Defaults to none (empty string)', summary: '(empty string)'}},
},
/*icon props */ /*icon props */
backgroundColor: { backgroundColor: {...backgroundColor, table: {...backgroundColor.table, category: 'iconProps'}},
control: 'color', color: {...color, table: {...color.table, category: 'iconProps'}},
description: 'Circle background color', symbol: {...symbol, table: {...symbol.table, category: 'iconProps'}}
table: {defaultValue: {detail: 'Defaults to white', summary: '#fff'}, category: 'iconProps'},
},
color: {
control: 'color',
description: 'Icon color',
table: {defaultValue: {detail: 'Defaults to black', summary: '#000000'}, category: 'iconProps'},
},
symbol: {
control: 'select',
options: svgList,
description: 'Icon name',
table: {defaultValue: {detail: 'Defaults to none (empty string)', summary: '(empty string)'}, category: 'iconProps'}
}
} as any } as any
}; };
@@ -110,7 +74,7 @@ const Template: StoryObj<ExpenseIncomeCategoryByAccountDetailComponent> = {
<mw-expense-income-category-by-account-detail <mw-expense-income-category-by-account-detail
[acumAmount]="acumAmount" [acumAmount]="acumAmount"
[amount]="amount" [amount]="amount"
[iconProps]="{ symbol: symbol, color: color, backgroundColor: backgroundColor }" [iconProps]="{ symbol, color, backgroundColor }"
[category]="category" [category]="category"
[description]="description" [description]="description"
[showCheckbox]="showCheckbox" [showCheckbox]="showCheckbox"