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: granular plugin setting #3319

Open
wants to merge 33 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dcbd7f4
feat: allow enabling, disabling and hiding of blocks
Arukuen Sep 3, 2024
e03a884
feat: add enable settings to toolbar features
Arukuen Sep 10, 2024
4920cb4
feat: add settings store for tracking changes
Arukuen Sep 23, 2024
1439e8f
feat: settings content organizaiont
Arukuen Sep 23, 2024
81cd300
feat: style for sidenav
Arukuen Sep 23, 2024
a494402
feat: sidenav, organization, disabling blocks, and save changes
Arukuen Sep 23, 2024
4087625
fix: change blockstate from 0-2 to 1-3 to avoid nfalsy 0
Arukuen Sep 23, 2024
39ce02b
feat: add min height to sidenav
Arukuen Sep 30, 2024
a18971e
feat: remove template since we will use react instead
Arukuen Sep 30, 2024
7b842c2
feat: use react approach for cleaner and more efficient code
Arukuen Sep 30, 2024
3e8b25d
feat: admin notice when settings are saved
Arukuen Oct 1, 2024
8e76a0a
feat: integrate pro-related settings
Arukuen Oct 1, 2024
233e05f
fix: conditional lazy loading of pro settings
Arukuen Oct 3, 2024
c8b74a7
feat: integrate missing settings such as icon, pro notice, tooltip
Arukuen Oct 5, 2024
c3adc23
feat: add stackable global settings
Arukuen Oct 5, 2024
5ed2b62
Merge branch 'develop' into feat-granular-plugin-setting
Arukuen Oct 5, 2024
d151983
fix: indentation from merge conflict
Arukuen Oct 5, 2024
14c6d7f
feat: apply global settings by conditional registering
Arukuen Oct 6, 2024
7f9bf2f
feat: search functionality integration
Arukuen Oct 14, 2024
5859c58
feat: application of search highlight through conditional classes
Arukuen Oct 14, 2024
7469539
feat: search highlight style
Arukuen Oct 14, 2024
22818bb
feat: admin toolbar setting
Arukuen Oct 15, 2024
ce74380
feat: util function for substituting to disabled blocks
Arukuen Oct 16, 2024
ffbea73
fix: disabling and hiding block variations
Arukuen Oct 21, 2024
343b20a
feat: disable/enable confirmation, disable/enable/hide all blocks
Arukuen Oct 24, 2024
1354cb9
feat: removeChildIfDisabled
Arukuen Oct 24, 2024
56551e1
feat: first batch of core substitution and removal integration
Arukuen Oct 24, 2024
fadc1a4
fix: blockname typo
Arukuen Oct 24, 2024
6243f42
Revert "feat: first batch of core substitution and removal integration"
Arukuen Oct 25, 2024
c9175f9
feat: piggyback on the filter instead of manual change in variations,…
Arukuen Oct 26, 2024
f6a8104
feat: special integration for blocks with no variation/neet to remove
Arukuen Oct 26, 2024
c92aa4f
feat: integrate card default-2 with social-links
Arukuen Oct 26, 2024
2cdc940
fix: styles and media queries, spinner on saved
Arukuen Oct 28, 2024
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
12 changes: 11 additions & 1 deletion src/block/card/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ImageFaded from './images/faded.svg'
* External dependencies
*/
import { i18n, isPro } from 'stackable'
import { substituteIfDisabled } from '~stackable/util'

/**
* WordPress dependencies
Expand Down Expand Up @@ -105,7 +106,7 @@ const variations = applyFilters(
bottom: 0,
left: 0,
},
}, [
}, [ substituteIfDisabled( [ 'stackable/button-group|social-buttons', 'stackable/button-group|icon-button' ],
[ 'stackable/button-group', {
columnSpacing: {
top: 0,
Expand All @@ -132,6 +133,15 @@ const variations = applyFilters(
className: 'is-style-plain',
} ],
] ],
[ 'core/social-links',
{
align: 'right',
},
[
[ 'core/social-link', { service: 'facebook' } ],
[ 'core/social-link', { service: 'twitter' } ],
],
] ),
] ],
] ],
],
Expand Down
5 changes: 3 additions & 2 deletions src/block/icon-box/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { useBlockContext } from '~stackable/hooks'
import {
withBlockAttributeContext, withBlockWrapperIsHovered, withQueryLoopContext,
} from '~stackable/higher-order'
import { substituteCoreIfDisabled } from '~stackable/util'

/**
* WordPress dependencies
Expand All @@ -49,9 +50,9 @@ export const TEMPLATE = [
text: __( 'Icon Box', i18n ), hasP: true, textTag: 'h4',
} ],
] ],
[ 'stackable/text', {
substituteCoreIfDisabled( 'stackable/text', {
text: 'Description for this block. Use this space for describing your block.',
} ],
} ),
]

const Edit = props => {
Expand Down
9 changes: 5 additions & 4 deletions src/block/notification/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { i18n, isPro } from 'stackable'
import { removeChildIfDisabled } from '~stackable/util'

/**
* WordPress dependencies
Expand Down Expand Up @@ -37,7 +38,7 @@ const variations = applyFilters(
pickerTitle: __( 'Default', i18n ),
pickerIcon: ImageDefault,
isActive: [ 'className' ],
innerBlocks: [
innerBlocks: removeChildIfDisabled( 'stackable/icon', [
[ 'stackable/icon', {
icon: '<svg data-prefix="fas" data-icon="exclamation-triangle" class="svg-inline--fa fa-exclamation-triangle fa-w-18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" aria-hidden="true" width="32" height="32"><path fill="currentColor" d="M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"></path></svg>',
iconColor1: '#FFFFFF',
Expand All @@ -62,7 +63,7 @@ const variations = applyFilters(
},
} ],
] ],
],
] ),
scope: [ 'block' ],
},
{
Expand All @@ -83,7 +84,7 @@ const variations = applyFilters(
pickerTitle: __( 'Plain', i18n ),
pickerIcon: ImagePlain,
isActive: [ 'className' ],
innerBlocks: [
innerBlocks: removeChildIfDisabled( 'stackable/icon', [
[ 'stackable/icon', {
icon: '<svg data-prefix="fas" data-icon="exclamation-triangle" class="svg-inline--fa fa-exclamation-triangle fa-w-18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" aria-hidden="true" width="32" height="32"><path fill="currentColor" d="M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"></path></svg>',
iconColor1: 'var(--stk-container-background-color, #40ba7b)',
Expand Down Expand Up @@ -111,7 +112,7 @@ const variations = applyFilters(
},
} ],
] ],
],
] ),
scope: [ 'block' ],
},
{
Expand Down
19 changes: 17 additions & 2 deletions src/block/team-member/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Internal dependencies
*/
import { i18n, isPro } from 'stackable'
import { substituteIfDisabled } from '~stackable/util'

/**
* WordPress dependencies
Expand Down Expand Up @@ -53,6 +54,14 @@ import ImageCover from './images/cover.svg'
],
]

const socialLinksInnerBlocks = [
[ 'core/social-link', { service: 'facebook' } ],
[ 'core/social-link', { service: 'twitter' } ],
[ 'core/social-link', { service: 'instagram' } ],
[ 'core/social-link', { service: 'youtube' } ],
[ 'core/social-link', { service: 'linkedin' } ],
]

const variations = applyFilters(
'stackable.team-member.variations',
[
Expand All @@ -77,7 +86,10 @@ const variations = applyFilters(
text: __( 'Position', i18n ),
} ],
[ 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do. Description for this block. You can use this space for describing your block.', 'Content placeholder', i18n ) } ],
[ 'stackable/button-group', {}, buttonGroupInnerBlocks ],
substituteIfDisabled( [ 'stackable/button-group|social-buttons', 'stackable/button-group|icon-button' ],
[ 'stackable/button-group', {}, buttonGroupInnerBlocks ],
[ 'core/social-links', { align: 'center' }, socialLinksInnerBlocks ],
),
],
scope: [ 'block' ],
},
Expand All @@ -98,7 +110,10 @@ const variations = applyFilters(
[ 'stackable/subtitle', {
text: __( 'Position', i18n ),
} ],
[ 'stackable/button-group', {}, buttonGroupInnerBlocks ],
substituteIfDisabled( [ 'stackable/button-group|social-buttons', 'stackable/button-group|icon-button' ],
[ 'stackable/button-group', {}, buttonGroupInnerBlocks ],
[ 'core/social-links', { align: 'center' }, socialLinksInnerBlocks ],
),
],
scope: [ 'block' ],
},
Expand Down
5 changes: 3 additions & 2 deletions src/block/timeline/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
withQueryLoopContext,
} from '~stackable/higher-order'
import { range } from 'lodash'
import { substituteCoreIfDisabled } from '~stackable/util'

/**
* WordPress dependencies
Expand All @@ -68,9 +69,9 @@ const TEMPLATE = [
left: 0,
},
}, [
[ 'stackable/text', {
substituteCoreIfDisabled( 'stackable/text', {
text: _x( 'Description for this block. Use this space for describing your block. Any text will do.', 'Content placeholder', i18n ),
} ],
} ),
] ],
]

Expand Down
7 changes: 5 additions & 2 deletions src/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import './disabled-blocks'
* External dependencies
*/
import { i18n } from 'stackable'
import { addStackableBlockCategory, registerBlockType } from '~stackable/util'
import {
addStackableBlockCategory,
registerBlockType,
} from '~stackable/util'
import { withVisualGuideContext } from '~stackable/higher-order'

/**
Expand Down Expand Up @@ -45,7 +48,7 @@ const importAllAndRegister = r => {
settings.keywords = settings.keywords.map( keyword => __( keyword, i18n ) ) // eslint-disable-line @wordpress/i18n-no-variables
}

// Register the block.
// Register the block if it's not already registered and not disabled.
if ( ! getBlockType( name ) ) {
registerBlockType( name, settings )
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/admin-base-setting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ let i = 1

const AdminBaseSetting = props => {
const [ uid ] = useState( `ugb-admin-setting-${ i++ }` )
const isSearched = props.searchTerm && props.label.toLowerCase().includes( props.searchTerm )
const mainClasses = classnames( [
'ugb-admin-setting',
props.className,
], {
[ `ugb-admin-setting--${ props.size }` ]: props.size,
'ugb-admin-setting--highlight': isSearched,
'ugb-admin-setting--not-highlight': props.searchTerm && ! isSearched,
} )

return (
Expand Down
14 changes: 14 additions & 0 deletions src/components/admin-toolbar-setting/editor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.ugb-admin-toolbar-setting__wrapper {
display: flex;
a {
margin-right: 10px;
width: 80px;
}
.ugb-admin-toolbar-setting {
display: flex;
.ugb-button-component {
padding: 14px;
width: 100%;
}
}
}
74 changes: 74 additions & 0 deletions src/components/admin-toolbar-setting/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import AdminBaseSetting from '../admin-base-setting'
import Button from '../button'
import { ButtonGroup } from '@wordpress/components'
import { __ } from '@wordpress/i18n'
import { i18n } from 'stackable'

const AdminToolbarSetting = props => {
return (
<AdminBaseSetting { ...props }>
<div className="ugb-admin-toolbar-setting__wrapper">
<a
href={ props.demoLink }
target="_blank"
rel="noopener noreferrer"
onClick={ ev => ev.stopPropagation() }
>
{ __( 'view demo', i18n ) }
</a>
<ButtonGroup
children={
props.controls.map( option => {
const isSelected = props.value ? props.value === option.value : props.placeholder === option.value
const tabindex = isSelected ? '0' : '-1'

return <Button
style={ option.selectedColor && isSelected ? { backgroundColor: option.selectedColor } : {} }
isPrimary={ ! option.selectedColor && isSelected }
key={ option.value }
label={ option.title || props.label }
tabIndex={ tabindex }
aria-pressed={ isSelected }
isSmall={ props.isSmall }
onClick={ () => {
if ( option.value === props.value ) {
return
}
props.onChange( option.value )
} }
onKeyDown={ e => {
const el = e.target
if ( el ) {
// On right, select the next value or loop to first.
if ( e.keyCode === 39 ) {
const nextEl = el.nextElementSibling || el.parentElement.firstElementChild
nextEl.focus()
nextEl.click()

// Trigger click on the previous option or loop to last.
} else if ( e.keyCode === 37 ) {
const prevEl = el.previousElementSibling || el.parentElement.lastElementChild
prevEl.focus()
prevEl.click()
}
}
} }
children={ <span className="ugb-admin-toolbar-setting__option">{ option.title }</span> }
/>
} )
}
className="ugb-admin-toolbar-setting"
/>
</div>
</AdminBaseSetting>
)
}

AdminToolbarSetting.defaultProps = {
controls: [],
label: '',
value: '',
onChange: () => {},
}

export default AdminToolbarSetting
Loading
Loading