corvée(dépendances) ajoute Carbon Fields
This commit is contained in:
parent
135cc65eed
commit
62368587e5
459 changed files with 72750 additions and 26 deletions
96
web/vendor/htmlburger/carbon-fields/packages/blocks/fields/datetime/index.js
vendored
Normal file
96
web/vendor/htmlburger/carbon-fields/packages/blocks/fields/datetime/index.js
vendored
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
* External dependencies.
|
||||
*/
|
||||
import { format } from '@wordpress/date';
|
||||
import { Component } from '@wordpress/element';
|
||||
import { addFilter } from '@wordpress/hooks';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
/**
|
||||
* Internal dependencies.
|
||||
*/
|
||||
import './style.scss';
|
||||
|
||||
class DateTimeField extends Component {
|
||||
/**
|
||||
* Handles the change.
|
||||
*
|
||||
* @param {Date[]} selectedDates
|
||||
* @param {string} selectedDateStr
|
||||
* @return {void}
|
||||
*/
|
||||
handleChange = ( selectedDates, selectedDateStr ) => {
|
||||
const {
|
||||
id,
|
||||
onChange,
|
||||
value,
|
||||
field
|
||||
} = this.props;
|
||||
|
||||
const formattedDate = format( field.storage_format, selectedDateStr );
|
||||
|
||||
if ( formattedDate !== value ) {
|
||||
onChange( id, formattedDate );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the component.
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
render() {
|
||||
const { handleChange } = this;
|
||||
const { children } = this.props;
|
||||
|
||||
return children( {
|
||||
handleChange
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
addFilter( 'carbon-fields.date_time.block', 'carbon-fields/blocks', ( OriginalDateTimeField ) => ( props ) => {
|
||||
return (
|
||||
<DateTimeField { ...props }>
|
||||
{ ( {
|
||||
handleChange
|
||||
} ) => (
|
||||
<OriginalDateTimeField
|
||||
buttonText={ __( 'Select Date', 'carbon-fields-ui' ) }
|
||||
{ ...props }
|
||||
onChange={ handleChange }
|
||||
/>
|
||||
) }
|
||||
</DateTimeField>
|
||||
);
|
||||
} );
|
||||
|
||||
addFilter( 'carbon-fields.date.block', 'carbon-fields/blocks', ( OriginalDateField ) => ( props ) => {
|
||||
return (
|
||||
<DateTimeField { ...props }>
|
||||
{ ( {
|
||||
handleChange
|
||||
} ) => (
|
||||
<OriginalDateField
|
||||
{ ...props }
|
||||
onChange={ handleChange }
|
||||
/>
|
||||
) }
|
||||
</DateTimeField>
|
||||
);
|
||||
} );
|
||||
|
||||
addFilter( 'carbon-fields.time.block', 'carbon-fields/blocks', ( OriginalTimeField ) => ( props ) => {
|
||||
return (
|
||||
<DateTimeField { ...props }>
|
||||
{ ( {
|
||||
handleChange
|
||||
} ) => (
|
||||
<OriginalTimeField
|
||||
{ ...props }
|
||||
onChange={ handleChange }
|
||||
/>
|
||||
) }
|
||||
</DateTimeField>
|
||||
);
|
||||
} );
|
||||
44
web/vendor/htmlburger/carbon-fields/packages/blocks/fields/datetime/style.scss
vendored
Normal file
44
web/vendor/htmlburger/carbon-fields/packages/blocks/fields/datetime/style.scss
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* ==========================================================================
|
||||
DateTime
|
||||
========================================================================== */
|
||||
|
||||
.cf-datetime__inner {
|
||||
.edit-post-sidebar & {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.edit-post-sidebar &::before {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 9px;
|
||||
display: inline-block;
|
||||
margin-top: -10px;
|
||||
}
|
||||
}
|
||||
|
||||
.cf-datetime__input {
|
||||
.wp-block .cf-field & {
|
||||
min-width: 0;
|
||||
border-color: $wp-color-gray-light-500;
|
||||
border-radius: 0;
|
||||
|
||||
&:focus {
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
.edit-post-sidebar .cf-field & {
|
||||
padding-left: 35px;
|
||||
}
|
||||
}
|
||||
|
||||
.cf-datetime__button {
|
||||
.wp-block & {
|
||||
height: auto;
|
||||
border-color: $wp-color-gray-light-500;
|
||||
}
|
||||
|
||||
.edit-post-sidebar & {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue