Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storybook: Fix broken import statements for DateTime component #27794

Merged
merged 1 commit into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.