From 171af92a32ccb0fea11bdea09db468f43c920305 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Thu, 7 Dec 2023 00:10:16 +0900 Subject: [PATCH] refs #4653 Change fontSize --- locales/en/translation.json | 3 +- renderer/components/Settings.tsx | 51 ++++++++++++++++++------- renderer/components/layouts/account.tsx | 11 +++++- renderer/utils/i18n.tsx | 1 - 4 files changed, 48 insertions(+), 18 deletions(-) diff --git a/locales/en/translation.json b/locales/en/translation.json index bf929d29..1abbf811 100644 --- a/locales/en/translation.json +++ b/locales/en/translation.json @@ -113,6 +113,7 @@ }, "settings": { "title": "Settings", - "language": "Language" + "language": "Language", + "font_size": "Font size" } } diff --git a/renderer/components/Settings.tsx b/renderer/components/Settings.tsx index da5da0ab..b47360ac 100644 --- a/renderer/components/Settings.tsx +++ b/renderer/components/Settings.tsx @@ -1,5 +1,5 @@ import { localeType } from '@/utils/i18n' -import { Label, Modal, Select } from 'flowbite-react' +import { Label, Modal, Select, TextInput } from 'flowbite-react' import { ChangeEvent, useEffect, useState } from 'react' import { FormattedMessage } from 'react-intl' @@ -22,6 +22,7 @@ const languages = [ export default function Settings(props: Props) { const [language, setLanguage] = useState('en') + const [fontSize, setFontSize] = useState(16) useEffect(() => { if (typeof localStorage !== 'undefined') { @@ -38,25 +39,47 @@ export default function Settings(props: Props) { props.reloadSettings() } + const fontSizeChanged = (e: ChangeEvent) => { + setFontSize(parseInt(e.target.value)) + if (typeof localStorage !== 'undefined') { + localStorage.setItem('fontSize', e.target.value) + } + props.reloadSettings() + } + return ( -
- -
-
- +
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
diff --git a/renderer/components/layouts/account.tsx b/renderer/components/layouts/account.tsx index eba6f62e..3496cb52 100644 --- a/renderer/components/layouts/account.tsx +++ b/renderer/components/layouts/account.tsx @@ -1,4 +1,4 @@ -import { useContext, useEffect, useRef, useState } from 'react' +import { CSSProperties, useContext, useEffect, useRef, useState } from 'react' import { FaGear, FaPlus } from 'react-icons/fa6' import { Account, db } from '@/db' import NewAccount from '@/components/accounts/New' @@ -18,6 +18,7 @@ export default function Layout({ children }: LayoutProps) { const [accounts, setAccounts] = useState>([]) const [openNewModal, setOpenNewModal] = useState(false) const [openSettings, setOpenSettings] = useState(false) + const [style, setStyle] = useState({}) const { switchLang } = useContext(Context) const router = useRouter() const { formatMessage } = useIntl() @@ -104,11 +105,17 @@ export default function Layout({ children }: LayoutProps) { if (typeof localStorage !== 'undefined') { const lang = localStorage.getItem('language') switchLang(lang) + const fontSize = localStorage.getItem('fontSize') + if (parseInt(fontSize)) { + setStyle({ + fontSize: `${fontSize}px` + }) + } } } return ( -
+