@lapis-notes/lapis-plugin-docs 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +188 -2
- package/dist/docs/DocsBlockMarkdownEditor.svelte +37 -0
- package/dist/docs/DocsBlockMarkdownEditor.svelte.d.ts +13 -0
- package/dist/docs/DocsBlockRefPicker.svelte +75 -0
- package/dist/docs/DocsBlockRefPicker.svelte.d.ts +11 -0
- package/dist/docs/DocsBookEditor.svelte +141 -0
- package/dist/docs/DocsBookEditor.svelte.d.ts +10 -0
- package/dist/docs/DocsBookNavigation.svelte +838 -0
- package/dist/docs/DocsBookNavigation.svelte.d.ts +11 -0
- package/dist/docs/DocsBooksColumn.svelte +82 -0
- package/dist/docs/DocsBooksColumn.svelte.d.ts +10 -0
- package/dist/docs/DocsCardBackMatter.svelte +32 -0
- package/dist/docs/DocsCardBackMatter.svelte.d.ts +10 -0
- package/dist/docs/DocsCardBlockExtra.svelte +43 -0
- package/dist/docs/DocsCardBlockExtra.svelte.d.ts +9 -0
- package/dist/docs/DocsCardPreviewFlip.svelte +143 -0
- package/dist/docs/DocsCardPreviewFlip.svelte.d.ts +17 -0
- package/dist/docs/DocsCardPreviewStack.svelte +135 -0
- package/dist/docs/DocsCardPreviewStack.svelte.d.ts +13 -0
- package/dist/docs/DocsCardPrompt.svelte +33 -0
- package/dist/docs/DocsCardPrompt.svelte.d.ts +8 -0
- package/dist/docs/DocsCardReviewAnswer.svelte +45 -0
- package/dist/docs/DocsCardReviewAnswer.svelte.d.ts +8 -0
- package/dist/docs/DocsCardTagChips.svelte +19 -0
- package/dist/docs/DocsCardTagChips.svelte.d.ts +7 -0
- package/dist/docs/DocsCardsPanel.svelte +232 -0
- package/dist/docs/DocsCardsPanel.svelte.d.ts +17 -0
- package/dist/docs/DocsCardsReview.css +1050 -0
- package/dist/docs/DocsChapterFooter.svelte +248 -0
- package/dist/docs/DocsChapterFooter.svelte.d.ts +11 -0
- package/dist/docs/DocsChapterScrollRing.svelte +101 -0
- package/dist/docs/DocsChapterScrollRing.svelte.d.ts +6 -0
- package/dist/docs/DocsDisplayPanel.css +627 -0
- package/dist/docs/DocsDisplayPanel.svelte +78 -0
- package/dist/docs/DocsDisplayPanel.svelte.d.ts +16 -0
- package/dist/docs/DocsEditorPanel.css +325 -0
- package/dist/docs/DocsEditorPanel.svelte +570 -0
- package/dist/docs/DocsEditorPanel.svelte.d.ts +22 -0
- package/dist/docs/DocsFlipCard.svelte +68 -0
- package/dist/docs/DocsFlipCard.svelte.d.ts +8 -0
- package/dist/docs/DocsFolderDirectoryList.svelte +206 -0
- package/dist/docs/DocsFolderDirectoryList.svelte.d.ts +14 -0
- package/dist/docs/DocsFolderPanel.css +357 -0
- package/dist/docs/DocsFolderPanel.svelte +102 -0
- package/dist/docs/DocsFolderPanel.svelte.d.ts +17 -0
- package/dist/docs/DocsLinksPanel.css +61 -0
- package/dist/docs/DocsLinksPanel.svelte +55 -0
- package/dist/docs/DocsLinksPanel.svelte.d.ts +11 -0
- package/dist/docs/DocsMarkdownField.svelte +93 -0
- package/dist/docs/DocsMarkdownField.svelte.d.ts +11 -0
- package/dist/docs/DocsMarkdownPreview.svelte +278 -0
- package/dist/docs/DocsMarkdownPreview.svelte.d.ts +17 -0
- package/dist/docs/DocsReviewPanel.svelte +63 -0
- package/dist/docs/DocsReviewPanel.svelte.d.ts +11 -0
- package/dist/docs/DocsRichBlock.svelte +291 -0
- package/dist/docs/DocsRichBlock.svelte.d.ts +13 -0
- package/dist/docs/DocsRichDisplay.svelte +316 -0
- package/dist/docs/DocsRichDisplay.svelte.d.ts +14 -0
- package/dist/docs/DocsSlidesPreview.css +243 -0
- package/dist/docs/DocsSlidesPreview.svelte +206 -0
- package/dist/docs/DocsSlidesPreview.svelte.d.ts +10 -0
- package/dist/docs/DocsWorkspace.css +570 -0
- package/dist/docs/DocsWorkspace.svelte +831 -0
- package/dist/docs/DocsWorkspace.svelte.d.ts +48 -0
- package/dist/docs/DocsWorkspaceToolbar.svelte +211 -0
- package/dist/docs/DocsWorkspaceToolbar.svelte.d.ts +27 -0
- package/dist/docs/candidates/ChoiceMenu.svelte +114 -0
- package/dist/docs/candidates/ChoiceMenu.svelte.d.ts +10 -0
- package/dist/docs/candidates/FlipCardDeck.svelte +800 -0
- package/dist/docs/candidates/FlipCardDeck.svelte.d.ts +36 -0
- package/dist/docs/candidates/MarkdownFloatingToc.svelte +313 -0
- package/dist/docs/candidates/MarkdownFloatingToc.svelte.d.ts +14 -0
- package/dist/docs/candidates/SearchableChoicePicker.css +161 -0
- package/dist/docs/candidates/SearchableChoicePicker.svelte +208 -0
- package/dist/docs/candidates/SearchableChoicePicker.svelte.d.ts +19 -0
- package/dist/docs/candidates/StructuredTable.svelte +98 -0
- package/dist/docs/candidates/StructuredTable.svelte.d.ts +8 -0
- package/dist/docs/candidates/StructuredTableEditor.svelte +374 -0
- package/dist/docs/candidates/StructuredTableEditor.svelte.d.ts +12 -0
- package/dist/docs/candidates/TagEditor.svelte +31 -0
- package/dist/docs/candidates/TagEditor.svelte.d.ts +14 -0
- package/dist/docs/candidates/WorkspaceHistoryControls.svelte +112 -0
- package/dist/docs/candidates/WorkspaceHistoryControls.svelte.d.ts +8 -0
- package/dist/docs/candidates/markdown-floating-toc.css +151 -0
- package/dist/docs/candidates/markdown-floating-toc.d.ts +1 -0
- package/dist/docs/candidates/markdown-floating-toc.js +1 -0
- package/dist/docs/docs-anki-import.d.ts +34 -0
- package/dist/docs/docs-anki-import.js +516 -0
- package/dist/docs/docs-book-view-model.d.ts +9 -0
- package/dist/docs/docs-book-view-model.js +71 -0
- package/dist/docs/docs-card-answer-markdown.d.ts +1 -0
- package/dist/docs/docs-card-answer-markdown.js +63 -0
- package/dist/docs/docs-card-display.d.ts +10 -0
- package/dist/docs/docs-card-display.js +18 -0
- package/dist/docs/docs-display-focus.d.ts +7 -0
- package/dist/docs/docs-display-focus.js +42 -0
- package/dist/docs/docs-document-surface.d.ts +7 -0
- package/dist/docs/docs-document-surface.js +25 -0
- package/dist/docs/docs-folder-directory.d.ts +21 -0
- package/dist/docs/docs-folder-directory.js +56 -0
- package/dist/docs/docs-link-mode.d.ts +16 -0
- package/dist/docs/docs-link-mode.js +94 -0
- package/dist/docs/docs-workspace-helpers.d.ts +25 -0
- package/dist/docs/docs-workspace-helpers.js +195 -0
- package/dist/docs/docs.tokens.css +13 -0
- package/dist/docs/import-anki-package.d.ts +10 -0
- package/dist/docs/import-anki-package.js +30 -0
- package/dist/docs/lapis-markdown-extensions.d.ts +9 -0
- package/dist/docs/lapis-markdown-extensions.js +128 -0
- package/dist/docs/pin-reading-chrome.d.ts +4 -0
- package/dist/docs/pin-reading-chrome.js +32 -0
- package/dist/docs/sidebar/DocsFoldersSidebar.svelte +134 -0
- package/dist/docs/sidebar/DocsFoldersSidebar.svelte.d.ts +15 -0
- package/dist/docs/sidebar/DocsLinksSidebar.svelte +105 -0
- package/dist/docs/sidebar/DocsLinksSidebar.svelte.d.ts +11 -0
- package/dist/docs/sidebar/DocsSidebar.css +346 -0
- package/dist/docs/sidebar/DocsSidebar.svelte +430 -0
- package/dist/docs/sidebar/DocsSidebar.svelte.d.ts +18 -0
- package/dist/docs/sidebar/DocsSidebarHost.svelte +139 -0
- package/dist/docs/sidebar/DocsSidebarHost.svelte.d.ts +12 -0
- package/dist/docs/sidebar/DocsTagsSidebar.svelte +176 -0
- package/dist/docs/sidebar/DocsTagsSidebar.svelte.d.ts +12 -0
- package/dist/docs/sidebar/docs-book-note-tree.d.ts +23 -0
- package/dist/docs/sidebar/docs-book-note-tree.js +88 -0
- package/dist/docs/sidebar/docs-note-sort.d.ts +26 -0
- package/dist/docs/sidebar/docs-note-sort.js +54 -0
- package/dist/docs/sidebar/docs-sidebar-filters.d.ts +17 -0
- package/dist/docs/sidebar/docs-sidebar-filters.js +74 -0
- package/dist/docs/sidebar/docs-sidebar-ui-storage.d.ts +24 -0
- package/dist/docs/sidebar/docs-sidebar-ui-storage.js +87 -0
- package/dist/docs/sidebar/docs-source-folder-tree.d.ts +16 -0
- package/dist/docs/sidebar/docs-source-folder-tree.js +143 -0
- package/dist/docs/sidebar/docs-tag-tree.d.ts +17 -0
- package/dist/docs/sidebar/docs-tag-tree.js +84 -0
- package/dist/docs-cards-view.d.ts +18 -0
- package/dist/docs-cards-view.js +52 -0
- package/dist/docs-document-view.d.ts +24 -0
- package/dist/docs-document-view.js +127 -0
- package/dist/docs-document-workspace.svelte +215 -0
- package/dist/docs-document-workspace.svelte.d.ts +16 -0
- package/dist/docs-index.d.ts +5 -0
- package/dist/docs-index.js +49 -0
- package/dist/docs-path.d.ts +6 -0
- package/dist/docs-path.js +10 -0
- package/dist/docs-plugin.d.ts +21 -0
- package/dist/docs-plugin.js +140 -0
- package/dist/docs-repository.d.ts +15 -0
- package/dist/docs-repository.js +75 -0
- package/dist/docs-review-view.d.ts +18 -0
- package/dist/docs-review-view.js +52 -0
- package/dist/docs-settings-tab.d.ts +8 -0
- package/dist/docs-settings-tab.js +25 -0
- package/dist/docs-settings.d.ts +17 -0
- package/dist/docs-settings.js +38 -0
- package/dist/docs-view.d.ts +22 -0
- package/dist/docs-view.js +51 -0
- package/dist/docs-workspace.svelte +394 -0
- package/dist/docs-workspace.svelte.d.ts +15 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/model/book.d.ts +6 -0
- package/dist/model/book.js +101 -0
- package/dist/model/coding-runtime.d.ts +4 -0
- package/dist/model/coding-runtime.js +9 -0
- package/dist/model/docs-card-context.d.ts +32 -0
- package/dist/model/docs-card-context.js +89 -0
- package/dist/model/docs-card-preview-stack-motion.d.ts +51 -0
- package/dist/model/docs-card-preview-stack-motion.js +94 -0
- package/dist/model/docs-media-context.d.ts +9 -0
- package/dist/model/docs-media-context.js +18 -0
- package/dist/model/docs-note-list.d.ts +8 -0
- package/dist/model/docs-note-list.js +25 -0
- package/dist/model/docs-relative-media.d.ts +30 -0
- package/dist/model/docs-relative-media.js +116 -0
- package/dist/model/docs-review-constants.d.ts +4 -0
- package/dist/model/docs-review-constants.js +13 -0
- package/dist/model/fsrs.d.ts +14 -0
- package/dist/model/fsrs.js +153 -0
- package/dist/model/graph.d.ts +12 -0
- package/dist/model/graph.js +169 -0
- package/dist/model/index.d.ts +14 -0
- package/dist/model/index.js +14 -0
- package/dist/model/markdown-normalize.d.ts +11 -0
- package/dist/model/markdown-normalize.js +755 -0
- package/dist/model/markdown.d.ts +167 -0
- package/dist/model/markdown.js +365 -0
- package/dist/model/sample.d.ts +7 -0
- package/dist/model/sample.js +524 -0
- package/dist/model/types.d.ts +328 -0
- package/dist/model/types.js +1 -0
- package/dist/model/workspace.d.ts +6 -0
- package/dist/model/workspace.js +81 -0
- package/dist/storybook.css +52 -0
- package/dist/styles.css +1 -0
- package/manifest.json +11 -0
- package/package.json +147 -4
|
@@ -0,0 +1,800 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* DESIGN_CORE_CANDIDATE: FlipCardDeck — ported for Docs; promote to design-core/forms later.
|
|
4
|
+
*/
|
|
5
|
+
import ChevronLeftIcon from '@lucide/svelte/icons/chevron-left';
|
|
6
|
+
import ChevronRightIcon from '@lucide/svelte/icons/chevron-right';
|
|
7
|
+
import EyeIcon from '@lucide/svelte/icons/eye';
|
|
8
|
+
import ListOrderedIcon from '@lucide/svelte/icons/list-ordered';
|
|
9
|
+
import type { Snippet } from 'svelte';
|
|
10
|
+
|
|
11
|
+
export type FlipCardDeckMode = 'browse' | 'study';
|
|
12
|
+
|
|
13
|
+
export type FlipCardDeckContext = {
|
|
14
|
+
key: string;
|
|
15
|
+
index: number;
|
|
16
|
+
count: number;
|
|
17
|
+
peek: boolean;
|
|
18
|
+
revealed: boolean;
|
|
19
|
+
reveal: () => void;
|
|
20
|
+
hide: () => void;
|
|
21
|
+
toggle: () => void;
|
|
22
|
+
next: () => void;
|
|
23
|
+
previous: () => void;
|
|
24
|
+
goTo: (index: number) => void;
|
|
25
|
+
reset: () => void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type SwipeDrag = {
|
|
29
|
+
pointerId: number;
|
|
30
|
+
startX: number;
|
|
31
|
+
startY: number;
|
|
32
|
+
deltaX: number;
|
|
33
|
+
active: boolean;
|
|
34
|
+
target: HTMLElement;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
let {
|
|
38
|
+
items = [],
|
|
39
|
+
keyFor = defaultKeyFor,
|
|
40
|
+
revealedByKey = $bindable({}),
|
|
41
|
+
ariaLabel = 'Card deck',
|
|
42
|
+
emptyLabel = 'No cards yet.',
|
|
43
|
+
mode = 'browse',
|
|
44
|
+
initialIndex = 0,
|
|
45
|
+
blockSwipeWhenRevealed = true,
|
|
46
|
+
indexControlLabel = '',
|
|
47
|
+
indexControlTarget = 0,
|
|
48
|
+
frontActionLabel = 'Show Answer',
|
|
49
|
+
backActionLabel = 'Show Question',
|
|
50
|
+
front,
|
|
51
|
+
back,
|
|
52
|
+
backActions
|
|
53
|
+
}: {
|
|
54
|
+
items: unknown[];
|
|
55
|
+
keyFor?: (item: unknown, index: number) => string;
|
|
56
|
+
revealedByKey: Record<string, boolean>;
|
|
57
|
+
ariaLabel?: string;
|
|
58
|
+
emptyLabel?: string;
|
|
59
|
+
mode?: FlipCardDeckMode;
|
|
60
|
+
initialIndex?: number;
|
|
61
|
+
blockSwipeWhenRevealed?: boolean;
|
|
62
|
+
indexControlLabel?: string;
|
|
63
|
+
indexControlTarget?: number;
|
|
64
|
+
frontActionLabel?: string;
|
|
65
|
+
backActionLabel?: string;
|
|
66
|
+
front: Snippet<[unknown, FlipCardDeckContext]>;
|
|
67
|
+
back: Snippet<[unknown, FlipCardDeckContext]>;
|
|
68
|
+
backActions?: Snippet<[unknown, FlipCardDeckContext]>;
|
|
69
|
+
} = $props();
|
|
70
|
+
|
|
71
|
+
const visibleDepth = 3;
|
|
72
|
+
const swipeActivationThreshold = 8;
|
|
73
|
+
const swipeCommitThreshold = 96;
|
|
74
|
+
|
|
75
|
+
let activeIndex = $state(0);
|
|
76
|
+
let appliedInitialIndex = $state<number | null>(null);
|
|
77
|
+
let swipeDrag = $state<SwipeDrag | null>(null);
|
|
78
|
+
let swipeOwnerDocument = $state<Document | null>(null);
|
|
79
|
+
let swipeReleaseX = $state<number | null>(null);
|
|
80
|
+
let swipeReleaseTimer: ReturnType<typeof setTimeout> | undefined;
|
|
81
|
+
|
|
82
|
+
const cardCount = $derived(items.length);
|
|
83
|
+
const resolvedIndex = $derived(resolveIndex(activeIndex, cardCount, mode));
|
|
84
|
+
const visibleCount = $derived(
|
|
85
|
+
mode === 'study'
|
|
86
|
+
? Math.min(visibleDepth, Math.max(0, cardCount - resolvedIndex))
|
|
87
|
+
: Math.min(visibleDepth, cardCount)
|
|
88
|
+
);
|
|
89
|
+
const stackItems = $derived(
|
|
90
|
+
Array.from({ length: visibleCount }, (_, depth) => {
|
|
91
|
+
const index = resolveIndex(resolvedIndex + depth, cardCount, mode);
|
|
92
|
+
const item = items[index];
|
|
93
|
+
return {
|
|
94
|
+
item,
|
|
95
|
+
index,
|
|
96
|
+
depth,
|
|
97
|
+
key: item ? keyFor(item, index) : `${index}`
|
|
98
|
+
};
|
|
99
|
+
}).filter((entry) => entry.item !== undefined)
|
|
100
|
+
);
|
|
101
|
+
const canGoPrevious = $derived(cardCount > 1 && (mode === 'browse' || resolvedIndex > 0));
|
|
102
|
+
const canGoNext = $derived(cardCount > 1 && (mode === 'browse' || resolvedIndex < cardCount - 1));
|
|
103
|
+
const topKey = $derived(stackItems[0]?.key ?? '');
|
|
104
|
+
const topRevealed = $derived(topKey ? revealedByKey[topKey] === true : false);
|
|
105
|
+
|
|
106
|
+
$effect(() => {
|
|
107
|
+
if (cardCount === 0) {
|
|
108
|
+
activeIndex = 0;
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (initialIndex !== appliedInitialIndex) {
|
|
112
|
+
appliedInitialIndex = initialIndex;
|
|
113
|
+
activeIndex = resolveIndex(initialIndex, cardCount, mode);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const next = resolveIndex(activeIndex, cardCount, mode);
|
|
117
|
+
if (next !== activeIndex) activeIndex = next;
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
$effect(() => {
|
|
121
|
+
return () => {
|
|
122
|
+
clearSwipeDrag();
|
|
123
|
+
resetSwipeRelease();
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
function defaultKeyFor(item: unknown, index: number) {
|
|
128
|
+
if (item && typeof item === 'object' && 'id' in item) return String(item.id);
|
|
129
|
+
return String(index);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function resolveIndex(index: number, count: number, valueMode: FlipCardDeckMode) {
|
|
133
|
+
if (count <= 0) return 0;
|
|
134
|
+
if (valueMode === 'study') return Math.min(Math.max(index, 0), count - 1);
|
|
135
|
+
return ((index % count) + count) % count;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function currentResolvedIndex() {
|
|
139
|
+
return resolveIndex(activeIndex, items.length, mode);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function currentTopKey() {
|
|
143
|
+
const count = items.length;
|
|
144
|
+
if (count === 0) return '';
|
|
145
|
+
const index = currentResolvedIndex();
|
|
146
|
+
const item = items[index];
|
|
147
|
+
return item ? keyFor(item, index) : '';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function currentTopRevealed() {
|
|
151
|
+
const key = currentTopKey();
|
|
152
|
+
return key ? revealedByKey[key] === true : false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function canNavigatePrevious() {
|
|
156
|
+
const count = items.length;
|
|
157
|
+
if (count <= 1) return false;
|
|
158
|
+
return mode === 'browse' || currentResolvedIndex() > 0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function canNavigateNext() {
|
|
162
|
+
const count = items.length;
|
|
163
|
+
if (count <= 1) return false;
|
|
164
|
+
return mode === 'browse' || currentResolvedIndex() < count - 1;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function setRevealed(key: string, revealed: boolean) {
|
|
168
|
+
revealedByKey = { ...revealedByKey, [key]: revealed };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function focusFaceAction(source: Element | null, face: 'front' | 'back') {
|
|
172
|
+
const flip = source?.closest('.flip-card-deck__flip-inner');
|
|
173
|
+
const targetFace = flip?.querySelector<HTMLElement>(`.flip-card-deck__face--${face}`);
|
|
174
|
+
if (!targetFace) return;
|
|
175
|
+
|
|
176
|
+
// The incoming face must accept focus before the outgoing face becomes hidden.
|
|
177
|
+
targetFace.inert = false;
|
|
178
|
+
const action = targetFace.querySelector<HTMLElement>('.flip-card-deck__primary-action');
|
|
179
|
+
action?.focus({ preventScroll: true });
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function revealCard(key: string, source: Element | null = document.activeElement) {
|
|
183
|
+
focusFaceAction(source, 'back');
|
|
184
|
+
setRevealed(key, true);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function hideCard(key: string, source: Element | null = document.activeElement) {
|
|
188
|
+
focusFaceAction(source, 'front');
|
|
189
|
+
setRevealed(key, false);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function hideTopCard() {
|
|
193
|
+
const key = currentTopKey();
|
|
194
|
+
if (!key) return;
|
|
195
|
+
hideCard(key);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function resetDeck() {
|
|
199
|
+
activeIndex = 0;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function showPreviousCard() {
|
|
203
|
+
if (!canNavigatePrevious()) return;
|
|
204
|
+
hideTopCard();
|
|
205
|
+
activeIndex = resolveIndex(currentResolvedIndex() - 1, items.length, mode);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function showNextCard() {
|
|
209
|
+
if (!canNavigateNext()) return;
|
|
210
|
+
hideTopCard();
|
|
211
|
+
activeIndex = resolveIndex(currentResolvedIndex() + 1, items.length, mode);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function showCardAt(index: number) {
|
|
215
|
+
if (items.length === 0) return;
|
|
216
|
+
hideTopCard();
|
|
217
|
+
activeIndex = resolveIndex(index, items.length, mode);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function contextFor(key: string, index: number, peek: boolean): FlipCardDeckContext {
|
|
221
|
+
const revealed = revealedByKey[key] === true;
|
|
222
|
+
return {
|
|
223
|
+
key,
|
|
224
|
+
index,
|
|
225
|
+
count: items.length,
|
|
226
|
+
peek,
|
|
227
|
+
revealed,
|
|
228
|
+
reveal: () => revealCard(key),
|
|
229
|
+
hide: () => hideCard(key),
|
|
230
|
+
toggle: () => setRevealed(key, !revealed),
|
|
231
|
+
next: showNextCard,
|
|
232
|
+
previous: showPreviousCard,
|
|
233
|
+
goTo: showCardAt,
|
|
234
|
+
reset: resetDeck
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function shouldIgnoreInteractiveTarget(target: EventTarget | null) {
|
|
239
|
+
if (!(target instanceof HTMLElement)) return true;
|
|
240
|
+
return Boolean(
|
|
241
|
+
target.closest(
|
|
242
|
+
'button, a, input, textarea, select, [contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"]'
|
|
243
|
+
)
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function clearSwipeListeners() {
|
|
248
|
+
if (!swipeOwnerDocument) return;
|
|
249
|
+
swipeOwnerDocument.removeEventListener('pointermove', handleSwipePointerMove);
|
|
250
|
+
swipeOwnerDocument.removeEventListener('pointerup', handleSwipePointerUp);
|
|
251
|
+
swipeOwnerDocument.removeEventListener('pointercancel', handleSwipePointerUp);
|
|
252
|
+
swipeOwnerDocument = null;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function clearSwipeDrag(releasePointerCapture = true) {
|
|
256
|
+
const drag = swipeDrag;
|
|
257
|
+
clearSwipeListeners();
|
|
258
|
+
if (
|
|
259
|
+
releasePointerCapture &&
|
|
260
|
+
drag &&
|
|
261
|
+
typeof drag.target.hasPointerCapture === 'function' &&
|
|
262
|
+
drag.target.hasPointerCapture(drag.pointerId)
|
|
263
|
+
) {
|
|
264
|
+
drag.target.releasePointerCapture(drag.pointerId);
|
|
265
|
+
}
|
|
266
|
+
swipeDrag = null;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function resetSwipeRelease() {
|
|
270
|
+
if (swipeReleaseTimer !== undefined) clearTimeout(swipeReleaseTimer);
|
|
271
|
+
swipeReleaseTimer = undefined;
|
|
272
|
+
swipeReleaseX = null;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function animateSwipeRelease(fromX: number) {
|
|
276
|
+
resetSwipeRelease();
|
|
277
|
+
swipeReleaseX = fromX;
|
|
278
|
+
requestAnimationFrame(() => {
|
|
279
|
+
swipeReleaseX = 0;
|
|
280
|
+
swipeReleaseTimer = setTimeout(resetSwipeRelease, 220);
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function topCardSwipeOffset() {
|
|
285
|
+
if (swipeDrag?.active) return swipeDrag.deltaX;
|
|
286
|
+
if (swipeReleaseX !== null) return swipeReleaseX;
|
|
287
|
+
return 0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function swipeDragStyle(deltaX: number) {
|
|
291
|
+
const limited = Math.max(-180, Math.min(180, deltaX));
|
|
292
|
+
const rotate = limited / 18;
|
|
293
|
+
return `--flip-card-drag-x:${limited}px;--flip-card-drag-rotate:${rotate}deg`;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function handleTopCardPointerDown(event: PointerEvent) {
|
|
297
|
+
if (
|
|
298
|
+
mode !== 'browse' ||
|
|
299
|
+
cardCount <= 1 ||
|
|
300
|
+
(event.pointerType === 'mouse' && event.button !== 0) ||
|
|
301
|
+
event.isPrimary === false ||
|
|
302
|
+
shouldIgnoreInteractiveTarget(event.target) ||
|
|
303
|
+
(blockSwipeWhenRevealed && currentTopRevealed())
|
|
304
|
+
) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const target = event.currentTarget;
|
|
308
|
+
if (!(target instanceof HTMLElement)) return;
|
|
309
|
+
resetSwipeRelease();
|
|
310
|
+
swipeDrag = {
|
|
311
|
+
pointerId: event.pointerId,
|
|
312
|
+
startX: event.clientX,
|
|
313
|
+
startY: event.clientY,
|
|
314
|
+
deltaX: 0,
|
|
315
|
+
active: false,
|
|
316
|
+
target
|
|
317
|
+
};
|
|
318
|
+
swipeOwnerDocument = target.ownerDocument;
|
|
319
|
+
target.setPointerCapture(event.pointerId);
|
|
320
|
+
swipeOwnerDocument.addEventListener('pointermove', handleSwipePointerMove);
|
|
321
|
+
swipeOwnerDocument.addEventListener('pointerup', handleSwipePointerUp);
|
|
322
|
+
swipeOwnerDocument.addEventListener('pointercancel', handleSwipePointerUp);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function handleSwipePointerMove(event: PointerEvent) {
|
|
326
|
+
const drag = swipeDrag;
|
|
327
|
+
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
328
|
+
const deltaX = event.clientX - drag.startX;
|
|
329
|
+
const deltaY = event.clientY - drag.startY;
|
|
330
|
+
if (!drag.active) {
|
|
331
|
+
const distance = Math.hypot(deltaX, deltaY);
|
|
332
|
+
if (distance < swipeActivationThreshold) return;
|
|
333
|
+
if (Math.abs(deltaX) <= Math.abs(deltaY)) {
|
|
334
|
+
clearSwipeDrag();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
event.preventDefault();
|
|
338
|
+
swipeDrag = { ...drag, active: true, deltaX };
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
event.preventDefault();
|
|
342
|
+
swipeDrag = { ...drag, deltaX };
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function handleSwipePointerUp(event: PointerEvent) {
|
|
346
|
+
const drag = swipeDrag;
|
|
347
|
+
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
348
|
+
const { deltaX, active, target } = drag;
|
|
349
|
+
if (target.hasPointerCapture(event.pointerId)) target.releasePointerCapture(event.pointerId);
|
|
350
|
+
clearSwipeDrag(false);
|
|
351
|
+
if (!active) return;
|
|
352
|
+
if (deltaX <= -swipeCommitThreshold) {
|
|
353
|
+
resetSwipeRelease();
|
|
354
|
+
showNextCard();
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
if (deltaX >= swipeCommitThreshold) {
|
|
358
|
+
resetSwipeRelease();
|
|
359
|
+
showPreviousCard();
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
animateSwipeRelease(deltaX);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function shouldIgnoreKeyboard(event: KeyboardEvent) {
|
|
366
|
+
if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.altKey) return true;
|
|
367
|
+
const target = event.target;
|
|
368
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
369
|
+
return Boolean(
|
|
370
|
+
target.closest(
|
|
371
|
+
'input, textarea, select, [contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"]'
|
|
372
|
+
)
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
377
|
+
if (shouldIgnoreKeyboard(event)) return;
|
|
378
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
379
|
+
const key = currentTopKey();
|
|
380
|
+
if (!key || currentTopRevealed()) return;
|
|
381
|
+
event.preventDefault();
|
|
382
|
+
setRevealed(key, true);
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
if (event.key === 'Escape') {
|
|
386
|
+
const key = currentTopKey();
|
|
387
|
+
if (!key || !currentTopRevealed()) return;
|
|
388
|
+
event.preventDefault();
|
|
389
|
+
setRevealed(key, false);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (event.key === 'ArrowLeft' || event.key === 'h') {
|
|
393
|
+
if (!canNavigatePrevious()) return;
|
|
394
|
+
event.preventDefault();
|
|
395
|
+
showPreviousCard();
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
if (event.key === 'ArrowRight' || event.key === 'l') {
|
|
399
|
+
if (!canNavigateNext()) return;
|
|
400
|
+
event.preventDefault();
|
|
401
|
+
showNextCard();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
</script>
|
|
405
|
+
|
|
406
|
+
<svelte:window onkeydown={handleKeydown} />
|
|
407
|
+
|
|
408
|
+
{#if cardCount === 0}
|
|
409
|
+
<div class="flip-card-deck-empty">{emptyLabel}</div>
|
|
410
|
+
{:else}
|
|
411
|
+
<div class="flip-card-deck" aria-label={ariaLabel} role="region">
|
|
412
|
+
{#if cardCount > 1}
|
|
413
|
+
<div class="flip-card-deck__controls">
|
|
414
|
+
<button
|
|
415
|
+
type="button"
|
|
416
|
+
class="flip-card-deck__nav"
|
|
417
|
+
aria-label="Previous card"
|
|
418
|
+
disabled={!canGoPrevious}
|
|
419
|
+
onclick={showPreviousCard}
|
|
420
|
+
>
|
|
421
|
+
<ChevronLeftIcon aria-hidden="true" />
|
|
422
|
+
</button>
|
|
423
|
+
<p class="flip-card-deck__count">Card {resolvedIndex + 1} of {cardCount}</p>
|
|
424
|
+
{#if indexControlLabel}
|
|
425
|
+
<button
|
|
426
|
+
type="button"
|
|
427
|
+
class="flip-card-deck__index-nav"
|
|
428
|
+
aria-label={indexControlLabel}
|
|
429
|
+
disabled={resolvedIndex === resolveIndex(indexControlTarget, cardCount, mode)}
|
|
430
|
+
onclick={() => showCardAt(indexControlTarget)}
|
|
431
|
+
>
|
|
432
|
+
<ListOrderedIcon aria-hidden="true" />
|
|
433
|
+
<span class="flip-card-deck__sr-only">{indexControlLabel}</span>
|
|
434
|
+
</button>
|
|
435
|
+
{/if}
|
|
436
|
+
<button
|
|
437
|
+
type="button"
|
|
438
|
+
class="flip-card-deck__nav"
|
|
439
|
+
aria-label="Next card"
|
|
440
|
+
disabled={!canGoNext}
|
|
441
|
+
onclick={showNextCard}
|
|
442
|
+
>
|
|
443
|
+
<ChevronRightIcon aria-hidden="true" />
|
|
444
|
+
</button>
|
|
445
|
+
</div>
|
|
446
|
+
{/if}
|
|
447
|
+
|
|
448
|
+
<div class="flip-card-deck__stack">
|
|
449
|
+
{#each stackItems as { item, key, index, depth } (`${key}:${depth}`)}
|
|
450
|
+
{@const peek = depth !== 0}
|
|
451
|
+
{@const context = contextFor(key, index, peek)}
|
|
452
|
+
{@const swipeOffset = depth === 0 ? topCardSwipeOffset() : 0}
|
|
453
|
+
<div
|
|
454
|
+
class="flip-card-deck__slot"
|
|
455
|
+
class:flip-card-deck__slot--swiping={depth === 0 && swipeDrag?.active}
|
|
456
|
+
class:flip-card-deck__slot--swipe-reset={depth === 0 && swipeReleaseX !== null && !swipeDrag?.active}
|
|
457
|
+
style={depth === 0 && (swipeDrag?.active || swipeReleaseX !== null)
|
|
458
|
+
? swipeDragStyle(swipeOffset)
|
|
459
|
+
: undefined}
|
|
460
|
+
data-depth={depth}
|
|
461
|
+
aria-hidden={peek ? 'true' : undefined}
|
|
462
|
+
inert={peek}
|
|
463
|
+
onpointerdown={depth === 0 ? handleTopCardPointerDown : undefined}
|
|
464
|
+
>
|
|
465
|
+
<div
|
|
466
|
+
class="flip-card-deck__flip"
|
|
467
|
+
class:flip-card-deck__flip--revealed={!peek && context.revealed}
|
|
468
|
+
data-peek={peek ? 'true' : undefined}
|
|
469
|
+
>
|
|
470
|
+
{#if peek}
|
|
471
|
+
<article class="flip-card-deck__face flip-card-deck__face--front flip-card-deck__face--peek">
|
|
472
|
+
<div class="flip-card-deck__face-scroll">
|
|
473
|
+
{@render front(item, context)}
|
|
474
|
+
</div>
|
|
475
|
+
</article>
|
|
476
|
+
{:else}
|
|
477
|
+
<div class="flip-card-deck__flip-inner">
|
|
478
|
+
<article class="flip-card-deck__face flip-card-deck__face--front" aria-hidden={context.revealed} inert={context.revealed}>
|
|
479
|
+
<div class="flip-card-deck__face-scroll flip-card-deck__face-scroll--front">
|
|
480
|
+
{@render front(item, context)}
|
|
481
|
+
</div>
|
|
482
|
+
<div class="flip-card-deck__face-actions">
|
|
483
|
+
<button
|
|
484
|
+
type="button"
|
|
485
|
+
class="flip-card-deck__primary-action"
|
|
486
|
+
onclick={(event) => revealCard(context.key, event.currentTarget)}
|
|
487
|
+
>
|
|
488
|
+
<EyeIcon aria-hidden="true" />
|
|
489
|
+
{frontActionLabel}
|
|
490
|
+
</button>
|
|
491
|
+
</div>
|
|
492
|
+
</article>
|
|
493
|
+
<article class="flip-card-deck__face flip-card-deck__face--back" aria-hidden={!context.revealed} inert={!context.revealed}>
|
|
494
|
+
<div class="flip-card-deck__face-scroll">
|
|
495
|
+
{@render back(item, context)}
|
|
496
|
+
</div>
|
|
497
|
+
<div class="flip-card-deck__face-actions">
|
|
498
|
+
{#if backActions}
|
|
499
|
+
{@render backActions(item, context)}
|
|
500
|
+
{:else}
|
|
501
|
+
<button type="button" class="flip-card-deck__primary-action" onclick={context.hide}>
|
|
502
|
+
{backActionLabel}
|
|
503
|
+
</button>
|
|
504
|
+
{/if}
|
|
505
|
+
</div>
|
|
506
|
+
</article>
|
|
507
|
+
</div>
|
|
508
|
+
{/if}
|
|
509
|
+
</div>
|
|
510
|
+
</div>
|
|
511
|
+
{/each}
|
|
512
|
+
</div>
|
|
513
|
+
</div>
|
|
514
|
+
{/if}
|
|
515
|
+
|
|
516
|
+
<style>
|
|
517
|
+
.flip-card-deck {
|
|
518
|
+
--flip-card-accent: #2563eb;
|
|
519
|
+
--flip-card-accent-alt: #06b6d4;
|
|
520
|
+
--flip-card-border: var(--border, color-mix(in srgb, #111 16%, transparent));
|
|
521
|
+
--flip-card-muted: var(--muted-foreground, #64748b);
|
|
522
|
+
--flip-card-surface: var(--card, #fff);
|
|
523
|
+
--flip-card-foreground: var(--foreground, #111827);
|
|
524
|
+
--flip-card-height: clamp(22rem, 48svh, 36rem);
|
|
525
|
+
display: grid;
|
|
526
|
+
gap: 0.85rem;
|
|
527
|
+
outline: 0;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.flip-card-deck__controls {
|
|
531
|
+
display: flex;
|
|
532
|
+
align-items: center;
|
|
533
|
+
justify-content: center;
|
|
534
|
+
gap: 0.8rem;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
.flip-card-deck__count {
|
|
538
|
+
min-width: 7rem;
|
|
539
|
+
margin: 0;
|
|
540
|
+
color: var(--flip-card-muted);
|
|
541
|
+
font-size: 0.82rem;
|
|
542
|
+
font-weight: 750;
|
|
543
|
+
text-align: center;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
.flip-card-deck__nav,
|
|
547
|
+
.flip-card-deck__index-nav,
|
|
548
|
+
.flip-card-deck :global(.flip-card-deck__primary-action) {
|
|
549
|
+
display: inline-flex;
|
|
550
|
+
align-items: center;
|
|
551
|
+
justify-content: center;
|
|
552
|
+
gap: 0.4rem;
|
|
553
|
+
border: 1px solid var(--flip-card-border);
|
|
554
|
+
background: color-mix(in srgb, var(--flip-card-surface) 92%, transparent);
|
|
555
|
+
color: var(--flip-card-foreground);
|
|
556
|
+
cursor: pointer;
|
|
557
|
+
font: inherit;
|
|
558
|
+
font-size: 0.82rem;
|
|
559
|
+
font-weight: 800;
|
|
560
|
+
transition:
|
|
561
|
+
background 140ms ease,
|
|
562
|
+
border-color 140ms ease,
|
|
563
|
+
transform 140ms ease;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
.flip-card-deck__nav {
|
|
567
|
+
width: 2.35rem;
|
|
568
|
+
height: 2.35rem;
|
|
569
|
+
border-radius: 999px;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
.flip-card-deck__index-nav {
|
|
573
|
+
box-sizing: border-box;
|
|
574
|
+
width: 1.65rem;
|
|
575
|
+
min-width: 1.65rem;
|
|
576
|
+
height: 1.65rem;
|
|
577
|
+
min-height: 1.65rem;
|
|
578
|
+
border-color: transparent;
|
|
579
|
+
border-radius: 0.45rem;
|
|
580
|
+
background: transparent;
|
|
581
|
+
color: var(--flip-card-muted);
|
|
582
|
+
padding: 0.34rem;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
.flip-card-deck :global(.flip-card-deck__primary-action) {
|
|
586
|
+
min-height: 2.5rem;
|
|
587
|
+
border-radius: 0.7rem;
|
|
588
|
+
padding: 0.55rem 0.85rem;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
.flip-card-deck__nav:hover:not(:disabled),
|
|
592
|
+
.flip-card-deck__nav:focus-visible:not(:disabled),
|
|
593
|
+
.flip-card-deck :global(.flip-card-deck__primary-action:hover:not(:disabled)),
|
|
594
|
+
.flip-card-deck :global(.flip-card-deck__primary-action:focus-visible:not(:disabled)) {
|
|
595
|
+
border-color: color-mix(in srgb, var(--flip-card-accent) 42%, var(--flip-card-border));
|
|
596
|
+
background: color-mix(in srgb, var(--flip-card-accent) 9%, var(--flip-card-surface));
|
|
597
|
+
transform: translateY(-1px);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.flip-card-deck__index-nav:hover:not(:disabled),
|
|
601
|
+
.flip-card-deck__index-nav:focus-visible:not(:disabled) {
|
|
602
|
+
border-color: transparent;
|
|
603
|
+
background: color-mix(in srgb, var(--flip-card-accent) 11%, transparent);
|
|
604
|
+
color: color-mix(in srgb, var(--flip-card-accent) 76%, var(--flip-card-foreground));
|
|
605
|
+
transform: translateY(-1px);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
.flip-card-deck__nav:disabled,
|
|
609
|
+
.flip-card-deck__index-nav:disabled,
|
|
610
|
+
.flip-card-deck :global(.flip-card-deck__primary-action:disabled) {
|
|
611
|
+
cursor: default;
|
|
612
|
+
opacity: 0.45;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.flip-card-deck__nav :global(svg),
|
|
616
|
+
.flip-card-deck :global(.flip-card-deck__primary-action svg) {
|
|
617
|
+
width: 1rem;
|
|
618
|
+
height: 1rem;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.flip-card-deck__index-nav :global(svg) {
|
|
622
|
+
width: 0.8rem;
|
|
623
|
+
height: 0.8rem;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.flip-card-deck__sr-only {
|
|
627
|
+
position: absolute;
|
|
628
|
+
width: 1px;
|
|
629
|
+
height: 1px;
|
|
630
|
+
overflow: hidden;
|
|
631
|
+
clip: rect(0, 0, 0, 0);
|
|
632
|
+
white-space: nowrap;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
.flip-card-deck__stack {
|
|
636
|
+
position: relative;
|
|
637
|
+
width: min(100%, 44rem);
|
|
638
|
+
min-height: var(--flip-card-height);
|
|
639
|
+
margin: 0 auto;
|
|
640
|
+
overflow: visible;
|
|
641
|
+
perspective: 1100px;
|
|
642
|
+
touch-action: pan-y pinch-zoom;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
.flip-card-deck__slot {
|
|
646
|
+
position: absolute;
|
|
647
|
+
inset: 0;
|
|
648
|
+
transform-origin: 50% 100%;
|
|
649
|
+
transition:
|
|
650
|
+
transform 320ms cubic-bezier(0.34, 1.25, 0.64, 1),
|
|
651
|
+
opacity 220ms ease;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
.flip-card-deck__slot[data-depth='0'] {
|
|
655
|
+
z-index: 3;
|
|
656
|
+
cursor: grab;
|
|
657
|
+
transform: rotate(0deg) scale(1);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.flip-card-deck__slot[data-depth='0'].flip-card-deck__slot--swiping {
|
|
661
|
+
cursor: grabbing;
|
|
662
|
+
transition: none;
|
|
663
|
+
transform: translate(var(--flip-card-drag-x, 0), 0) rotate(var(--flip-card-drag-rotate, 0deg));
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
.flip-card-deck__slot[data-depth='0'].flip-card-deck__slot--swipe-reset {
|
|
667
|
+
transform: translate(var(--flip-card-drag-x, 0), 0) rotate(var(--flip-card-drag-rotate, 0deg));
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
.flip-card-deck__slot[data-depth='1'] {
|
|
671
|
+
z-index: 2;
|
|
672
|
+
opacity: 0.94;
|
|
673
|
+
pointer-events: none;
|
|
674
|
+
transform: rotate(3.5deg) scale(0.955);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
.flip-card-deck__slot[data-depth='2'] {
|
|
678
|
+
z-index: 1;
|
|
679
|
+
opacity: 0.88;
|
|
680
|
+
pointer-events: none;
|
|
681
|
+
transform: rotate(7deg) scale(0.91);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
.flip-card-deck__flip,
|
|
685
|
+
.flip-card-deck__flip-inner,
|
|
686
|
+
.flip-card-deck__face {
|
|
687
|
+
width: 100%;
|
|
688
|
+
height: 100%;
|
|
689
|
+
min-height: var(--flip-card-height);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
.flip-card-deck__flip {
|
|
693
|
+
position: relative;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
.flip-card-deck__flip-inner {
|
|
697
|
+
position: relative;
|
|
698
|
+
transform-style: preserve-3d;
|
|
699
|
+
transition: transform 460ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
.flip-card-deck__flip--revealed .flip-card-deck__flip-inner {
|
|
703
|
+
transform: rotateY(180deg);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.flip-card-deck__face {
|
|
707
|
+
position: absolute;
|
|
708
|
+
inset: 0;
|
|
709
|
+
display: flex;
|
|
710
|
+
flex-direction: column;
|
|
711
|
+
gap: 0.85rem;
|
|
712
|
+
overflow: hidden;
|
|
713
|
+
border: 1px solid color-mix(in srgb, var(--flip-card-accent) 30%, var(--flip-card-border));
|
|
714
|
+
border-radius: 1rem;
|
|
715
|
+
backface-visibility: hidden;
|
|
716
|
+
background:
|
|
717
|
+
linear-gradient(145deg, color-mix(in srgb, var(--flip-card-accent) 13%, transparent), transparent 15rem),
|
|
718
|
+
linear-gradient(320deg, color-mix(in srgb, var(--flip-card-accent-alt) 10%, transparent), transparent 16rem),
|
|
719
|
+
color-mix(in srgb, var(--flip-card-surface) 96%, transparent);
|
|
720
|
+
box-shadow: 0 24px 65px color-mix(in srgb, #000 13%, transparent);
|
|
721
|
+
color: var(--flip-card-foreground);
|
|
722
|
+
padding: clamp(1rem, 4vw, 1.7rem);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
.flip-card-deck__face--back {
|
|
726
|
+
transform: rotateY(180deg);
|
|
727
|
+
border-color: color-mix(in srgb, var(--flip-card-accent-alt) 32%, var(--flip-card-border));
|
|
728
|
+
background:
|
|
729
|
+
linear-gradient(135deg, color-mix(in srgb, var(--flip-card-accent-alt) 13%, transparent), transparent 14rem),
|
|
730
|
+
linear-gradient(315deg, color-mix(in srgb, var(--flip-card-accent) 10%, transparent), transparent 16rem),
|
|
731
|
+
color-mix(in srgb, var(--flip-card-surface) 96%, transparent);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
.flip-card-deck__face--peek {
|
|
735
|
+
position: absolute;
|
|
736
|
+
inset: 0;
|
|
737
|
+
pointer-events: none;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
.flip-card-deck__face[aria-hidden='true'] {
|
|
741
|
+
pointer-events: none;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
.flip-card-deck__face-scroll {
|
|
745
|
+
flex: 1 1 auto;
|
|
746
|
+
min-height: 0;
|
|
747
|
+
overflow-x: hidden;
|
|
748
|
+
overflow-y: auto;
|
|
749
|
+
overscroll-behavior: contain;
|
|
750
|
+
scrollbar-width: thin;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
.flip-card-deck__face-scroll--front {
|
|
754
|
+
display: flex;
|
|
755
|
+
align-items: stretch;
|
|
756
|
+
justify-content: flex-start;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
.flip-card-deck__face-actions {
|
|
760
|
+
flex-shrink: 0;
|
|
761
|
+
margin-top: auto;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
.flip-card-deck-empty {
|
|
765
|
+
display: grid;
|
|
766
|
+
min-height: 10rem;
|
|
767
|
+
place-items: center;
|
|
768
|
+
border: 1px dashed var(--flip-card-border, color-mix(in srgb, #111 18%, transparent));
|
|
769
|
+
border-radius: 0.85rem;
|
|
770
|
+
color: var(--flip-card-muted, #64748b);
|
|
771
|
+
font-size: 0.86rem;
|
|
772
|
+
font-weight: 700;
|
|
773
|
+
padding: 1rem;
|
|
774
|
+
text-align: center;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
@media (max-width: 720px) {
|
|
778
|
+
.flip-card-deck {
|
|
779
|
+
--flip-card-height: clamp(20rem, 64svh, 34rem);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
.flip-card-deck__stack {
|
|
783
|
+
width: min(100%, 33rem);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.flip-card-deck__face {
|
|
787
|
+
padding: 1rem;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
@media (prefers-reduced-motion: reduce) {
|
|
792
|
+
.flip-card-deck__slot,
|
|
793
|
+
.flip-card-deck__flip-inner,
|
|
794
|
+
.flip-card-deck__index-nav,
|
|
795
|
+
.flip-card-deck__nav,
|
|
796
|
+
.flip-card-deck :global(.flip-card-deck__primary-action) {
|
|
797
|
+
transition: none;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
</style>
|