772bb73b46
* ui/ux: codify design system and migrate settings to shared primitives Document Readest's design language in DESIGN.md (Adwaita-aligned, e-ink-first, RTL-correct) and migrate every settings panel onto a small set of primitives (BoxedList, SettingsRow, SettingsSwitchRow, SettingsSelect, SettingsInput, NavigationRow, Tips, SubPageHeader). AGENTS.md links to DESIGN.md so contributors land there before inventing new chassis classes. Replace the standalone KOReader/Readwise/Hardcover Config dialogs with a single Integrations panel (Reading Sync + Content Sources sub-pages). The reader's BookMenu now hides each provider until it's configured, and Hardcover's per-book "Enable for This Book" toggle is dropped — there's no auto-sync to gate, so the flag was just extra clicks. Refresh highlight colors (two-trigger swatch + label, translatable default names), background texture / theme color selectors (border-current keeps selection legible on any backdrop), CustomFonts/CustomDictionaries (quiet list-extension style + shared Tips primitive), the OPDS catalog manager (debounced auto-download, right-aligned Browse), Set PIN, and the KOSync conflict resolver. Translate the ~30 new strings across all 33 locales. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ui/ux: responsive typography, OPDS card polish, deep-link return paths Restore the .settings-content responsive cascade (14px desktop / 16px mobile) the legacy panels relied on by dropping hardcoded `text-sm`/`text-xs` from the new primitives. Secondary text moves to em-relative `text-[0.85em]` so it scales with the parent. Form controls (`<input>`, `<select>`) re-apply the cascade explicitly via the `settings-content` class since browsers don't inherit font-size onto form elements. Extract `<SectionTitle>` primitive (caseless-language aware via `isCaselessUILang`/`isCaselessLang`) and route every uppercase tag-style header through it: BoxedList groups, Reading Sync, Content Sources, Theme Color, Background Image, integration form labels, KOSyncResolver device labels, and the OPDS My Catalogs / Popular Catalogs sections. CJK / Arabic / Hebrew / Indic / Thai / Tibetan locales bump to `1em` since `uppercase` is a no-op on those scripts. Redesign the OPDS My Catalogs cards: whole card becomes the browse trigger (role='button'), edit/delete collapse into a 3-dot dropdown menu, and the sync-status moves to a sub-line under Auto-download so the card height stays constant whether the toggle is on/off or sync data has arrived. Plumb a `from=settings-integrations` URL marker through the OPDS browser so both manual close and auto-close-on-failure (preserved as `router.back()` for transient failures, paired with a new `stashOPDSReturnTarget` helper) return the user to Settings -> Integrations -> OPDS Catalogs sub-page rather than the dialog's top level. Backed by new `requestedSubPage` deep-link store field. Skip the OPDS catalog passphrase prompt when credentials sync is disabled -- `replicaPublish` already drops encrypted fields at the wire, so prompting was both pointless and confusing. Fix `SettingsDialog` calling `setRequestedPanel(null)` inside a `useState` lazy initializer (zustand setter during render -> React warning); move the clear into a one-shot `useEffect`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ui/ux: opt Settings into OverlayScrollbars + caseless typography polish Add an opt-in `useOverlayScroll` prop to `<Dialog>` that swaps the body's native `overflow-y-auto` for `<OverlayScrollbarsComponent>` (autohide, click-scroll, no native overlaid bars). SettingsDialog flips it on so the long Layout / Color panels keep a visible, theme-aware scroll track on Android / iOS webviews where native scrollbars auto-hide entirely. Other short-modal callers stay on the native scrollbar. Drop the `uppercase tracking-wider` SectionTitle styling for caseless scripts and pair it with body-weight `font-medium` instead — those typographic effects are no-ops on Han / Hangul / Devanagari / Thai etc., so a plain medium-weight body-size title reads more correctly than a shrunken pseudo-uppercase one. SettingsRow / NavigationRow primary labels follow the same rule (drop `font-medium` in caseless locales since the inherited body weight already carries; CJK fonts bold poorly at body size). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ui/ux: SettingLabel primitive + KOSyncForm select polish + Tips alignment Add `<SettingLabel>` primitive — caseless-aware row/field label that pairs with `<SectionTitle>` (groups) for per-item labels. Cased scripts get `font-medium`; caseless scripts (CJK / Arabic / Hebrew / Indic / Thai / Tibetan) drop the weight since Han / Hangul / Devanagari etc. bold poorly at body size. No font-size class so it inherits the `.settings-content` 14/16 cascade. Routed through `SettingsRow`, `NavigationRow`, and the ~12 ad-hoc inline `text-sm font-medium` callsites in AIPanel / FontPanel / ColorPanel / IntegrationsPanel / KOSync / Readwise / Hardcover forms. Refactor KOSyncForm's Sync Strategy + Checksum Method rows onto the shared `<SettingsSelect>` primitive — the inline 17-line div/select/ MdArrowDropDown chassis becomes a single SettingsSelect call with an options array. Drops the unused MdArrowDropDown import and ~25 lines. Fix Tips list-item alignment: callers traditionally pass `<li>` elements (semantic) but the primitive was double-wrapping into `<li><span><li>...</li></span></li>` — invalid HTML, and the inner `<li>`'s `display: list-item` broke line-wrap alignment on multi-line items. Unwrap caller `<li>` to its content; add `flex-1` on the text span so wrapped lines align under the first line instead of falling back to the bullet column. Bullet container switches to `h-[1.4em]` so it tracks the text line-height and pins to the first line's optical center via `items-center` regardless of how much the content wraps. DESIGN.md §5 typography updated to point primary-label callers at `<SettingLabel>`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
217 lines
8.3 KiB
TypeScript
217 lines
8.3 KiB
TypeScript
import clsx from 'clsx';
|
|
import React from 'react';
|
|
|
|
import { MdCheck } from 'react-icons/md';
|
|
import { useRouter } from 'next/navigation';
|
|
import { useEnv } from '@/context/EnvContext';
|
|
import { useAuth } from '@/context/AuthContext';
|
|
import { useReaderStore } from '@/store/readerStore';
|
|
import { useLibraryStore } from '@/store/libraryStore';
|
|
import { useSidebarStore } from '@/store/sidebarStore';
|
|
import { useTranslation } from '@/hooks/useTranslation';
|
|
import { useSettingsStore } from '@/store/settingsStore';
|
|
import { useParallelViewStore } from '@/store/parallelViewStore';
|
|
import { isWebAppPlatform } from '@/services/environment';
|
|
import { eventDispatcher } from '@/utils/event';
|
|
import { FIXED_LAYOUT_FORMATS } from '@/types/book';
|
|
import { DOWNLOAD_READEST_URL } from '@/services/constants';
|
|
import { navigateToLogin } from '@/utils/nav';
|
|
import { saveSysSettings, saveViewSettings } from '@/helpers/settings';
|
|
import { setProofreadRulesVisibility } from '@/app/reader/components/ProofreadRules';
|
|
import { setAboutDialogVisible } from '@/components/AboutWindow';
|
|
import useBooksManager from '../../hooks/useBooksManager';
|
|
import MenuItem from '@/components/MenuItem';
|
|
import Menu from '@/components/Menu';
|
|
|
|
interface BookMenuProps {
|
|
menuClassName?: string;
|
|
setIsDropdownOpen?: (isOpen: boolean) => void;
|
|
}
|
|
|
|
const BookMenu: React.FC<BookMenuProps> = ({ menuClassName, setIsDropdownOpen }) => {
|
|
const _ = useTranslation();
|
|
const router = useRouter();
|
|
const { envConfig, appService } = useEnv();
|
|
const { user } = useAuth();
|
|
const { settings } = useSettingsStore();
|
|
const { bookKeys, recreateViewer, getViewSettings } = useReaderStore();
|
|
const { getVisibleLibrary } = useLibraryStore();
|
|
const { openParallelView } = useBooksManager();
|
|
const { sideBarBookKey } = useSidebarStore();
|
|
const { parallelViews, setParallel, unsetParallel } = useParallelViewStore();
|
|
const viewSettings = getViewSettings(sideBarBookKey!);
|
|
|
|
const [isSortedTOC, setIsSortedTOC] = React.useState(viewSettings?.sortedTOC || false);
|
|
|
|
const handleParallelView = (id: string) => {
|
|
openParallelView(id);
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const handleReloadPage = () => {
|
|
window.location.reload();
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const showAboutReadest = () => {
|
|
setAboutDialogVisible(true);
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const downloadReadest = () => {
|
|
window.open(DOWNLOAD_READEST_URL, '_blank');
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const handleExportAnnotations = () => {
|
|
eventDispatcher.dispatch('export-annotations', { bookKey: sideBarBookKey });
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const handleToggleSortTOC = () => {
|
|
setIsSortedTOC((prev) => !prev);
|
|
setIsDropdownOpen?.(false);
|
|
if (sideBarBookKey) {
|
|
saveViewSettings(envConfig, sideBarBookKey, 'sortedTOC', !isSortedTOC, true, false).then(
|
|
() => {
|
|
recreateViewer(envConfig, sideBarBookKey);
|
|
},
|
|
);
|
|
}
|
|
};
|
|
const handleSetParallel = () => {
|
|
setParallel(bookKeys);
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const handleUnsetParallel = () => {
|
|
unsetParallel(bookKeys);
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const showProofreadRulesWindow = () => {
|
|
setProofreadRulesVisibility(true);
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const handlePullKOSync = () => {
|
|
eventDispatcher.dispatch('pull-kosync', { bookKey: sideBarBookKey });
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const handlePushKOSync = () => {
|
|
eventDispatcher.dispatch('push-kosync', { bookKey: sideBarBookKey });
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const handlePushReadwise = () => {
|
|
eventDispatcher.dispatch('readwise-push-all', { bookKey: sideBarBookKey });
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const handlePushHardcoverNotes = () => {
|
|
eventDispatcher.dispatch('hardcover-push-notes', { bookKey: sideBarBookKey });
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const handlePushHardcoverProgress = () => {
|
|
eventDispatcher.dispatch('hardcover-push-progress', { bookKey: sideBarBookKey });
|
|
setIsDropdownOpen?.(false);
|
|
};
|
|
const toggleDiscordPresence = () => {
|
|
const discordRichPresenceEnabled = !settings.discordRichPresenceEnabled;
|
|
saveSysSettings(envConfig, 'discordRichPresenceEnabled', discordRichPresenceEnabled);
|
|
setIsDropdownOpen?.(false);
|
|
if (discordRichPresenceEnabled && !user) {
|
|
navigateToLogin(router);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Menu
|
|
className={clsx('book-menu dropdown-content z-20 shadow-2xl', menuClassName)}
|
|
onCancel={() => setIsDropdownOpen?.(false)}
|
|
>
|
|
<MenuItem
|
|
label={_('Parallel Read')}
|
|
buttonClass={bookKeys.length > 1 ? 'lg:tooltip lg:tooltip-bottom' : ''}
|
|
tooltip={parallelViews.length > 0 ? _('Disable') : _('Enable')}
|
|
Icon={parallelViews.length > 0 && bookKeys.length > 1 ? MdCheck : undefined}
|
|
>
|
|
<ul className='max-h-60 overflow-y-auto'>
|
|
{getVisibleLibrary()
|
|
.filter((book) => !FIXED_LAYOUT_FORMATS.has(book.format))
|
|
.filter((book) => !!book.downloadedAt)
|
|
.slice(0, 20)
|
|
.map((book) => (
|
|
<MenuItem
|
|
key={book.hash}
|
|
Icon={
|
|
<img
|
|
src={book.coverImageUrl!}
|
|
alt={book.title}
|
|
width={56}
|
|
height={80}
|
|
className='aspect-auto max-h-8 max-w-4 rounded-sm shadow-md'
|
|
onError={(e) => {
|
|
(e.target as HTMLImageElement).style.display = 'none';
|
|
}}
|
|
/>
|
|
}
|
|
label={book.title}
|
|
labelClass='max-w-36'
|
|
onClick={() => handleParallelView(book.hash)}
|
|
/>
|
|
))}
|
|
</ul>
|
|
</MenuItem>
|
|
{bookKeys.length > 1 &&
|
|
(parallelViews.length > 0 ? (
|
|
<MenuItem label={_('Exit Parallel Read')} onClick={handleUnsetParallel} />
|
|
) : (
|
|
<MenuItem label={_('Enter Parallel Read')} onClick={handleSetParallel} />
|
|
))}
|
|
{(settings.kosync.enabled || settings.readwise.enabled || settings.hardcover.enabled) && (
|
|
<hr aria-hidden='true' className='border-base-200 my-1' />
|
|
)}
|
|
{settings.kosync.enabled && (
|
|
<MenuItem label={_('KOReader Sync')} detailsOpen={false} buttonClass='py-2'>
|
|
<ul className='flex flex-col ps-1'>
|
|
<MenuItem label={_('Push Progress')} noIcon onClick={handlePushKOSync} />
|
|
<MenuItem label={_('Pull Progress')} noIcon onClick={handlePullKOSync} />
|
|
</ul>
|
|
</MenuItem>
|
|
)}
|
|
{settings.readwise.enabled && (
|
|
<MenuItem label={_('Readwise Sync')} detailsOpen={false} buttonClass='py-2'>
|
|
<ul className='flex flex-col ps-1'>
|
|
<MenuItem label={_('Push Highlights')} noIcon onClick={handlePushReadwise} />
|
|
</ul>
|
|
</MenuItem>
|
|
)}
|
|
{settings.hardcover.enabled && (
|
|
<MenuItem label={_('Hardcover Sync')} detailsOpen={false} buttonClass='py-2'>
|
|
<ul className='flex flex-col ps-1'>
|
|
<MenuItem label={_('Push Progress')} noIcon onClick={handlePushHardcoverProgress} />
|
|
<MenuItem label={_('Push Notes')} noIcon onClick={handlePushHardcoverNotes} />
|
|
</ul>
|
|
</MenuItem>
|
|
)}
|
|
{appService?.isDesktopApp && (
|
|
<>
|
|
<hr aria-hidden='true' className='border-base-200 my-1' />
|
|
<MenuItem
|
|
label={_('Show on Discord')}
|
|
tooltip={_("Display what I'm reading on Discord")}
|
|
toggled={settings.discordRichPresenceEnabled}
|
|
onClick={toggleDiscordPresence}
|
|
/>
|
|
</>
|
|
)}
|
|
<hr aria-hidden='true' className='border-base-200 my-1' />
|
|
<MenuItem label={_('Proofread')} onClick={showProofreadRulesWindow} />
|
|
<hr aria-hidden='true' className='border-base-200 my-1' />
|
|
<MenuItem label={_('Export Annotations')} onClick={handleExportAnnotations} />
|
|
<MenuItem
|
|
label={_('Sort TOC by Page')}
|
|
Icon={isSortedTOC ? MdCheck : undefined}
|
|
onClick={handleToggleSortTOC}
|
|
/>
|
|
<MenuItem label={_('Reload Page')} shortcut='Shift+R' onClick={handleReloadPage} />
|
|
<hr aria-hidden='true' className='border-base-200 my-1' />
|
|
{isWebAppPlatform() && <MenuItem label={_('Download Readest')} onClick={downloadReadest} />}
|
|
<MenuItem label={_('About Readest')} onClick={showAboutReadest} />
|
|
</Menu>
|
|
);
|
|
};
|
|
|
|
export default BookMenu;
|