Skip to content

Commit a4c9bbd

Browse files
kaeizenArukuenGambitbfintal
authored
Feat: Global Color Schemes (#3457)
* init * feat: inspector-sub-header for new global settings * working responsive in editor and frontend * hover state * hover states * fix: use onClick properly * feat: global font pairs * fix: use new scraped font pairs; adjust code to simpler json structure * fix: make scrolling to current font pair independent from current view * fix: rename stackable_font_pair_name to stackable_selected_font_pair * fix: rename stackable_font_pair_name to stackable_selected_font_pair, reset previous commit * fix: move bulk of code to FontPairPicker, restructure with consistent naming * apply other block layouts * init * change request part 1 * feat: separate pro features * fix: proper resetting in editingMode and in not * feat: add confirmation when changing font pair while dirty * styling tweaks * fix: make typography settings headings consistent * fix: error when no previously selected font pair * fix: pro notice update, translation, renaming default theme * change request part 2 -hover state notice -orange indicator -reset button -bug fixes * fix: move editingMode to pro code * fix: error when resetting * change block components placeholder * fix: reset display bug * fix css * feat: inspector-sub-header for new global settings * fix: use onClick properly * feat: global font pairs * fix: use new scraped font pairs; adjust code to simpler json structure * fix: make scrolling to current font pair independent from current view * fix: rename stackable_font_pair_name to stackable_selected_font_pair * fix: rename stackable_font_pair_name to stackable_selected_font_pair, reset previous commit * fix: move bulk of code to FontPairPicker, restructure with consistent naming * feat: separate pro features * styling tweaks * fix: proper resetting in editingMode and in not * feat: add confirmation when changing font pair while dirty * fix: make typography settings headings consistent * fix: error when no previously selected font pair * fix: pro notice update, translation, renaming default theme * fix: move editingMode to pro code * fix: error when resetting * fix: reset display bug * Revert "Merge branch 'feat/3448-global-font-pairs' of https://github.com/gambitph/Stackable into feat/3448-global-font-pairs" This reverts commit 52ca1c1, reversing changes made to 889ed65. * fix: pro notice button * separate into spacing and borders, buttons and icons * fix code * rename functions * fix four range control initial position * border width in block editor override default * include defaults.json * add script for animation if block layout has hover * fix bug (border width and border type) * add import * tweaks to the reset all button * fix borderWidth override * fix breakpoints - use only 1 hook - fix typography breakpoint issue * fix hover animations, use stackable_frontend_css * add desc and tooltips * fix bug with shadow colors that uses rgba * tweaked and rearranged settings. added correct docs. updated text * use block-design-system.json * remove defaults.json from buildInclude in gulp * add documentation * custom icons * update block-design-system files * create array/object for four-range values * default color schemes - add color scheme attributes - save default color schemes to database * add presets, proControl, filters for premium * fix missing cssvar * add reset and delete func, rearranged stuff * fix block color scheme selector * update pro notice * init apply color scheme styles * apply color schemes to editor and frontend * remove bg color for :root * fix typo * fix color schemes if empty * update comment * update preset picker, add duplicate fx * show color scheme colors in picker * fix add function, fix frontend if default is empty * only add colors that have value in the picker * move toggle to color palette, rearrange settings * update global colors test * update global-settings test * hover state * update toggle in color palette * update color scheme preview and color picker * fix preview in edit * fix color palette controls * update editor loader * apply parent-hover styles on frontend, add theme compatibility * hover states * fix array_map function * fix other array_map functions * fix theme compatibility * add more presets, move theme compatibility code * add documentation * Update src/components/pro-control/index.js [skip ci] * fix for moving background image on hover * remove static from function * minor fixes translatable text, use lodash's kebabCase, add prefix, use array_column, rename namespace * cache color scheme css --------- Co-authored-by: Alquen Sarmiento <[email protected]> Co-authored-by: Gambit <[email protected]> Co-authored-by: [email protected] <> Co-authored-by: Benjamin Intal <[email protected]>
1 parent 8e4a0ce commit a4c9bbd

File tree

61 files changed

+2644
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2644
-96
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
"css",
1212
"scss"
1313
]
14-
}
14+
}

e2e/tests/global-settings.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ test.describe( 'Global Settings', () => {
139139
await defaultBlockPage.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click()
140140

141141
// The default timeout is 30s, extend it to 90s
142-
const updateRequest = defaultBlockPage.waitForResponse( response => response.url().includes( 'update_block_style' ) && response.request().method() === 'POST', { timeout: 90_000 } )
142+
const updateRequest = defaultBlockPage.waitForRequest( request => request.url().includes( 'update_block_style' ) && request.method() === 'POST', { timeout: 90_000 } )
143143

144144
// In older WP versions, the button text is 'Update' instead of 'Save'
145145
if ( await defaultBlockPage.getByRole( 'button', {

plugin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ function is_frontend() {
233233
require_once( plugin_dir_path( __FILE__ ) . 'src/global-settings.php' );
234234
require_once( plugin_dir_path( __FILE__ ) . 'src/plugins/global-settings/spacing-and-borders/index.php' );
235235
require_once( plugin_dir_path( __FILE__ ) . 'src/plugins/global-settings/buttons-and-icons/index.php' );
236+
require_once( plugin_dir_path( __FILE__ ) . 'src/plugins/global-settings/color-schemes/index.php' );
236237
require_once( plugin_dir_path( __FILE__ ) . 'src/custom-block-styles.php' );
237238
require_once( plugin_dir_path( __FILE__ ) . 'src/css-optimize.php' );
238239
require_once( plugin_dir_path( __FILE__ ) . 'src/compatibility/index.php' );

src/block-components/block-div/attributes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export const addAttributes = attrObject => {
1919
type: 'boolean',
2020
default: false,
2121
},
22+
backgroundColorScheme: {
23+
type: 'string',
24+
default: '',
25+
},
2226
},
2327
versionAdded: '3.0.0',
2428
versionDeprecated: '',

src/block-components/block-div/edit.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ import {
1515
InspectorBlockControls,
1616
InspectorStyleControls,
1717
PanelAdvancedSettings,
18+
AdvancedSelectControl,
1819
} from '~stackable/components'
1920
import {
2021
useBlockAttributesContext,
22+
useBlockColorSchemes,
2123
useBlockLayoutDefaults,
2224
useBlockSetAttributesContext,
2325
} from '~stackable/hooks'
@@ -34,10 +36,23 @@ export const Edit = memo( props => {
3436
initialOpen,
3537
backgroundMediaAllowVideo,
3638
} = props
37-
const hasBackground = useBlockAttributesContext( attributes => attributes.hasBackground )
39+
40+
const {
41+
hasBackground,
42+
backgroundColorScheme,
43+
} = useBlockAttributesContext( attributes => ( {
44+
hasBackground: attributes.hasBackground,
45+
backgroundColorScheme: attributes.backgroundColorScheme,
46+
} ) )
3847
const setAttributes = useBlockSetAttributesContext()
3948
const { getPlaceholder } = useBlockLayoutDefaults()
4049

50+
const {
51+
getScheme,
52+
COLOR_SCHEME_OPTIONS,
53+
backgroundModeColorScheme,
54+
} = useBlockColorSchemes()
55+
4156
return (
4257
<>
4358
<InspectorBlockControls>
@@ -75,6 +90,17 @@ export const Edit = memo( props => {
7590
onChange={ hasBackground => setAttributes( { hasBackground } ) }
7691
initialOpen={ initialOpen === 'background' }
7792
>
93+
<AdvancedSelectControl
94+
label={ __( 'Color Scheme', i18n ) }
95+
value={ getScheme( backgroundColorScheme || backgroundModeColorScheme, { mode: 'background', returnFallback: false } ) }
96+
options={ COLOR_SCHEME_OPTIONS }
97+
attribute="backgroundColorScheme"
98+
changeCallback={ newScheme => {
99+
const colorScheme = newScheme === backgroundModeColorScheme ? '' : newScheme
100+
return colorScheme
101+
} }
102+
default={ backgroundModeColorScheme }
103+
/>
78104
<BackgroundControls
79105
attrNameTemplate="block%s"
80106
onBackgroundEnableAttribute="hasBackground"

src/block-components/block-div/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const BlockDiv = memo( props => {
5757
{
5858
[ uniqueBlockClass ]: withUniqueClass,
5959
'stk-block-background': attributes.hasBackground,
60+
[ `stk--background-scheme--${ attributes.backgroundColorScheme }` ]: attributes.hasBackground && attributes.backgroundColorScheme,
6061
// When the block has auto margins, we need to "add" those margins to
6162
// the main block div so we can simulate the effect inside the editor.
6263
// This works in conjunction with the styles in
@@ -132,6 +133,7 @@ BlockDiv.Content = props => {
132133
uniqueBlockClass,
133134
{
134135
'stk-block-background': attributes.hasBackground,
136+
[ `stk--background-scheme--${ attributes.backgroundColorScheme }` ]: attributes.hasBackground && attributes.backgroundColorScheme,
135137
// When the block has auto top/bottom margins, we need to force the
136138
// parent container to be 100% height or else the auto won't have any
137139
// effect in the frontend. This is okay in the editor-side.

src/block-components/container-div/attributes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export const addAttributes = attrObject => {
1515
type: 'boolean',
1616
default: true,
1717
},
18+
containerColorScheme: {
19+
type: 'string',
20+
default: '',
21+
},
1822
},
1923
versionAdded: '3.0.0',
2024
versionDeprecated: '',

src/block-components/container-div/edit.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ import {
1616
PanelAdvancedSettings,
1717
AdvancedToggleControl,
1818
InspectorBlockControls,
19+
AdvancedSelectControl,
1920
} from '~stackable/components'
2021
import {
2122
useBlockAttributesContext,
23+
useBlockColorSchemes,
2224
useBlockLayoutDefaults,
2325
useBlockSetAttributesContext,
2426
} from '~stackable/hooks'
@@ -33,10 +35,22 @@ export const Edit = props => {
3335
hasContentVerticalAlign = false,
3436
} = props
3537

36-
const hasContainer = useBlockAttributesContext( attributes => attributes.hasContainer )
38+
const {
39+
hasContainer,
40+
containerColorScheme,
41+
} = useBlockAttributesContext( attributes => ( {
42+
hasContainer: attributes.hasContainer,
43+
containerColorScheme: attributes.containerColorScheme,
44+
} ) )
3745
const setAttributes = useBlockSetAttributesContext()
3846
const { getPlaceholder } = useBlockLayoutDefaults()
3947

48+
const {
49+
getScheme,
50+
COLOR_SCHEME_OPTIONS,
51+
containerModeColorScheme,
52+
} = useBlockColorSchemes()
53+
4054
return (
4155
<>
4256
<InspectorBlockControls>
@@ -46,8 +60,18 @@ export const Edit = props => {
4660
hasToggle={ true }
4761
checked={ hasContainer }
4862
onChange={ hasContainer => setAttributes( { hasContainer } ) }
49-
5063
>
64+
<AdvancedSelectControl
65+
label={ __( 'Color Scheme', i18n ) }
66+
value={ getScheme( containerColorScheme || containerModeColorScheme, { returnFallback: false } ) }
67+
options={ COLOR_SCHEME_OPTIONS }
68+
attribute="containerColorScheme"
69+
changeCallback={ newScheme => {
70+
const colorScheme = newScheme === containerModeColorScheme ? '' : newScheme
71+
return colorScheme
72+
} }
73+
default={ containerModeColorScheme }
74+
/>
5175
<SizeControls.Layout
5276
attrNameTemplate="container%s"
5377
enableMargin={ false }

src/block-components/container-div/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const ContainerDiv = props => {
2323
containerBackgroundMediaExternalUrlTablet: attributes.containerBackgroundMediaExternalUrlTablet,
2424
containerBackgroundMediaExternalUrlMobile: attributes.containerBackgroundMediaExternalUrlMobile,
2525
containerBackgroundColorType: attributes.containerBackgroundColorType,
26+
containerColorScheme: attributes.containerColorScheme,
2627
}
2728
} )
2829
const instanceId = useQueryLoopInstanceId( attributes.uniqueId )
@@ -38,6 +39,7 @@ export const ContainerDiv = props => {
3839
'stk-hover-parent': attributes.hasContainer && attributes.triggerHoverState, // This is needed to trigger parent-hover hover styles.
3940
'stk--no-background': ! attributes.hasContainer,
4041
'stk--no-padding': ! attributes.hasContainer,
42+
[ `stk--container-scheme--${ attributes.containerColorScheme }` ]: attributes.hasContainer && attributes.containerColorScheme,
4143
} )
4244

4345
return <Div
@@ -71,6 +73,7 @@ ContainerDiv.Content = props => {
7173
'stk-hover-parent': attributes.hasContainer && attributes.triggerHoverState, // This is needed to trigger parent-hover hover styles.
7274
'stk--no-background': ! attributes.hasContainer,
7375
'stk--no-padding': ! attributes.hasContainer,
76+
[ `stk--container-scheme--${ attributes.containerColorScheme }` ]: attributes.hasContainer && attributes.containerColorScheme,
7477
} )
7578

7679
return <Div.Content

src/block/countdown/style.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
.stk-block-countdown__digit {
2828
font-size: 40px;
2929
height: 50%;
30+
color: var(--stk-accent-color);
31+
&:where(:hover) {
32+
#{ '--stk-accent-color' }: var(--stk-accent-color-hover);
33+
}
3034
}
3135

3236
.stk-block-countdown__label,
@@ -39,13 +43,16 @@
3943
align-items: center;
4044
justify-content: center;
4145
.stk-block-countdown__divider-colon {
42-
color: #000;
46+
color: var(--stk-accent-color, #000);
4347
display: flex;
4448
position: relative;
4549
justify-content: center;
4650
line-height: 1;
4751
font-size: 45px;
4852
top: -12px;
53+
&:where(:hover) {
54+
#{ '--stk-accent-color' }: var(--stk-accent-color-hover);
55+
}
4956
}
5057

5158
.stk-block-countdown__divider-line {

0 commit comments

Comments
 (0)