1
0
mirror of https://github.com/h3poteto/whalebird-desktop synced 2025-01-22 13:40:13 +01:00

refs #4653 Change fontSize

This commit is contained in:
AkiraFukushima 2023-12-07 00:10:16 +09:00
parent 61a6fb9aa2
commit 171af92a32
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
4 changed files with 48 additions and 18 deletions

View File

@ -113,6 +113,7 @@
},
"settings": {
"title": "Settings",
"language": "Language"
"language": "Language",
"font_size": "Font size"
}
}

View File

@ -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<localeType>('en')
const [fontSize, setFontSize] = useState<number>(16)
useEffect(() => {
if (typeof localStorage !== 'undefined') {
@ -38,12 +39,32 @@ export default function Settings(props: Props) {
props.reloadSettings()
}
const fontSizeChanged = (e: ChangeEvent<HTMLInputElement>) => {
setFontSize(parseInt(e.target.value))
if (typeof localStorage !== 'undefined') {
localStorage.setItem('fontSize', e.target.value)
}
props.reloadSettings()
}
return (
<Modal show={props.opened} onClose={props.close}>
<Modal.Header>
<FormattedMessage id="settings.title" />
</Modal.Header>
<Modal.Body>
<div className="flex flex-col gap-4">
<div>
<div className="mb-2">
<Label htmlFor="fontsize">
<FormattedMessage id="settings.font_size" />
</Label>
</div>
<div>
<TextInput type="number" value={fontSize} onChange={fontSizeChanged} />
</div>
</div>
<div>
<div className="mb-2">
<Label htmlFor="language">
<FormattedMessage id="settings.language" />
@ -58,6 +79,8 @@ export default function Settings(props: Props) {
))}
</Select>
</div>
</div>
</div>
</Modal.Body>
</Modal>
)

View File

@ -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<Array<Account>>([])
const [openNewModal, setOpenNewModal] = useState(false)
const [openSettings, setOpenSettings] = useState(false)
const [style, setStyle] = useState<CSSProperties>({})
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 (
<div className="app flex flex-col min-h-screen">
<div className="app flex flex-col min-h-screen" style={style}>
<main className="flex w-full box-border my-0 mx-auto min-h-screen">
<aside className="w-16 bg-gray-900 flex flex-col justify-between">
<div>

View File

@ -25,7 +25,6 @@ export const IntlProviderWrapper: React.FC<Props> = props => {
const switchLang = (locale: string) => {
const changeLang = langs.find(lang => lang.locale === locale)
console.log(changeLang)
if (changeLang == null) {
return
}