Update DateTimePickerControl's popover styling to work with slot-fill (#35343)
* Tweak CSS styling of popover to accommodate usage with slot-fill * Story for DateTimePickerControl use with slot-fill * Changelog
This commit is contained in:
parent
254fbd994f
commit
17fe37cafe
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Fix DateTimePickerControl's popover styling when slot-fill is used.
|
|
@ -5,7 +5,9 @@
|
|||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.components-datetime__date {
|
||||
border-top: 0;
|
||||
&__popover {
|
||||
.components-datetime__date {
|
||||
border-top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,6 +280,9 @@ export const DateTimePickerControl: React.FC< DateTimePickerControlProps > = ( {
|
|||
/>
|
||||
</BaseControl>
|
||||
) }
|
||||
popoverProps={ {
|
||||
className: 'woocommerce-date-time-picker-control__popover',
|
||||
} }
|
||||
renderContent={ () => {
|
||||
const Picker = isDateOnlyPicker ? DatePicker : WpDateTimePicker;
|
||||
const inputDateTime = parseAsLocalDateTime( inputString );
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
* External dependencies
|
||||
*/
|
||||
import React from 'react';
|
||||
import { Button } from '@wordpress/components';
|
||||
import { Button, Popover, SlotFillProvider } from '@wordpress/components';
|
||||
import { createElement, useState } from '@wordpress/element';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { DateTimePickerControl } from '../';
|
||||
import { DateTimePickerControl, defaultDateFormat } from '../';
|
||||
|
||||
export default {
|
||||
title: 'WooCommerce Admin/components/DateTimePickerControl',
|
||||
|
@ -147,3 +147,30 @@ ControlledDateOnlyEndOfDay.args = {
|
|||
timeForDateOnly: 'end-of-day',
|
||||
};
|
||||
ControlledDateOnlyEndOfDay.decorators = Controlled.decorators;
|
||||
|
||||
function PopoverSlotDecorator( Story, props ) {
|
||||
return (
|
||||
<div>
|
||||
<SlotFillProvider>
|
||||
<div>
|
||||
<Story
|
||||
args={ {
|
||||
...props.args,
|
||||
} }
|
||||
/>
|
||||
</div>
|
||||
<Popover.Slot />
|
||||
</SlotFillProvider>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const WithPopoverSlot = Template.bind( {} );
|
||||
WithPopoverSlot.args = {
|
||||
...Basic.args,
|
||||
label: 'Start date',
|
||||
placeholder: 'Enter the start date',
|
||||
help: 'There is a SlotFillProvider and Popover.Slot on the page',
|
||||
isDateOnlyPicker: true,
|
||||
};
|
||||
WithPopoverSlot.decorators = [ PopoverSlotDecorator ];
|
||||
|
|
Loading…
Reference in New Issue