Skip to content
Merged
Show file tree
Hide file tree
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
66 changes: 41 additions & 25 deletions onboarding/src/Components/CustomizeControls/TypographyControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,42 @@ import classnames from 'classnames';
import SVG from '../../utils/svg';
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { useState } from '@wordpress/element';

const TypographyControl = ( { siteStyle, handleFontClick, importData } ) => {
const themeMods = importData?.theme_mods;
const FALLBACK_FONT = 'Arial, Helvetica, sans-serif';

const [ defaultBodyFont ] = useState(
themeMods?.neve_body_font_family || 'Arial, Helvetica, sans-serif'
);
const getFontPairs = ( importData ) => {
if ( importData && importData.font_pairs && Object.keys( importData.font_pairs ).length ) {
return importData.font_pairs;
}
if ( tiobDash && tiobDash.fontParings ) {
return tiobDash.fontParings;
}
return null;
};

const [ defaultHeadingsFont ] = useState(
themeMods?.neve_headings_font_family || 'Arial, Helvetica, sans-serif'
);
const getDefaultFonts = ( importDataDefault ) => {
const themeMods = importDataDefault?.theme_mods;
return {
body: themeMods?.neve_body_font_family || FALLBACK_FONT,
heading: themeMods?.neve_headings_font_family || FALLBACK_FONT,
};
};

const { font } = siteStyle;
if ( ! tiobDash || ! tiobDash.fontParings ) {
return;
const TypographyControl = ( {
siteStyle,
handleFontClick,
importData,
importDataDefault,
} ) => {
const fontPairs = getFontPairs( importData );
if ( ! fontPairs ) {
return null;
}

const { body: defaultBodyFont, heading: defaultHeadingsFont } =
getDefaultFonts( importDataDefault );
const { font } = siteStyle;

return (
<div className="ob-ctrl">
<div className="ob-ctrl-head small-gap">
Expand All @@ -45,9 +63,8 @@ const TypographyControl = ( { siteStyle, handleFontClick, importData } ) => {
{ __( 'Default', 'templates-patterns-collection' ) }
</Button>

{ Object.keys( tiobDash.fontParings ).map( ( slug ) => {
const { headingFont, bodyFont } =
tiobDash.fontParings[ slug ];
{ Object.keys( fontPairs ).map( ( slug ) => {
const { headingFont, bodyFont } = fontPairs[ slug ];
const headingStyle = {
fontFamily: headingFont.font,
};
Expand Down Expand Up @@ -82,15 +99,12 @@ export default compose(
withDispatch(
(
dispatch,
{
importData,
siteStyle,
setSiteStyle,
defaultBodyFont,
defaultHeadingsFont,
}
{ importData, importDataDefault, siteStyle, setSiteStyle }
) => {
const { setImportData, setRefresh } = dispatch( 'ti-onboarding' );
const fontPairs = getFontPairs( importData );
const { body: defaultBodyFont, heading: defaultHeadingsFont } =
getDefaultFonts( importDataDefault );

return {
handleFontClick: ( fontKey ) => {
Expand All @@ -100,14 +114,16 @@ export default compose(
};
setSiteStyle( newStyle );

const { bodyFont, headingFont } =
fontKey !== 'default'
? tiobDash.fontParings[ fontKey ]
const pair =
fontKey !== 'default' && fontPairs && fontPairs[ fontKey ]
? fontPairs[ fontKey ]
: {
bodyFont: { font: defaultBodyFont },
headingFont: { font: defaultHeadingsFont },
};

const { bodyFont, headingFont } = pair;

const newImportData = {
...importData,
theme_mods: {
Expand Down
3 changes: 3 additions & 0 deletions onboarding/src/Components/SiteSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export const SiteSettings = ( {
<TypographyControl
siteStyle={ siteStyle }
setSiteStyle={ setSiteStyle }
importDataDefault={
importDataDefault
}
/>
</>
) }
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
=== Starter Sites & Templates by Neve ===
Contributors: themeisle
Tags: neve, templates, patterns, blocks, starter, sites, demo, content, import
Tags: starter sites, templates, block patterns, neve, gutenberg
Requires at least: 5.5
Tested up to: 6.9
Requires PHP: 5.6
Stable tag: 1.2.27
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.en.html

This plugin gives you access to 100+ templates and ready-to-use starter sites. Neve theme is used for all the designs.
Access 100+ Gutenberg templates and ready-to-use starter sites for WordPress. All designs work with the Neve theme. One-click import, fully responsive.

== Description ==

Expand Down
Loading