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

feat (inner column block): display name as "Slide" if used as childre… #3071

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions src/block/column/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* External dependencies
*/
import { ColumnIcon } from '~stackable/icons'
import { i18n } from 'stackable'

/**
* Internal dependencies
Expand All @@ -20,6 +21,7 @@ import metadata from './block.json'
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n'
import { select } from '@wordpress/data'

export const settings = {
...metadata,
Expand All @@ -38,4 +40,26 @@ export const settings = {
deprecated,
edit,
save,

__experimentalLabel: ( attributes, { context } ) => {
const customName = attributes?.metadata?.name
if ( context === 'list-view' && customName ) {
return customName
}

if ( context === 'list-view' && attributes?.uniqueId ) {
const { getEditorDom } = select( 'stackable/editor-dom' )
const editorDom = getEditorDom()
const isCarouselSlide = editorDom?.querySelector( `.stk-block-carousel__slider > * > * > * > * > [data-block-id="${ attributes.uniqueId }"]` )
if ( isCarouselSlide ) {
return __( 'Slide', i18n )
}
const isHorizontalScroller = editorDom?.querySelector( `.stk-block-horizontal-scroller > * > * > * > * > * > [data-block-id="${ attributes.uniqueId }"]` )
if ( isHorizontalScroller ) {
return __( 'Slide', i18n )
}
}

return ''
},
}
Loading