diff --git a/src/components/App/App.js b/src/components/App/App.js index 04ffb77e..589ff0a0 100644 --- a/src/components/App/App.js +++ b/src/components/App/App.js @@ -1,15 +1,10 @@ -/* eslint-disable no-unused-vars */ import React, { useEffect, useContext, Suspense } from 'react'; +import AppContext from '../../context/AppContext'; import LeftSidebar from '../LeftSidebar/LeftSidebar'; import RightSidebar from '../RightSidebar/RightSidebar'; -import AppContext from '../../context/AppContext'; -// Resume Templates -import Onyx from '../../templates/onyx'; -import Pikachu from '../../templates/pikachu'; -import Gengar from '../../templates/gengar'; -import Castform from '../../templates/castform'; +import templates from '../../templates'; const App = () => { const context = useContext(AppContext); @@ -21,21 +16,6 @@ const App = () => { dispatch({ type: 'import_data', payload: storedState }); }, [dispatch]); - const renderTemplate = () => { - switch (theme.layout) { - case 'Onyx': - return ; - case 'Pikachu': - return ; - case 'Gengar': - return ; - case 'Castform': - return ; - default: - return null; - } - }; - return (
@@ -47,7 +27,7 @@ const App = () => { className="animated fadeIn my-auto shadow-2xl" style={{ animationDelay: '500ms' }} > - {renderTemplate()} + {templates.find(x => theme.layout.toLowerCase() === x.key).component()}
diff --git a/src/components/LeftSidebar/LeftSidebar.js b/src/components/LeftSidebar/LeftSidebar.js index 81b68d40..d06c3bae 100644 --- a/src/components/LeftSidebar/LeftSidebar.js +++ b/src/components/LeftSidebar/LeftSidebar.js @@ -13,25 +13,24 @@ import ExtrasTab from './tabs/Extras'; import LanguagesTab from './tabs/Languages'; import ReferencesTab from './tabs/References'; -const tabs = [ - 'Profile', - 'Objective', - 'Work Experience', - 'Education', - 'Awards', - 'Certifications', - 'Skills', - 'Languages', - 'References', - 'Extras', -]; - const LeftSidebar = () => { const context = useContext(AppContext); const { state, dispatch } = context; const { data } = state; - const [currentTab, setCurrentTab] = useState('Extras'); + const tabs = [ + 'Profile', + 'Objective', + 'Work Experience', + 'Education', + 'Awards', + 'Certifications', + 'Skills', + 'Languages', + 'References', + 'Extras', + ]; + const [currentTab, setCurrentTab] = useState('Profile'); const onChange = (key, value) => { dispatch({ type: 'on_input', diff --git a/src/components/RightSidebar/RightSidebar.js b/src/components/RightSidebar/RightSidebar.js index 6277aa6e..1ca90de4 100644 --- a/src/components/RightSidebar/RightSidebar.js +++ b/src/components/RightSidebar/RightSidebar.js @@ -1,4 +1,5 @@ import React, { useState, useContext } from 'react'; +import { useTranslation } from 'react-i18next'; import AppContext from '../../context/AppContext'; import TabBar from '../../shared/TabBar'; @@ -8,14 +9,15 @@ import FontsTab from './tabs/Fonts'; import ActionsTab from './tabs/Actions'; import AboutTab from './tabs/About'; -const tabs = ['Templates', 'Colors', 'Fonts', 'Actions', 'About']; - const RightSidebar = () => { + const { t } = useTranslation('rightSidebar'); + const context = useContext(AppContext); const { state, dispatch } = context; const { data, theme } = state; - const [currentTab, setCurrentTab] = useState('Templates'); + const tabs = [t('templates.title'), 'Colors', 'Fonts', 'Actions', 'About']; + const [currentTab, setCurrentTab] = useState(t('templates.title')); const onChange = (key, value) => { dispatch({ type: 'on_input', @@ -30,7 +32,7 @@ const RightSidebar = () => { const renderTabs = () => { switch (currentTab) { - case 'Templates': + case t('templates.title'): return ; case 'Colors': return ; diff --git a/src/components/RightSidebar/tabs/Templates.js b/src/components/RightSidebar/tabs/Templates.js index e703d9c3..747b3a87 100644 --- a/src/components/RightSidebar/tabs/Templates.js +++ b/src/components/RightSidebar/tabs/Templates.js @@ -1,47 +1,25 @@ import React from 'react'; -import Onyx, { Image as OnyxPreview } from '../../../templates/onyx'; -import Pikachu, { Image as PikachuPreview } from '../../../templates/pikachu'; -import Gengar, { Image as GengarPreview } from '../../../templates/gengar'; -import Castform, { Image as CastformPreview } from '../../../templates/castform'; +import { useTranslation } from 'react-i18next'; -const templates = [ - { - name: 'Onyx', - component: Onyx, - preview: OnyxPreview, - }, - { - name: 'Pikachu', - component: Pikachu, - preview: PikachuPreview, - }, - { - name: 'Gengar', - component: Gengar, - preview: GengarPreview, - }, - { - name: 'Castform', - component: Castform, - preview: CastformPreview, - }, -]; +import templates from '../../../templates'; const TemplatesTab = ({ theme, onChange }) => { + const { t } = useTranslation('rightSidebar'); + return (
{templates.map(x => ( -
onChange('theme.layout', x.name)}> +
onChange('theme.layout', x.key)}> {x.name} -

{x.name}

+

{t(`templates.templates.${x.key}`)}

))}
diff --git a/src/i18n/index.js b/src/i18n/index.js index 07f35fed..852df769 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -8,7 +8,7 @@ i18n.use(initReactI18next).init({ fallbackLng: 'en', resources, debug: true, - ns: ['app', 'leftSidebar'], + ns: ['app', 'leftSidebar', 'rightSidebar'], defaultNS: 'app', }); diff --git a/src/i18n/resources/en/index.js b/src/i18n/resources/en/index.js index 585db3d8..943ca673 100644 --- a/src/i18n/resources/en/index.js +++ b/src/i18n/resources/en/index.js @@ -1,7 +1,9 @@ import app from './app'; import leftSidebar from './leftSidebar'; +import rightSidebar from './rightSidebar'; export default { app, leftSidebar, + rightSidebar, }; diff --git a/src/i18n/resources/en/rightSidebar/index.js b/src/i18n/resources/en/rightSidebar/index.js new file mode 100644 index 00000000..c3a0bcc3 --- /dev/null +++ b/src/i18n/resources/en/rightSidebar/index.js @@ -0,0 +1,5 @@ +import templates from './templates.json'; + +export default { + templates, +}; diff --git a/src/i18n/resources/en/rightSidebar/templates.json b/src/i18n/resources/en/rightSidebar/templates.json new file mode 100644 index 00000000..f2501798 --- /dev/null +++ b/src/i18n/resources/en/rightSidebar/templates.json @@ -0,0 +1,9 @@ +{ + "title": "Templates", + "templates": { + "onyx": "Onyx", + "pikachu": "Pikaaachu", + "gengar": "Gengar", + "castform": "Castform" + } +} diff --git a/src/templates/castform/Castform.js b/src/templates/castform/Castform.js index 7e2842c6..0245cbbc 100644 --- a/src/templates/castform/Castform.js +++ b/src/templates/castform/Castform.js @@ -234,10 +234,10 @@ const Castform = () => {
); - const ExtraItem = ({ key, value }) => ( -
-
{key}
-
{value}
+ const ExtraItem = x => ( +
+
{x.key}
+
{x.value}
); diff --git a/src/templates/gengar/Gengar.js b/src/templates/gengar/Gengar.js index 1b25177c..dcd0bd1a 100644 --- a/src/templates/gengar/Gengar.js +++ b/src/templates/gengar/Gengar.js @@ -215,7 +215,7 @@ const Gengar = () => { ); const ExtraItem = x => ( -
+
{x.key}
{x.value}
diff --git a/src/templates/index.js b/src/templates/index.js new file mode 100644 index 00000000..261fe54d --- /dev/null +++ b/src/templates/index.js @@ -0,0 +1,27 @@ +import Onyx, { Image as OnyxPreview } from './onyx'; +import Pikachu, { Image as PikachuPreview } from './pikachu'; +import Gengar, { Image as GengarPreview } from './gengar'; +import Castform, { Image as CastformPreview } from './castform'; + +export default [ + { + key: 'onyx', + component: Onyx, + preview: OnyxPreview, + }, + { + key: 'pikachu', + component: Pikachu, + preview: PikachuPreview, + }, + { + key: 'gengar', + component: Gengar, + preview: GengarPreview, + }, + { + key: 'castform', + component: Castform, + preview: CastformPreview, + }, +]; diff --git a/src/templates/onyx/Onyx.js b/src/templates/onyx/Onyx.js index 3b7a91f4..914c0766 100644 --- a/src/templates/onyx/Onyx.js +++ b/src/templates/onyx/Onyx.js @@ -211,7 +211,7 @@ const Onyx = () => { ); const ExtraItem = x => ( - + {x.key} {x.value} diff --git a/src/templates/pikachu/Pikachu.js b/src/templates/pikachu/Pikachu.js index 2fabc7e9..d3eaa879 100644 --- a/src/templates/pikachu/Pikachu.js +++ b/src/templates/pikachu/Pikachu.js @@ -120,7 +120,7 @@ const Pikachu = () => { ); const ExtraItem = x => ( -
+
{x.key}
{x.value}