A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
[2.5] Implement Font Size Adjustments
Amruth Pillaifdd35492a045
diff --git a/gatsby-config.js b/gatsby-config.jsindex 5e353e6ac..08c598663 100644--- a/gatsby-config.js+++ b/gatsby-config.js@@ -6,7 +6,7 @@ module.exports = {title: 'Reactive Resume',siteUrl: 'https://rxresu.me',description: 'A free and open source resume builder.',- version: '2.4.3',+ version: '2.5',},plugins: ['gatsby-plugin-react-helmet',diff --git a/src/components/builder/right/RightSidebar.js b/src/components/builder/right/RightSidebar.jsindex f702b6fe6..76005b067 100644--- a/src/components/builder/right/RightSidebar.js+++ b/src/components/builder/right/RightSidebar.js@@ -10,7 +10,7 @@ import Fonts from './sections/Fonts';import Layout from './sections/Layout';import Settings from './sections/Settings';import Templates from './sections/Templates';-import FontSizes from './sections/FontSizes';+import FontSize from './sections/FontSize';const getComponent = (id) => {switch (id) {@@ -28,8 +28,8 @@ const getComponent = (id) => {return Settings;case 'about':return About;- case 'font-sizes':- return FontSizes;+ case 'font-size':+ return FontSize;default:throw new Error();}diff --git a/src/components/builder/right/sections/FontSizes.js b/src/components/builder/right/sections/FontSize.jssimilarity index 62%rename from src/components/builder/right/sections/FontSizes.jsrename to src/components/builder/right/sections/FontSize.jsindex 03d4b7388..1145dc084 100644--- a/src/components/builder/right/sections/FontSizes.js+++ b/src/components/builder/right/sections/FontSize.js@@ -1,9 +1,9 @@/* eslint-disable jsx-a11y/control-has-associated-label */-import React, { memo, useState, useEffect } from 'react';-import fontSizeVarsDefault from '../../../../data/fontSizeVarsDefault';+import React, { memo, useEffect, useState } from 'react';+import { useDispatch, useSelector } from '../../../../contexts/ResumeContext';+import fontSizeOptions from '../../../../data/fontSizeOptions';import Heading from '../../../shared/Heading';-/* font size control */const FontSizes = ({ id }) => {// precompute some stuff for the logarithmic sliderconst logMax = 2.5;@@ -15,7 +15,10 @@ const FontSizes = ({ id }) => {const min = 0;const max = min + steps - 1;const scaleDefault = Math.log(logDefault / logMin) / Math.log(logStepSize);- const [fontScale, setFontScale] = useState(scaleDefault);++ const dispatch = useDispatch();+ const fontSize = useSelector('metadata.fontSize');+ const [fontScale, setFontScale] = useState(fontSize || scaleDefault);// translate a linearly scaled value from the slider into a scale factorconst scale = (value) => logStepSize ** (value - min) * logMin;@@ -23,7 +26,7 @@ const FontSizes = ({ id }) => {useEffect(() => {/* loop through the css variables we need to set and set them to the defaultfor that variable multiplied by the scale factor */- for (const [key, sizeDefault] of Object.entries(fontSizeVarsDefault)) {+ for (const [key, sizeDefault] of Object.entries(fontSizeOptions)) {document.documentElement.style.setProperty(key,`${scale(fontScale) * sizeDefault}rem`,@@ -31,19 +34,31 @@ const FontSizes = ({ id }) => {}}, [fontScale]);- const onChange = (event) => setFontScale(event.target.value);+ const onChange = (event) => {+ const { value } = event.target;++ setFontScale(value);++ dispatch({+ type: 'on_input',+ payload: {+ path: 'metadata.fontSize',+ value,+ },+ });+ };return (<section><Heading id={id} /><input- type="range"- onChange={onChange}+ step={1}min={min}max={max}- step={1}- defaultValue={scaleDefault}+ type="range"+ onChange={onChange}+ defaultValue={fontScale}/></section>);diff --git a/src/data/demoState.json b/src/data/demoState.jsonindex 0e5088fd8..7d6ae2d33 100644--- a/src/data/demoState.json+++ b/src/data/demoState.json@@ -138,6 +138,7 @@"text": "#212121"},"font": "Open Sans",+ "fontSize": 12,"language": "en","layout": {"castform": [diff --git a/src/data/fontSizeVarsDefault.js b/src/data/fontSizeOptions.jssimilarity index 86%rename from src/data/fontSizeVarsDefault.jsrename to src/data/fontSizeOptions.jsindex 7a89848c9..8bb211a47 100644--- a/src/data/fontSizeVarsDefault.js+++ b/src/data/fontSizeOptions.js@@ -1,4 +1,4 @@-const fontSizeVarsDefault = {+const fontSizeOptions = {'--text-xs-size': 0.75,'--text-sm-size': 0.875,'--text-lg-size': 1.125,@@ -15,4 +15,4 @@ const fontSizeVarsDefault = {'--text-4xl-line-height': 2.5,};-export default fontSizeVarsDefault;+export default fontSizeOptions;diff --git a/src/data/initialState.json b/src/data/initialState.jsonindex 172df9560..124287215 100644--- a/src/data/initialState.json+++ b/src/data/initialState.json@@ -74,6 +74,7 @@"language": "en","template": "onyx","font": "Montserrat",+ "fontSize": 12,"layout": {"onyx": [["objective", "work", "education", "projects"],diff --git a/src/data/rightSections.js b/src/data/rightSections.jsindex 5d0f01533..ab14c8584 100644--- a/src/data/rightSections.js+++ b/src/data/rightSections.js@@ -27,7 +27,7 @@ export default [icon: MdFontDownload,},{- id: 'font-sizes',+ id: 'font-size',icon: MdFormatSize,},{diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.jsonindex 757f409e4..d4dc7d581 100644--- a/src/i18n/locales/en.json+++ b/src/i18n/locales/en.json@@ -87,7 +87,7 @@"templates": "Templates","layout": "Layout","colors": "Colors",- "font-sizes": "Font Sizes",+ "font-size": "Font Size","fonts": "Fonts","actions": "Actions","settings": "Settings",