Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 69 additions & 1 deletion lumen/i18n-keys.json
Original file line number Diff line number Diff line change
Expand Up @@ -2299,6 +2299,38 @@
"lumen.browse.browseGenres",
"lumen.browse.checkedPopular",
"lumen.browse.clearFilters",
"lumen.browse.filters",
"lumen.browse.filtersDone",
"lumen.browse.removeFilter",
"lumen.browse.notFilter",
"lumen.browse.activeFilters",
"lumen.filters.clearAll",
"lumen.search.someSourcesFailed",
"lumen.search.source.books",
"lumen.search.source.comics",
"lumen.search.source.titles",
"lumen.search.source.some",
"lumen.detail.moreActions",
"lumen.detail.more",
"lumen.detail.close",
"lumen.detail.showMore",
"lumen.detail.showLess",
"lumen.account.jumpTo",
"lumen.account.importLists",
"lumen.me.importLists",
"lumen.me.importListsHelp",
"lumen.music.player.hearth",
"lumen.music.player.hearthHelp",
"lumen.music.backToDiscover",
"lumen.adminSettings.musicAppsTitle",
"lumen.adminSettings.musicAppsHelp",
"lumen.adminSettings.musicDefaultApp",
"lumen.podcasts.followingFilter",
"lumen.podcasts.filterAll",
"lumen.podcasts.filterFollowing",
"lumen.podcasts.filterNotFollowing",
"lumen.podcasts.noneFollowed",
"lumen.podcasts.allFollowed",
"lumen.browse.clearNetwork",
"lumen.browse.clearStudio",
"lumen.browse.clearSubjectTags",
Expand Down Expand Up @@ -6916,5 +6948,41 @@
"i18n.loading",
"i18n.saving",
"library.episodes",
"library.library"
"library.library",
"lumen.music.allSongs",
"lumen.detail.discoverNavigation",
"lumen.videoRating.showAll",
"lumen.status.hdAnd4k",
"lumen.detail.showAllCount",
"lumen.detail.castCrew",
"lumen.detail.details",
"lumen.music.creditsDetails",
"lumen.me.libraryTools",
"lumen.admin.home.mediaServices",
"lumen.detail.allEditions",
"lumen.detail.showFewer",
"lumen.bookDetail.allNarrations",
"lumen.bookDetail.edition",
"lumen.bookDetail.ebookEpub",
"lumen.bookDetail.pageCount",
"lumen.search.suggest.queries",
"lumen.search.suggest.recent",
"lumen.search.suggest.people",
"lumen.search.suggest.titles",
"lumen.search.suggest.didYouMean",
"lumen.search.suggest.owned",
"lumen.search.suggest.label",
"lumen.search.top.heading",
"lumen.search.top.person",
"lumen.search.top.series",
"lumen.search.top.movie",
"lumen.search.top.openSeason",
"lumen.search.top.matches",
"lumen.search.top.knownFor",
"lumen.search.showingResultsFor",
"lumen.search.didYouMean",
"lumen.search.source.video",
"lumen.search.source.music",
"lumen.search.source.authors",
"lumen.search.source.magazines"
]
228 changes: 216 additions & 12 deletions lumen/i18n-overrides.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lumen/src/components/BookRequestOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useAuth } from '../auth';
import { friendlyError } from '../errors';
import { useApi } from '../hooks';
import { useLumenLocale } from '../i18n';
import { Icon } from '../icons';
import { canChooseRequestOptions, canRequestAs } from './detail';

type Format = 'ebook' | 'audiobook';
Expand Down Expand Up @@ -110,6 +111,7 @@ export default function BookRequestOptions({
onToggle={(event) => setOpen(event.currentTarget.open)}
>
<summary>
<Icon name="chev" size="sm" />
{t('lumen.bulkBooks.advancedOptions', 'Advanced Request Options')}
</summary>
<div className="adv-grid">
Expand Down
50 changes: 50 additions & 0 deletions lumen/src/components/ClampText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { useLayoutEffect, useRef, useState, type ReactNode } from 'react';
import { useLumenLocale } from '../i18n';
import { usePhone } from './PhoneFilters';

// Long descriptions on phones show about four lines, with Show more for the rest.
export function ClampText({
children,
className = 'ov',
lines,
}: {
children: ReactNode;
className?: string;
// a fixed number of lines on every screen size (default: four, phones only)
lines?: number;
}) {
const { t } = useLumenLocale();
const phone = usePhone() || lines !== undefined;
const box = useRef<HTMLParagraphElement>(null);
const [overflows, setOverflows] = useState(false);
const [open, setOpen] = useState(false);
useLayoutEffect(() => {
const node = box.current;
if (!node || !phone || open) return;
setOverflows(node.scrollHeight > node.clientHeight + 2);
}, [phone, open, children]);
return (
<div className="clamp-text">
<p
ref={box}
className={
phone && !open ? `${className} clamp-${lines ?? 4}` : className
}
>
{children}
</p>
{phone && (overflows || open) && (
<button
type="button"
className={lines !== undefined ? 'more-link' : 'btn btn-quiet btn-sm'}
aria-expanded={open}
onClick={() => setOpen(!open)}
>
{open
? t('lumen.detail.showLess', 'Show less')
: t('lumen.detail.showMore', 'Show more')}
</button>
)}
</div>
);
}
39 changes: 39 additions & 0 deletions lumen/src/components/EditionPreview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useLumenLocale } from '../i18n';

// Edition and narration pickers show the first few rows; the rest open with "All N editions".
export const EDITION_PREVIEW = 4;

// Only folds when it hides at least two rows. A row kept by `keep` (the selection) always shows.
export const foldsEditions = (count: number) => count > EDITION_PREVIEW + 1;

export function previewRows<T>(
rows: T[],
open: boolean,
keep: (row: T) => boolean
): T[] {
if (open || !foldsEditions(rows.length)) return rows;
return rows.filter((row, i) => i < EDITION_PREVIEW || keep(row));
}

export function MoreEditions({
open,
onToggle,
label,
}: {
open: boolean;
onToggle: () => void;
// the closed label, e.g. "All 12 editions"
label: string;
}) {
const { t } = useLumenLocale();
return (
<button
type="button"
className="more-link"
aria-expanded={open}
onClick={onToggle}
>
{open ? t('lumen.detail.showFewer', 'Show fewer') : label}
</button>
);
}
1 change: 1 addition & 0 deletions lumen/src/components/ExternalRequestLists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export function ExternalRequestLists() {

return (
<Section
id="import-lists"
title={t('lumen.account.external.title', 'External Request Lists')}
>
<p className="note">
Expand Down
136 changes: 136 additions & 0 deletions lumen/src/components/MoreActions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import {
createContext,
useContext,
useLayoutEffect,
useRef,
useState,
type ReactNode,
} from 'react';
import { useLumenLocale } from '../i18n';
import { Icon } from '../icons';
import { Section } from './cards';
import { FilterSheet, usePhone } from './PhoneFilters';

// Phones keep a detail page's main actions in view and fold the occasional ones (indexer
// search, blocklist, issue reports, associations and the like) into one More sheet; wider
// screens show them inline as before. Each action keeps its own permission check: More only
// shows when two or more of them have something to offer; a single one shows in place.
export function MoreActions({ children }: { children: ReactNode }) {
const { t } = useLumenLocale();
const phone = usePhone();
const probe = useRef<HTMLSpanElement>(null);
const [count, setCount] = useState(0);
const [open, setOpen] = useState(false);
useLayoutEffect(() => {
const node = probe.current;
if (!node) return;
const check = () => setCount(node.childElementCount);
check();
const watcher = new MutationObserver(check);
watcher.observe(node, { childList: true });
return () => watcher.disconnect();
}, [phone]);
if (!phone) return <span className="detail-actions">{children}</span>;
const label = t('lumen.detail.moreActions', 'More actions');
return (
<>
{/* one action needs no sheet: it shows in place */}
<span
ref={probe}
hidden={count !== 1}
className={count === 1 ? 'more-actions-single' : 'more-actions-probe'}
>
{children}
</span>
{count > 1 && (
<button
type="button"
className="chip more-actions-btn"
aria-haspopup="dialog"
aria-label={label}
onClick={() => setOpen(true)}
>
<Icon name="more" size="sm" />
<span className="more-lbl">{t('lumen.detail.more', 'More')}</span>
</button>
)}
{open && (
<FilterSheet
title={label}
onClose={() => setOpen(false)}
done={t('lumen.detail.close', 'Close')}
>
<div className="more-actions-list">{children}</div>
</FilterSheet>
)}
</>
);
}

// Inside a folded phone group, PhoneSubsection shows a small heading instead of a section.
const PhoneGroupContext = createContext(false);

// A settings group that phones fold behind its title; wider screens keep the open section.
// With splitOnWide, wider screens show each PhoneSubsection inside as its own section (as
// before), while phones fold them together under one title.
export function PhoneSection({
title,
id,
splitOnWide = false,
children,
}: {
title: string;
id?: string;
splitOnWide?: boolean;
children: ReactNode;
}) {
const phone = usePhone();
if (!phone)
return splitOnWide ? (
<>{children}</>
) : (
<Section title={title} id={id}>
{children}
</Section>
);
return (
<details className="adv phone-section" id={id}>
{/* still a heading for screen readers and page outlines while folded */}
<summary>
<Icon name="chev" size="sm" />
<h2 className="phone-section-title">{title}</h2>
</summary>
<div className="phone-section-body">
<PhoneGroupContext.Provider value={true}>
{children}
</PhoneGroupContext.Provider>
</div>
</details>
);
}

// One group inside a combined PhoneSection: its own section on wider screens, a small
// heading inside the shared fold on phones.
export function PhoneSubsection({
title,
id,
children,
}: {
title: string;
id?: string;
children: ReactNode;
}) {
const grouped = useContext(PhoneGroupContext);
if (!grouped)
return (
<Section title={title} id={id}>
{children}
</Section>
);
return (
<div className="phone-sub" id={id}>
<h3 className="phone-sub-title">{title}</h3>
{children}
</div>
);
}
Loading
Loading