Skip to content

Commit

Permalink
Storybook: Fix broken import statements for DateTime component (#27794)
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo authored Dec 18, 2020
1 parent 29bb0e6 commit 229d54b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 54 deletions.
37 changes: 35 additions & 2 deletions packages/components/src/date-time/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { boolean } from '@storybook/addon-knobs';
import { boolean, button } from '@storybook/addon-knobs';

/**
* WordPress dependencies
Expand All @@ -11,7 +11,7 @@ import { useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import { DateTimePicker } from '../';
import DateTimePicker from '../';

export default {
title: 'Components/DateTimePicker',
Expand All @@ -34,3 +34,36 @@ export const _default = () => {
const is12Hour = boolean( 'Is 12 hour (shows AM/PM)', false );
return <DateTimePickerWithState is12Hour={ is12Hour } />;
};

// Date utils, for demo purposes.
const DAY_IN_MS = 24 * 60 * 60 * 1000;
const aFewDaysAfter = ( date ) => {
// eslint-disable-next-line no-restricted-syntax
return new Date( date.getTime() + ( 1 + Math.random() * 5 ) * DAY_IN_MS );
};

const now = new Date();

export const WithDaysHighlighted = () => {
const [ date, setDate ] = useState( now );

const [ highlights, setHighlights ] = useState( [
{ date: aFewDaysAfter( now ) },
] );

button( 'Add random highlight', () => {
const lastHighlight = highlights[ highlights.length - 1 ];
setHighlights( [
...highlights,
{ date: aFewDaysAfter( lastHighlight.date ) },
] );
} );

return (
<DateTimePicker
currentDate={ date }
onChange={ setDate }
events={ highlights }
/>
);
};
52 changes: 0 additions & 52 deletions packages/components/src/date-time/stories/with-days-highlighted.js

This file was deleted.

0 comments on commit 229d54b

Please sign in to comment.