forked from ztjhz/BetterChatGPT
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporary Font Size Changer (small, medium, large - small by default)
- Loading branch information
darks
authored and
darks
committed
Aug 22, 2023
1 parent
fbf2071
commit dc4ca51
Showing
9 changed files
with
181 additions
and
6 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
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,35 @@ | ||
import React, { useEffect } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import useStore from '@store/store'; | ||
import { FontSize } from '@type/font-size'; | ||
|
||
const FontSizeChanger = () => { | ||
const { t } = useTranslation(); | ||
const fontSize = useStore((state) => state.fontSize); | ||
const setFontSize = useStore((state) => state.setFontSize); | ||
|
||
const changeFontSize = (fontSize: FontSize) => { | ||
setFontSize(fontSize); | ||
}; | ||
|
||
useEffect(() => { | ||
document.documentElement.setAttribute('font-size', fontSize); | ||
}, [fontSize]); | ||
|
||
return fontSize ? ( | ||
<select | ||
className='items-center gap-3 btn btn-neutral' | ||
aria-label='change font size' | ||
onChange={(e) => changeFontSize(e.target.value as FontSize)} | ||
value={fontSize} | ||
> | ||
<option value='sm'>Small</option> | ||
<option value='md'>Medium</option> | ||
<option value='lg'>Large</option> | ||
</select> | ||
) : ( | ||
<></> | ||
); | ||
}; | ||
|
||
export default FontSizeChanger; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type FontSize = 'sm' | 'md' | 'lg'; |