* phase 0: token foundation * phase 1: motion language * phase 2: primitives and semantic tokens * phase 3: depth and rhythm polish * phase 4: enforce design system lint rules * phase 5: split ui primitives into modules * phase 7: refactor app surfaces to ui layer * phase 9: enforce ui architecture imports * phase 10: add ui system harness * fix compact reader auth control * fix pdf loader flash * Converge sidebar and reader controls * refactor: remove initial loader state and related logic from PDFViewerPage * Remove legacy UI shim imports * Converge modal and drawer frames * Migrate secondary modals to shared frame * Move settings modal onto shared frame * Use shared cards in audiobook settings * Converge choice and popover surfaces * Converge reader navigation buttons * Refactor UI components to use consistent button and icon styles across the application * refactor(ui): unify button usage in settings, admin, and doclist components Replace native button elements with shared Button, ChoiceTile, and IconButton components for consistent UI behavior and styling. Update classNames and props to match new component APIs. Adjust FinderSidebar to use utility function for conditional class merging. * feat(ui): introduce shared Listbox components for unified select and dropdown styling Replace direct usage of Headless UI Listbox primitives with new SharedListboxButton, SharedListboxOption, and SharedListboxOptions components across AudiobookExportModal, FinderToolbar, VoicesControlBase, and select UI. Refactor related imports and classNames to centralize dropdown styling and logic. Simplify UserMenu button markup for improved consistency. This change consolidates dropdown/select UI patterns, reduces duplication, and improves maintainability by providing a single source of truth for Listbox styling and behavior. * refactor(ui): consolidate button, menu, popover, and range primitives for unified usage Remove legacy UI harness and dev/demo files. Replace scattered button, menu, popover, and range input utilities with shared, composable primitives: Button, ButtonLink, ButtonAnchor, MenuActionItem, MenuItemsSurface, PopoverSurface, PopoverTrigger, and RangeInput. Update all usages across app, admin, player, and document components to use these new primitives, eliminating duplicated class logic and improving consistency. Remove obsolete utility files and class exports. This change streamlines UI code, centralizes styling, and reduces maintenance overhead. * feat(ui): redesign range input with dynamic progress styling and improved accessibility Revamp the range input component to support dynamic progress indication using CSS custom properties and linear gradients. Add logic to compute and set the progress percentage based on current value, min, and max. Refine focus and disabled states for better accessibility and usability. Update styling for both WebKit and Mozilla engines to ensure consistent appearance. This change enhances visual feedback and modernizes the range slider UI. * style(ui): update range input to use secondary accent color for progress Switch range input progress styling from primary to secondary accent color for both WebKit and Mozilla engines. Remove drop shadow from slider thumb for a cleaner appearance. This change aligns the component with the updated design palette and simplifies visual effects. * refactor(app): remove unused Link imports from public pages and components Eliminate redundant imports of the Link component from Next.js in several public-facing pages and components. These imports were no longer in use after recent UI refactoring and consolidation of navigation elements. This cleanup reduces bundle size and improves code clarity. * chore(ui): remove unused export of segmented control classes from select component Eliminate unnecessary export statements for segmentedButtonClass and segmentedGroupClass in the select component to streamline the module's public API and reduce potential confusion. * test(accessibility): improve confirm dialog test coverage and refactor media state helper Expand accessibility tests for ConfirmDialog to assert dialog semantics, ARIA attributes, and visible destructive actions using test IDs. Refactor expectMediaState helper to check both UI control state and underlying media signals for more robust playback state detection. * refactor(ui): improve segmented control accessibility and update danger color tokens Update SegmentedControl to support full keyboard navigation and focus management, enhancing accessibility. Replace string indicator in Select with icon, and update button danger variant to use new --danger-strong variable for hover states. Add danger-strong token to Tailwind config and globals. Refine dropzone disabled behavior, adjust focus ring for better contrast, and apply minor UI consistency tweaks across components. * feat(ui): convert SidebarNavLink to forwardRef component Refactor SidebarNavLink to use React.forwardRef, enabling parent components to access the underlying anchor element's ref. Update prop typing and function signature accordingly for improved composability and integration with higher-order components.
168 lines
5.1 KiB
TypeScript
168 lines
5.1 KiB
TypeScript
'use client';
|
|
|
|
import { useState, useEffect } from 'react';
|
|
import { updateAppConfig } from '@/lib/client/dexie';
|
|
import { Button, ModalFrame, ModalTitle } from '@/components/ui';
|
|
|
|
interface PrivacyModalProps {
|
|
isOpen: boolean;
|
|
onAccept?: () => void;
|
|
onDismiss?: () => void;
|
|
}
|
|
|
|
function PrivacyModalBody({ origin }: { origin: string }) {
|
|
return (
|
|
<div className="mt-4 space-y-4 text-sm text-soft">
|
|
<div className="rounded-lg border border-line bg-surface-sunken p-3">
|
|
<div className="text-xs font-semibold uppercase tracking-wide text-soft">Service Operator</div>
|
|
<div className="mt-1">
|
|
This instance is hosted at <span className="font-bold">{origin || 'this server'}</span>.
|
|
</div>
|
|
</div>
|
|
|
|
<p className="leading-relaxed">
|
|
We value your privacy. This application uses strictly necessary cookies for authentication
|
|
and optional analytics only when consent allows it. Your documents are stored encrypted at rest.
|
|
</p>
|
|
|
|
<p className="leading-relaxed">
|
|
OpenReader does not currently provide end-to-end encryption.
|
|
</p>
|
|
|
|
<p className="leading-relaxed">
|
|
The owner of this instance may be able to access stored metadata and uploaded files needed to operate the
|
|
service.
|
|
</p>
|
|
|
|
<p className="leading-relaxed">
|
|
Passwords are not stored as readable plaintext.
|
|
</p>
|
|
|
|
<p className="leading-relaxed">
|
|
For full details on data collection, processing, and your rights, please review our complete{' '}
|
|
<a href="/privacy" target="_blank" className="font-semibold text-accent hover:underline">Privacy Policy</a>.
|
|
</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function PrivacyModal({ isOpen, onAccept, onDismiss }: PrivacyModalProps) {
|
|
const [origin, setOrigin] = useState('');
|
|
const [agreed, setAgreed] = useState(false);
|
|
|
|
useEffect(() => {
|
|
if (typeof window === 'undefined') return;
|
|
setOrigin(window.location.origin);
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
if (isOpen) {
|
|
setAgreed(false);
|
|
}
|
|
}, [isOpen]);
|
|
|
|
const handleAccept = async () => {
|
|
await updateAppConfig({ privacyAccepted: true });
|
|
if (typeof window !== 'undefined') {
|
|
window.dispatchEvent(new Event('openreader:privacyAccepted'));
|
|
}
|
|
onAccept?.();
|
|
};
|
|
|
|
return (
|
|
<ModalFrame open={isOpen} onClose={onDismiss ?? (() => {})} panelTestId="privacy-modal" className="z-[80]">
|
|
<ModalTitle>Privacy & Data Usage</ModalTitle>
|
|
|
|
<PrivacyModalBody origin={origin} />
|
|
|
|
<div className="mt-6 space-y-4">
|
|
<div className="flex items-start gap-3 rounded-lg border border-line p-3 bg-surface-sunken">
|
|
<div className="flex h-6 items-center">
|
|
<input
|
|
data-testid="privacy-agree-checkbox"
|
|
id="privacy-agree"
|
|
type="checkbox"
|
|
checked={agreed}
|
|
onChange={(e) => setAgreed(e.target.checked)}
|
|
className="h-4 w-4 rounded border-line text-accent focus:ring-accent-line bg-surface"
|
|
/>
|
|
</div>
|
|
<div className="text-sm leading-6">
|
|
<label htmlFor="privacy-agree" className="font-medium text-foreground select-none cursor-pointer">
|
|
I have read and agree to the
|
|
</label>{' '}
|
|
<a href="/privacy" target="_blank" className="font-semibold text-accent hover:underline">
|
|
Privacy Policy
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex justify-end">
|
|
<Button
|
|
data-testid="privacy-continue-button"
|
|
variant="primary"
|
|
size="lg"
|
|
disabled={!agreed}
|
|
onClick={handleAccept}
|
|
>
|
|
Continue
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</ModalFrame>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Function to programmatically show the privacy popup
|
|
* This can be called from signin/signup components
|
|
*/
|
|
export function showPrivacyModal(): void {
|
|
// Create a temporary container for the popup
|
|
const container = document.createElement('div');
|
|
container.id = 'privacy-modal-container';
|
|
document.body.appendChild(container);
|
|
|
|
const origin = typeof window !== 'undefined' ? window.location.origin : '';
|
|
// Import React and render the popup
|
|
import('react-dom/client').then(({ createRoot }) => {
|
|
import('react').then((React) => {
|
|
const root = createRoot(container);
|
|
|
|
const PopupWrapper = () => {
|
|
const [show, setShow] = useState(true);
|
|
|
|
const handleClose = () => {
|
|
setShow(false);
|
|
};
|
|
|
|
return (
|
|
<ModalFrame
|
|
open={show}
|
|
onClose={handleClose}
|
|
afterLeave={() => {
|
|
root.unmount();
|
|
container.remove();
|
|
}}
|
|
>
|
|
<ModalTitle>Privacy & Data Usage</ModalTitle>
|
|
|
|
<PrivacyModalBody origin={origin} />
|
|
|
|
<div className="mt-6 flex justify-end">
|
|
<Button
|
|
variant="primary"
|
|
size="lg"
|
|
onClick={handleClose}
|
|
>
|
|
Close
|
|
</Button>
|
|
</div>
|
|
</ModalFrame>
|
|
);
|
|
};
|
|
|
|
root.render(React.createElement(PopupWrapper));
|
|
});
|
|
});
|
|
}
|