-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Migrate stories 30..34 to controls (#37697)
- Loading branch information
Showing
8 changed files
with
110 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,52 @@ | ||
import {date, select, withKnobs} from '@storybook/addon-knobs'; | ||
|
||
import * as Preact from '#preact'; | ||
|
||
import {BentoDateDisplay} from '../component'; | ||
|
||
export default { | ||
title: 'DateDisplay', | ||
component: BentoDateDisplay, | ||
decorators: [withKnobs], | ||
argTypes: { | ||
datetime: { | ||
name: 'Date/time', | ||
control: {type: 'date'}, | ||
defaultValue: Date.now(), | ||
}, | ||
displayIn: { | ||
name: 'Display in', | ||
defaultValue: 'utc', | ||
options: ['utc', 'local'], | ||
control: {type: 'select'}, | ||
}, | ||
locale: { | ||
name: 'Locale', | ||
defaultValue: 'en-US', | ||
options: ['en-US', 'en-GB', 'fr', 'ru', 'ar', 'he', 'ja'], | ||
control: {type: 'select'}, | ||
}, | ||
}, | ||
}; | ||
|
||
const DISPLAY_IN_OPTIONS = ['utc', 'local']; | ||
const LOCALES = ['en-US', 'en-GB', 'fr', 'ru', 'ar', 'he', 'ja']; | ||
|
||
export const _default = () => { | ||
const dateTime = date('Date/time', new Date()); | ||
const displayIn = select( | ||
'Display in', | ||
DISPLAY_IN_OPTIONS, | ||
DISPLAY_IN_OPTIONS[0] | ||
); | ||
const locale = select('Locale', LOCALES, LOCALES[0]); | ||
export const Default = ({datetime, displayIn, locale, ...args}) => { | ||
return ( | ||
<BentoDateDisplay | ||
datetime={dateTime} | ||
datetime={datetime} | ||
displayIn={displayIn} | ||
locale={locale} | ||
render={(date) => ( | ||
<div>{`ISO: ${date.iso}; locale: ${date.localeString}`}</div> | ||
)} | ||
{...args} | ||
/> | ||
); | ||
}; | ||
|
||
export const defaultRenderer = () => { | ||
const displayIn = select( | ||
'Display in', | ||
DISPLAY_IN_OPTIONS, | ||
DISPLAY_IN_OPTIONS[0] | ||
); | ||
const dateTime = date('Date/time', new Date()); | ||
const locale = select('Locale', LOCALES, LOCALES[0]); | ||
export const DefaultRenderer = ({datetime, displayIn, locale, ...args}) => { | ||
return ( | ||
<BentoDateDisplay | ||
datetime={dateTime} | ||
datetime={datetime} | ||
displayIn={displayIn} | ||
locale={locale} | ||
{...args} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.