-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from sinamics/font_size
Added option to select application font size
- Loading branch information
Showing
10 changed files
with
255 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useTranslations } from "next-intl"; | ||
import React, { useEffect, useState } from "react"; | ||
|
||
const ApplicationFontSize = () => { | ||
const t = useTranslations("userSettings"); | ||
const [fontSize, setFontSize] = useState(() => { | ||
// Get font size from local storage or default to "Medium" | ||
const savedFontSize = localStorage.getItem("appFontSize"); | ||
return savedFontSize || "Medium"; | ||
}); | ||
|
||
useEffect(() => { | ||
// Apply the font size class to the document element | ||
document.documentElement.className = fontSizeOptions[fontSize]; | ||
// Save the font size to local storage whenever it changes | ||
localStorage.setItem("appFontSize", fontSize); | ||
}, [fontSize]); | ||
|
||
const fontSizeOptions = { | ||
Small: "text-xs", | ||
Medium: "text-base", | ||
Large: "text-lg", | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div className="form-control w-full max-w-xs"> | ||
<label className="label"> | ||
<span className="label-text font-medium"> | ||
{t("account.accountPreferences.fontSize")} | ||
</span> | ||
</label> | ||
<select | ||
value={fontSize} | ||
onChange={(e) => setFontSize(e.target.value)} | ||
className="select select-bordered select-sm" | ||
> | ||
{Object.keys(fontSizeOptions).map((name) => ( | ||
<option key={name} value={name}> | ||
{name} | ||
</option> | ||
))} | ||
</select> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ApplicationFontSize; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.