-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add new fonts! * ui for new settings * add additional fonts * fix lint
- Loading branch information
1 parent
c6966d4
commit ce3fd2e
Showing
108 changed files
with
926 additions
and
132 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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
15 changes: 9 additions & 6 deletions
15
packages/browser/src/components/readers/epub/controls/EpubNavigationControls.tsx
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
49 changes: 49 additions & 0 deletions
49
packages/browser/src/components/readers/epub/controls/FontFamily.tsx
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 { Label, NativeSelect } from '@stump/components' | ||
import { useLocaleContext } from '@stump/i18n' | ||
import { isSupportedFont } from '@stump/sdk' | ||
import { useCallback } from 'react' | ||
|
||
import { useBookPreferences } from '@/scenes/book/reader/useBookPreferences' | ||
import { SUPPORTED_FONT_OPTIONS } from '@/scenes/settings/app/appearance/FontSelect' | ||
|
||
import { useEpubReaderContext } from '../context' | ||
|
||
export default function FontFamily() { | ||
const { t } = useLocaleContext() | ||
const { | ||
readerMeta: { bookEntity }, | ||
} = useEpubReaderContext() | ||
const { | ||
bookPreferences: { fontFamily }, | ||
setBookPreferences, | ||
} = useBookPreferences({ book: bookEntity }) | ||
|
||
const changeFont = useCallback( | ||
(font: string) => { | ||
if (!font) { | ||
setBookPreferences({ fontFamily: undefined }) | ||
} else if (isSupportedFont(font)) { | ||
// Note: useApplyTheme will apply the font to the body element after the preferences are updated | ||
setBookPreferences({ fontFamily: font }) | ||
} | ||
}, | ||
[setBookPreferences], | ||
) | ||
|
||
return ( | ||
<div className="py-1.5"> | ||
<Label htmlFor="font-family">{t(getKey('fontFamily.label'))}</Label> | ||
<NativeSelect | ||
id="font-family" | ||
size="sm" | ||
options={[{ value: '', label: 'Default' }].concat(SUPPORTED_FONT_OPTIONS)} | ||
value={fontFamily ?? ''} | ||
onChange={(e) => changeFont(e.target.value)} | ||
className="mt-1.5" | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
const LOCAL_BASE = 'settingsScene.app/reader.sections.textBasedBooks.sections' | ||
const getKey = (key: string) => `${LOCAL_BASE}.${key}` |
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.