Skip to content

Commit

Permalink
feat(storybook): predefined formats now come from a separate object
Browse files Browse the repository at this point in the history
  • Loading branch information
Strider2342 committed Nov 8, 2024
1 parent 3bce5ea commit d698f0d
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions apps/react-storybook/stories/chat/Chat.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,18 @@ export const Customization: Story = {
}
}

const formattingOptions = ['shortdate', 'shorttime', 'yyyy-mm-dd hh:mm:ss', 'hh:mm:ss', 'longdate', 'longtime', 'none'];

const formattingControlMappings = {
['shortdate']: 'shortdate',
['shorttime']: 'shorttime',
['yyyy-mm-dd hh:mm:ss']: 'yyyy-mm-dd hh:mm:ss',
['hh:mm:ss']: 'hh:mm:ss',
['longdate']: 'longdate',
['longtime']: 'longtime',
['none']: null,
};

export const Formatting: Story = {
args: {
dayHeaderFormat: 'shortdate',
Expand All @@ -399,30 +411,14 @@ export const Formatting: Story = {
argTypes: {
dayHeaderFormat: {
control: 'select',
options: ['shortdate', 'shorttime', 'yyyy-mm-dd hh:mm:ss', 'hh:mm:ss', 'longdate', 'longtime', 'none'],
mapping: {
['shortdate']: 'shortdate',
['shorttime']: 'shorttime',
['yyyy-mm-dd hh:mm:ss']: 'yyyy-mm-dd hh:mm:ss',
['hh:mm:ss']: 'hh:mm:ss',
['longdate']: 'longdate',
['longtime']: 'longtime',
['none']: null,
},
defaultValue: 'shorttime',
options: [ ...formattingOptions ],
mapping: { ...formattingControlMappings },
defaultValue: 'shortdate',
},
messageTimestampFormat: {
control: 'select',
options: ['shortdate', 'shorttime', 'yyyy-mm-dd hh:mm:ss', 'hh:mm:ss', 'longdate', 'longtime', 'none'],
mapping: {
['shortdate']: 'shortdate',
['shorttime']: 'shorttime',
['yyyy-mm-dd hh:mm:ss']: 'yyyy-mm-dd hh:mm:ss',
['hh:mm:ss']: 'hh:mm:ss',
['longdate']: 'longdate',
['longtime']: 'longtime',
['none']: null,
},
options: [ ...formattingOptions ],
mapping: { ...formattingControlMappings },
defaultValue: 'shorttime',
},
},
Expand Down

0 comments on commit d698f0d

Please sign in to comment.