Skip to content

Commit 621bf48

Browse files
Merge branch 'develop' into feat/global-color-schemes
2 parents a4adf45 + d18b4c6 commit 621bf48

File tree

8 files changed

+42
-2512
lines changed

8 files changed

+42
-2512
lines changed

.config/webpack.config.dev.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = [
3434

3535
output: {
3636
filename: '[name].js',
37+
chunkFilename: '[name].[contenthash].json', // Output filename for dynamically imported chunks
3738
},
3839

3940
// Externals are only WordPress loaded libraries.

.config/webpack.config.prod.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = [
3434

3535
output: {
3636
filename: '[name].js',
37+
chunkFilename: '[name].[contenthash].json', // Output filename for dynamically imported chunks
3738
},
3839

3940
// Externals are only WordPress loaded libraries.

src/components/font-family-control/index.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { i18n } from 'stackable'
66
/**
77
* Internal dependencies
88
*/
9-
import fonts from './google-fonts.json'
109
import {
1110
loadGoogleFont,
1211
MODERN_FONT_STACKS,
@@ -18,20 +17,32 @@ import {
1817
*/
1918
import { __ } from '@wordpress/i18n'
2019
import { applyFilters } from '@wordpress/hooks'
21-
import { useMemo } from '@wordpress/element'
20+
import {
21+
useMemo, useState, useEffect,
22+
} from '@wordpress/element'
2223
import AdvancedAutosuggestControl from '../advanced-autosuggest-control'
2324

2425
import { select } from '@wordpress/data'
2526

26-
const fontOptions = fonts.map( font => {
27-
return { label: font.family, value: font.family }
28-
} )
27+
const loadGoogleFonts = async () => {
28+
const { default: fonts } =
29+
await import( /* webpackChunkName: "data/google-fonts" */ './google-fonts.json' )
30+
return fonts.map( font => ( { label: font.family, value: font.family } ) )
31+
}
2932

3033
const FontFamilyControl = props => {
3134
const {
3235
loadingThemeFont, themeFonts, themeFontOptions,
3336
} = select( 'stackable/theme-fonts' ).getThemeFonts()
3437

38+
const [ googleFontOptions, setGoogleFontOptions ] = useState( [] )
39+
40+
useEffect( () => {
41+
loadGoogleFonts().then( fontOptions => {
42+
setGoogleFontOptions( fontOptions )
43+
} )
44+
}, [] )
45+
3546
const options = useMemo( () => {
3647
const allFontOptions = [
3748
{
@@ -53,7 +64,7 @@ const FontFamilyControl = props => {
5364
{
5465
id: 'google-fonts',
5566
title: __( 'Google Fonts', i18n ),
56-
options: fontOptions,
67+
options: googleFontOptions,
5768
},
5869
]
5970
if ( themeFonts.length ) {
@@ -64,7 +75,7 @@ const FontFamilyControl = props => {
6475
} )
6576
}
6677
return applyFilters( 'stackable.font-family-control.options', allFontOptions )
67-
}, [ loadingThemeFont ] )
78+
}, [ loadingThemeFont, googleFontOptions ] )
6879

6980
return (
7081
<AdvancedAutosuggestControl
@@ -74,7 +85,7 @@ const FontFamilyControl = props => {
7485
onChange={ fontFamily => {
7586
if ( ! themeFonts.includes( fontFamily ) ) {
7687
// Load font if it's a Google font.
77-
fontOptions.some( font => {
88+
googleFontOptions.some( font => {
7889
if ( font.value === fontFamily ) {
7990
loadGoogleFont( fontFamily )
8091
return true

src/components/pro-control/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ const LABELS = {
118118
</ul>,
119119
},
120120
'font-pairs': {
121-
title: __( 'Add Your Own Font Pairs', i18n ),
121+
title: __( 'Premium Typography', i18n ),
122122
description: <ul>
123-
<li>{ __( 'Add your own custom Font Pairs', i18n ) }</li>
124-
<li>{ __( 'Manage your custom Font Pairs', i18n ) }</li>
123+
<li>{ __( 'Access to 90+ curated font pairs', i18n ) }</li>
124+
<li>{ __( 'Create your own custom font pairs', i18n ) }</li>
125125
</ul>,
126126
},
127127
'color-schemes': {

src/hooks/use-font-loader.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import { select } from '@wordpress/data'
77
export const useFontLoader = fontFamilyValue => {
88
const { loadingThemeFont, themeFonts } = select( 'stackable/theme-fonts' ).getThemeFonts()
99
useEffect( () => {
10-
if ( ! loadingThemeFont ) {
11-
if ( ! themeFonts.includes( fontFamilyValue ) ) {
12-
loadGoogleFont( fontFamilyValue )
13-
doAction( 'stackable.font-loader.load', fontFamilyValue )
14-
}
10+
if ( ! themeFonts.includes( fontFamilyValue ) ) {
11+
loadGoogleFont( fontFamilyValue )
12+
doAction( 'stackable.font-loader.load', fontFamilyValue )
1513
}
1614
}, [ loadingThemeFont, fontFamilyValue ] )
1715
}

0 commit comments

Comments
 (0)