From da9b356130b5273c2c7ad70425e4cec4139098ac Mon Sep 17 00:00:00 2001 From: Diogo Correia Date: Fri, 26 Apr 2024 16:19:22 +0200 Subject: [PATCH] refactor: move things around and only load fonts when sidebar is open --- .../DropdownSelect/DropdownOption.js | 5 +-- .../DropdownSelect/DropdownSelect.js | 20 +--------- src/components/ThemeSettings/ThemeSettings.js | 39 +++++++++++++------ src/hooks/theme-hooks.js | 12 ++++-- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/components/ThemeSettings/DropdownSelect/DropdownOption.js b/src/components/ThemeSettings/DropdownSelect/DropdownOption.js index 09977d7b..d6264e7b 100644 --- a/src/components/ThemeSettings/DropdownSelect/DropdownOption.js +++ b/src/components/ThemeSettings/DropdownSelect/DropdownOption.js @@ -1,12 +1,9 @@ import React, { useContext } from 'react'; import { DropdownContext } from './DropdownSelect'; -import { fonts } from '../../../hooks/theme-hooks'; -const DropdownOption = ({ value, children }) => { +const DropdownOption = ({ value, children, style }) => { const { id, value: selectedValue, onChange } = useContext(DropdownContext); - const style = fonts[value] ? { fontFamily: fonts[value]['cssFamily'], fontSize: '17px' } : {}; - return ( + {panelOpen && fontPreviewsLoader} {fontLoader} diff --git a/src/hooks/theme-hooks.js b/src/hooks/theme-hooks.js index ecc1ecda..64bd046a 100644 --- a/src/hooks/theme-hooks.js +++ b/src/hooks/theme-hooks.js @@ -8,17 +8,17 @@ export const fonts = { roboto: { cssFamily: 'Roboto, sans-serif', url: 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap', - displayName: 'Roboto%20(default)', + displayName: 'Roboto (default)', }, comicNeue: { cssFamily: 'Comic Neue, sans-serif', url: 'https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap', - displayName: 'Comic%20Neue', + displayName: 'Comic Neue', }, indieFlower: { cssFamily: 'Indie Flower, cursive', url: 'https://fonts.googleapis.com/css2?family=Indie+Flower&display=swap', - displayName: 'Indie%20Flower', + displayName: 'Indie Flower', }, nunito: { cssFamily: 'Nunito, sans-serif', @@ -33,19 +33,23 @@ export const fonts = { openSans: { cssFamily: 'Open Sans, Roboto, sans-serif', url: 'https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap', - displayName: 'Open%20Sans', + displayName: 'Open Sans', }, cursive: { cssFamily: 'cursive', + displayName: 'cursive (system)', }, monospace: { cssFamily: 'monospace', + displayName: 'monospace (system)', }, sansSerif: { cssFamily: 'sans-serif', + displayName: 'sans-serif (system)', }, serif: { cssFamily: 'serif', + displayName: 'serif (system)', }, };