corvée(dépendances) ajoute Carbon Fields

This commit is contained in:
gcch 2024-08-09 18:45:01 +02:00
commit 62368587e5
459 changed files with 72750 additions and 26 deletions

View file

@ -0,0 +1,55 @@
/**
* External dependencies.
*/
import { addFilter } from '@wordpress/hooks';
import { select } from '@wordpress/data';
import { get, find } from 'lodash';
/**
* Carbon Fields dependencies.
*/
import { withProps } from '@carbon-fields/core';
/**
* Internal dependencies.
*/
import './style.scss';
addFilter( 'carbon-fields.association.block', 'carbon-fields/blocks', withProps( ( props ) => {
return {
hierarchyResolver() {
// Get the block that contains the field.
const block = select( 'core/block-editor' ).getBlock( props.blockId );
// Get the path.
const path = props.id.split( '__' );
// Remove the chunk that contains the block identifier.
path.shift();
// Get the hierarchy.
let hierarchy = path.shift();
let accessor = `data.${ hierarchy }`;
// Visit every branch in the tree so we can get the full hierarchy.
while ( path.length > 0 ) {
const chunk = path.shift();
const isGroup = chunk.indexOf( 'cf-' ) === 0;
if ( isGroup ) {
const groups = get( block.attributes, `${ accessor }` );
const group = find( groups, [ '_id', chunk ] );
const groupIndex = groups.indexOf( group );
accessor = `${ accessor }.${ groupIndex }`;
hierarchy = `${ hierarchy }[${ groupIndex }]:${ group._type }/`;
} else {
accessor = `${ accessor }.${ chunk }`;
hierarchy = `${ hierarchy }${ chunk }`;
}
}
return hierarchy;
}
};
} ) );

View file

@ -0,0 +1,72 @@
/* ==========================================================================
Association
========================================================================== */
.cf-association__cols {
.block-editor & {
border-top-width: 1px;
margin-top: 4px;
}
.edit-post-sidebar & {
border-color: $gb-dark-gray-150;
flex-direction: column;
}
.edit-post-sidebar &::before {
background-color: $gb-dark-gray-150;
display: none;
}
}
.cf-association__counter {
.edit-post-sidebar & {
display: none;
}
}
.cf-association__option {
.edit-post-sidebar & {
height: 40px;
}
.edit-post-sidebar & + & {
border-top-color: $gb-dark-gray-150;
}
}
.cf-association__option-thumb {
.edit-post-sidebar & {
display: none;
}
}
.cf-association__option-content {
.edit-post-sidebar & {
align-items: flex-start;
flex-direction: column;
min-width: 0;
}
}
.cf-association__option-title {
.edit-post-sidebar & {
width: 100%;
}
}
.cf-association__option-actions {
.edit-post-sidebar .cf-association__col:first-child & {
min-width: 0;
}
.edit-post-sidebar & {
margin-left: auto;
}
}
.cf-association__option-action {
.edit-post-sidebar &--edit {
display: none;
}
}