import type {Meta, StoryObj} from '@storybook/web-components'; import { AutomationButtonDirection, AutomationButtonDirectonValueLabel, AutomationButtonSize, AutomationButtonStateLabel, AutomationButtonTagLabel, ObcAutomationButton, } from './automation-button'; import './automation-button'; import {html} from 'lit'; import '../../icons/icon-twoway-digital-open'; import '../../icons/icon-twoway-digital-closed'; import '../../icons/icon-switch-horizontal-on'; import '../../icons/icon-switch-horizontal-off'; import '../../icons/icon-damper-horizontal-on'; import '../../icons/icon-damper-horizontal-off'; import '../../components/badge/badge'; import '../../icons/icon-alert-off-google'; import '../../icons/icon-auto'; import '../../icons/icon-duty'; import '../../icons/icon-pump-on-horizontal'; import '../../icons/icon-pump-off-horizontal'; import '../valve-analog-three-way-icon/valve-analog-three-way-icon'; import '../../icons/icon-command-locked-f'; import {BadgeSize} from '../../components/badge/badge'; import {crossDecorator} from '../../storybook-util'; const meta: Meta = { title: 'Automation/Button', tags: ['autodocs'], component: 'obc-automation-button', decorators: [crossDecorator], argTypes: { size: { options: ['small', 'regular', 'large', 'xl'], control: {type: 'radio'}, }, labelPosition: { options: ['top', 'bottom', 'left', 'right'], control: {type: 'radio'}, }, labelSize: { options: ['small', 'regular', 'enhanced'], control: {type: 'radio'}, }, labelStyle: { options: ['regular', 'enhanced', 'active'], control: {type: 'radio'}, }, alert: { control: {type: 'boolean'}, }, direction: { options: [ 'forward', 'forward-fast', 'forward-stopped', 'backward', 'backward-fast', 'backward-stopped', 'standby', ], control: {type: 'radio'}, }, }, args: { size: 'regular', labelPosition: 'bottom', labelSize: 'regular', labelStyle: 'regular', }, parameters: { // Overrides the default behavior and pauses the animation at the first frame at the component level for all stories. chromatic: {pauseAnimationAtEnd: false}, }, } satisfies Meta; export default meta; type Story = StoryObj; export const ValveOpen: Story = { render(args) { const labels = [ { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; return html` `; }, }; export const ValveAlert: Story = { args: { alert: true, }, render(args) { const labels = [ { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; return html` `; }, }; export const ValveBadges: Story = { render(args) { const labels = [ { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; const badgeSize = [ AutomationButtonSize.small, AutomationButtonSize.regular, ].includes(args.size) ? BadgeSize.regular : BadgeSize.large; return html` `; }, }; export const ValveProgress: Story = { args: { progress: true, }, render(args) { const labels = [ { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; return html` `; }, }; export const ValveClosed: Story = { render(args) { const labels = [ { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; return html` `; }, }; export const SwitchOn: Story = { render(args) { const labels = [ {type: 'state', text: 'On', bold: true} as AutomationButtonStateLabel, { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; return html` `; }, }; export const SwitchOff: Story = { render(args) { const labels = [ {type: 'state', text: 'Off', bold: false} as AutomationButtonStateLabel, { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; return html` `; }, }; export const DamperOn: Story = { render(args) { const labels = [ {type: 'state', text: 'On', bold: true} as AutomationButtonStateLabel, { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; return html` `; }, }; export const DamperOff: Story = { render(args) { const labels = [ {type: 'state', text: 'Off', bold: false} as AutomationButtonStateLabel, { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; return html` `; }, }; export const DamperBadges: Story = { render(args) { const labels = [ {type: 'state', text: 'On', bold: true} as AutomationButtonStateLabel, { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; const badgeSize = [ AutomationButtonSize.small, AutomationButtonSize.regular, ].includes(args.size) ? BadgeSize.regular : BadgeSize.large; return html` `; }, }; export const MotorOn: Story = { args: { direction: AutomationButtonDirection.forward, }, render(args) { const labels = [ {type: 'state', text: 'On', bold: true} as AutomationButtonStateLabel, { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; return html` `; }, }; export const MotorOff: Story = { args: { direction: 'forward-stopped', }, render(args) { const labels = [ {type: 'state', text: 'Off', bold: false} as AutomationButtonStateLabel, { type: 'tag', text: '0000', showHash: false, } as AutomationButtonTagLabel, ]; return html` `; }, }; export const ThreeWayValveOpenRight: Story = { argTypes: { value: { control: {type: 'range', min: 0, max: 100, step: 1}, }, }, args: { value: 70, }, render(args) { const labels = [ { nDigits: 3, type: 'direction', unit: 'percent', value: 100 - args.value, direction: 'up', } as AutomationButtonDirectonValueLabel, { nDigits: 3, type: 'direction', unit: 'percent', value: args.value, direction: 'right', } as AutomationButtonDirectonValueLabel, { type: 'tag', text: '0000', showHash: true, } as AutomationButtonTagLabel, ]; return html` `; }, };