@eightyfourthousand/lib-editing 2026.3.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/.babelrc +12 -0
- package/.eslintrc.json +18 -0
- package/README.md +7 -0
- package/jest.config.ts +10 -0
- package/package.json +35 -0
- package/postcss.config.mjs +9 -0
- package/project.json +29 -0
- package/src/fixtures/basic/json.ts +396 -0
- package/src/fixtures/toh251/json.ts +4913 -0
- package/src/fixtures/toh251/passages.ts +2814 -0
- package/src/fixtures/types.ts +8 -0
- package/src/index.ts +4 -0
- package/src/lib/block.ts +226 -0
- package/src/lib/components/editor/BlockEditor.tsx +38 -0
- package/src/lib/components/editor/EditorBackMatterPage.tsx +95 -0
- package/src/lib/components/editor/EditorBodyPage.tsx +87 -0
- package/src/lib/components/editor/EditorHeader.tsx +22 -0
- package/src/lib/components/editor/EditorLayout.tsx +62 -0
- package/src/lib/components/editor/EditorLeftPanelPage.tsx +27 -0
- package/src/lib/components/editor/EditorProvider.tsx +399 -0
- package/src/lib/components/editor/PaginationProvider.tsx +472 -0
- package/src/lib/components/editor/TitlesBuilder.tsx +40 -0
- package/src/lib/components/editor/TranslationBuilder.tsx +171 -0
- package/src/lib/components/editor/TranslationEditor.tsx +32 -0
- package/src/lib/components/editor/extensions/Abbreviation/Abbreviation.ts +133 -0
- package/src/lib/components/editor/extensions/Audio/Audio.ts +69 -0
- package/src/lib/components/editor/extensions/Bold.ts +43 -0
- package/src/lib/components/editor/extensions/Document.ts +8 -0
- package/src/lib/components/editor/extensions/DragHandle/DragHandle.ts +429 -0
- package/src/lib/components/editor/extensions/EndNoteLink/EndNoteLink.tsx +39 -0
- package/src/lib/components/editor/extensions/EndNoteLink/EndNoteLinkHoverContent.tsx +139 -0
- package/src/lib/components/editor/extensions/EndNoteLink/EndNoteLinkMark.ts +236 -0
- package/src/lib/components/editor/extensions/EndNoteLink/endnote-utils.ts +412 -0
- package/src/lib/components/editor/extensions/GlobalConfig.ts +52 -0
- package/src/lib/components/editor/extensions/GlossaryInstance/GlossaryInput.tsx +54 -0
- package/src/lib/components/editor/extensions/GlossaryInstance/GlossaryInstance.tsx +129 -0
- package/src/lib/components/editor/extensions/GlossaryInstance/GlossaryInstanceNode.ts +148 -0
- package/src/lib/components/editor/extensions/Heading/Heading.ts +71 -0
- package/src/lib/components/editor/extensions/HoverInputField.tsx +54 -0
- package/src/lib/components/editor/extensions/Image.ts +18 -0
- package/src/lib/components/editor/extensions/Indent.ts +103 -0
- package/src/lib/components/editor/extensions/InternalLink/InternalLink.ts +173 -0
- package/src/lib/components/editor/extensions/InternalLink/InternalLinkHoverContent.tsx +137 -0
- package/src/lib/components/editor/extensions/InternalLink/InternalLinkInput.tsx +71 -0
- package/src/lib/components/editor/extensions/InternalLink/index.ts +1 -0
- package/src/lib/components/editor/extensions/Italic.ts +50 -0
- package/src/lib/components/editor/extensions/LeadingSpace.ts +106 -0
- package/src/lib/components/editor/extensions/Line/LineNode.ts +41 -0
- package/src/lib/components/editor/extensions/LineGroup/LineGroupNode.ts +124 -0
- package/src/lib/components/editor/extensions/Link/Link.ts +65 -0
- package/src/lib/components/editor/extensions/Link/LinkHoverContent.tsx +124 -0
- package/src/lib/components/editor/extensions/Link/index.ts +1 -0
- package/src/lib/components/editor/extensions/List.ts +74 -0
- package/src/lib/components/editor/extensions/Mantra/Mantra.ts +88 -0
- package/src/lib/components/editor/extensions/Mention/Mention.ts +184 -0
- package/src/lib/components/editor/extensions/Mention/MentionHoverContent.tsx +158 -0
- package/src/lib/components/editor/extensions/NodeWrapper.tsx +57 -0
- package/src/lib/components/editor/extensions/Paragraph/Paragraph.ts +25 -0
- package/src/lib/components/editor/extensions/ParagraphIndent.ts +87 -0
- package/src/lib/components/editor/extensions/Passage/EditLabel.tsx +57 -0
- package/src/lib/components/editor/extensions/Passage/EditorOptions.tsx +29 -0
- package/src/lib/components/editor/extensions/Passage/Passage.tsx +238 -0
- package/src/lib/components/editor/extensions/Passage/PassageNode.ts +223 -0
- package/src/lib/components/editor/extensions/Passage/ReaderOptions.tsx +55 -0
- package/src/lib/components/editor/extensions/Passage/ShowAnnotations.tsx +92 -0
- package/src/lib/components/editor/extensions/Passage/index.ts +1 -0
- package/src/lib/components/editor/extensions/Passage/label.spec.ts +118 -0
- package/src/lib/components/editor/extensions/Passage/label.ts +39 -0
- package/src/lib/components/editor/extensions/Placeholder.ts +9 -0
- package/src/lib/components/editor/extensions/SlashCommand/SlashCommand.ts +65 -0
- package/src/lib/components/editor/extensions/SlashCommand/SuggestionList.tsx +109 -0
- package/src/lib/components/editor/extensions/SlashCommand/Suggestions.ts +185 -0
- package/src/lib/components/editor/extensions/SmallCaps.ts +110 -0
- package/src/lib/components/editor/extensions/StarterKit.ts +36 -0
- package/src/lib/components/editor/extensions/Subscript.ts +43 -0
- package/src/lib/components/editor/extensions/Superscript.ts +43 -0
- package/src/lib/components/editor/extensions/Table.ts +32 -0
- package/src/lib/components/editor/extensions/TextAlign.ts +5 -0
- package/src/lib/components/editor/extensions/TitleMetadata.ts +40 -0
- package/src/lib/components/editor/extensions/TitleNode.ts +133 -0
- package/src/lib/components/editor/extensions/TitlesNode.ts +102 -0
- package/src/lib/components/editor/extensions/Trailer.ts +57 -0
- package/src/lib/components/editor/extensions/TranslationDocument.ts +7 -0
- package/src/lib/components/editor/extensions/TranslationMetadata.ts +58 -0
- package/src/lib/components/editor/extensions/Underline.ts +43 -0
- package/src/lib/components/editor/hooks/index.ts +4 -0
- package/src/lib/components/editor/hooks/useBlockEditor.ts +53 -0
- package/src/lib/components/editor/hooks/useDefaultExtensions.ts +39 -0
- package/src/lib/components/editor/hooks/useDirtyStore.ts +33 -0
- package/src/lib/components/editor/hooks/useTranslationExtensions.ts +148 -0
- package/src/lib/components/editor/index.ts +10 -0
- package/src/lib/components/editor/menus/EmptyBubbleMenu.tsx +42 -0
- package/src/lib/components/editor/menus/MainBubbleMenu.tsx +51 -0
- package/src/lib/components/editor/menus/TranslationBubbleMenu.tsx +57 -0
- package/src/lib/components/editor/menus/index.ts +3 -0
- package/src/lib/components/editor/menus/selectors/EndNoteSelector.tsx +388 -0
- package/src/lib/components/editor/menus/selectors/GlossarySelector.tsx +63 -0
- package/src/lib/components/editor/menus/selectors/LinkSelector.tsx +68 -0
- package/src/lib/components/editor/menus/selectors/MantraSelector.tsx +119 -0
- package/src/lib/components/editor/menus/selectors/NodeSelector.tsx +144 -0
- package/src/lib/components/editor/menus/selectors/ParagraphButtons.tsx +68 -0
- package/src/lib/components/editor/menus/selectors/SelectorInputField.tsx +68 -0
- package/src/lib/components/editor/menus/selectors/TextAlignSelector.tsx +89 -0
- package/src/lib/components/editor/menus/selectors/TextButtons.tsx +89 -0
- package/src/lib/components/editor/menus/selectors/TranslationNodeSelector.tsx +143 -0
- package/src/lib/components/editor/menus/selectors/TranslationTextButtons.tsx +125 -0
- package/src/lib/components/editor/menus/selectors/index.ts +5 -0
- package/src/lib/components/editor/save-filter.spec.ts +94 -0
- package/src/lib/components/editor/save-filter.ts +27 -0
- package/src/lib/components/editor/util.ts +304 -0
- package/src/lib/components/index.ts +3 -0
- package/src/lib/components/reader/ReaderBackMatterPage.tsx +62 -0
- package/src/lib/components/reader/ReaderBackMatterPanel.tsx +53 -0
- package/src/lib/components/reader/ReaderBodyPage.tsx +46 -0
- package/src/lib/components/reader/ReaderBodyPanel.tsx +68 -0
- package/src/lib/components/reader/ReaderLayout.tsx +39 -0
- package/src/lib/components/reader/ReaderLeftPanel.tsx +8 -0
- package/src/lib/components/reader/ReaderLeftPanelPage.tsx +31 -0
- package/src/lib/components/reader/TranslationReader.tsx +28 -0
- package/src/lib/components/reader/index.ts +2 -0
- package/src/lib/components/reader/ssr.ts +3 -0
- package/src/lib/components/shared/AiSummarizerPage.tsx +12 -0
- package/src/lib/components/shared/BackMatterPanel.tsx +143 -0
- package/src/lib/components/shared/BodyPanel.tsx +214 -0
- package/src/lib/components/shared/HoverCardProvider.tsx +407 -0
- package/src/lib/components/shared/Imprint.tsx +24 -0
- package/src/lib/components/shared/LabeledElement.tsx +133 -0
- package/src/lib/components/shared/LeftPanel.tsx +65 -0
- package/src/lib/components/shared/NavigationContext.ts +64 -0
- package/src/lib/components/shared/NavigationProvider.tsx +368 -0
- package/src/lib/components/shared/OpenGraphImage.tsx +75 -0
- package/src/lib/components/shared/PassageSkeleton.tsx +10 -0
- package/src/lib/components/shared/RestrictionWarning.tsx +177 -0
- package/src/lib/components/shared/SourceReader.tsx +83 -0
- package/src/lib/components/shared/SuggestRevisionForm.tsx +99 -0
- package/src/lib/components/shared/TableOfContents.tsx +280 -0
- package/src/lib/components/shared/ThreeColumnRenderer.tsx +54 -0
- package/src/lib/components/shared/TranslationHeader.tsx +86 -0
- package/src/lib/components/shared/TranslationHoverCard.tsx +84 -0
- package/src/lib/components/shared/TranslationSkeleton.tsx +16 -0
- package/src/lib/components/shared/TranslationTable.tsx +155 -0
- package/src/lib/components/shared/bibliography/BibliographyBody.tsx +28 -0
- package/src/lib/components/shared/bibliography/BibliographyList.tsx +63 -0
- package/src/lib/components/shared/bibliography/index.ts +1 -0
- package/src/lib/components/shared/generate-metadata.ts +44 -0
- package/src/lib/components/shared/glossary/GlossaryInstanceBody.tsx +144 -0
- package/src/lib/components/shared/glossary/GlossaryPaginationProvider.tsx +317 -0
- package/src/lib/components/shared/glossary/GlossarySkeleton.tsx +19 -0
- package/src/lib/components/shared/glossary/GlossaryTermList.tsx +58 -0
- package/src/lib/components/shared/glossary/index.ts +3 -0
- package/src/lib/components/shared/hooks/useGlossaryInstanceListener.tsx +42 -0
- package/src/lib/components/shared/hooks/useScrollInTab.tsx +43 -0
- package/src/lib/components/shared/hooks/useScrollPositionRestore.ts +274 -0
- package/src/lib/components/shared/hooks/useTohToggle.tsx +52 -0
- package/src/lib/components/shared/index.ts +11 -0
- package/src/lib/components/shared/ssr.ts +2 -0
- package/src/lib/components/shared/titles/FramedCard.tsx +132 -0
- package/src/lib/components/shared/titles/LongTitle.tsx +20 -0
- package/src/lib/components/shared/titles/LongTitles.tsx +28 -0
- package/src/lib/components/shared/titles/Title.tsx +54 -0
- package/src/lib/components/shared/titles/TitleDetails.tsx +47 -0
- package/src/lib/components/shared/titles/TitleForm.tsx +37 -0
- package/src/lib/components/shared/titles/Titles.tsx +114 -0
- package/src/lib/components/shared/titles/TitlesCard.tsx +113 -0
- package/src/lib/components/shared/titles/index.ts +8 -0
- package/src/lib/components/shared/types.ts +79 -0
- package/src/lib/components/ssr.ts +2 -0
- package/src/lib/exporters/abbreviation.spec.ts +31 -0
- package/src/lib/exporters/abbreviation.ts +22 -0
- package/src/lib/exporters/annotation.ts +193 -0
- package/src/lib/exporters/audio.spec.ts +77 -0
- package/src/lib/exporters/audio.ts +27 -0
- package/src/lib/exporters/blockquote.spec.ts +48 -0
- package/src/lib/exporters/blockquote.ts +24 -0
- package/src/lib/exporters/code.spec.ts +93 -0
- package/src/lib/exporters/code.ts +26 -0
- package/src/lib/exporters/end-note-link.spec.ts +104 -0
- package/src/lib/exporters/end-note-link.ts +35 -0
- package/src/lib/exporters/export.ts +12 -0
- package/src/lib/exporters/glossary-instance.spec.ts +85 -0
- package/src/lib/exporters/glossary-instance.ts +31 -0
- package/src/lib/exporters/has-abbreviation.spec.ts +31 -0
- package/src/lib/exporters/has-abbreviation.ts +21 -0
- package/src/lib/exporters/heading.spec.ts +80 -0
- package/src/lib/exporters/heading.ts +28 -0
- package/src/lib/exporters/image.spec.ts +48 -0
- package/src/lib/exporters/image.ts +25 -0
- package/src/lib/exporters/indent.spec.ts +58 -0
- package/src/lib/exporters/indent.ts +18 -0
- package/src/lib/exporters/index.ts +1 -0
- package/src/lib/exporters/internal-link.spec.ts +90 -0
- package/src/lib/exporters/internal-link.ts +35 -0
- package/src/lib/exporters/italic.spec.ts +84 -0
- package/src/lib/exporters/italic.ts +55 -0
- package/src/lib/exporters/leading-space.spec.ts +28 -0
- package/src/lib/exporters/leading-space.ts +16 -0
- package/src/lib/exporters/line-group.spec.ts +48 -0
- package/src/lib/exporters/line-group.ts +24 -0
- package/src/lib/exporters/line.spec.ts +48 -0
- package/src/lib/exporters/line.ts +24 -0
- package/src/lib/exporters/link.spec.ts +123 -0
- package/src/lib/exporters/link.ts +67 -0
- package/src/lib/exporters/list-item.spec.ts +48 -0
- package/src/lib/exporters/list-item.ts +24 -0
- package/src/lib/exporters/list.spec.ts +82 -0
- package/src/lib/exporters/list.ts +31 -0
- package/src/lib/exporters/mantra.spec.ts +51 -0
- package/src/lib/exporters/mantra.ts +25 -0
- package/src/lib/exporters/mention.ts +41 -0
- package/src/lib/exporters/paragraph.spec.ts +173 -0
- package/src/lib/exporters/paragraph.ts +32 -0
- package/src/lib/exporters/quote.spec.ts +56 -0
- package/src/lib/exporters/quote.ts +25 -0
- package/src/lib/exporters/span.spec.ts +118 -0
- package/src/lib/exporters/span.ts +44 -0
- package/src/lib/exporters/table-body-data.spec.ts +48 -0
- package/src/lib/exporters/table-body-data.ts +24 -0
- package/src/lib/exporters/table-body-header.spec.ts +48 -0
- package/src/lib/exporters/table-body-header.ts +24 -0
- package/src/lib/exporters/table-body-row.spec.ts +48 -0
- package/src/lib/exporters/table-body-row.ts +24 -0
- package/src/lib/exporters/table.spec.ts +48 -0
- package/src/lib/exporters/table.ts +24 -0
- package/src/lib/exporters/trailer.spec.ts +48 -0
- package/src/lib/exporters/trailer.ts +24 -0
- package/src/lib/exporters/util.ts +62 -0
- package/src/lib/passage.ts +182 -0
- package/src/lib/titles.ts +80 -0
- package/src/lib/transformers/abbreviation.spec.ts +87 -0
- package/src/lib/transformers/abbreviation.ts +30 -0
- package/src/lib/transformers/annotate.ts +146 -0
- package/src/lib/transformers/audio.spec.ts +55 -0
- package/src/lib/transformers/audio.ts +29 -0
- package/src/lib/transformers/blockquote.spec.ts +48 -0
- package/src/lib/transformers/blockquote.ts +41 -0
- package/src/lib/transformers/code.spec.ts +52 -0
- package/src/lib/transformers/code.ts +22 -0
- package/src/lib/transformers/deprecated.ts +7 -0
- package/src/lib/transformers/end-note-link.spec.ts +56 -0
- package/src/lib/transformers/end-note-link.ts +76 -0
- package/src/lib/transformers/glossary-instance.spec.ts +55 -0
- package/src/lib/transformers/glossary-instance.ts +40 -0
- package/src/lib/transformers/has-abbreviation.spec.ts +50 -0
- package/src/lib/transformers/has-abbreviation.ts +30 -0
- package/src/lib/transformers/heading.spec.ts +62 -0
- package/src/lib/transformers/heading.ts +30 -0
- package/src/lib/transformers/image.spec.ts +51 -0
- package/src/lib/transformers/image.ts +28 -0
- package/src/lib/transformers/indent.spec.ts +53 -0
- package/src/lib/transformers/indent.ts +17 -0
- package/src/lib/transformers/index.ts +33 -0
- package/src/lib/transformers/inline-title.spec.ts +59 -0
- package/src/lib/transformers/inline-title.ts +34 -0
- package/src/lib/transformers/internal-link.spec.ts +67 -0
- package/src/lib/transformers/internal-link.ts +65 -0
- package/src/lib/transformers/italic.ts +22 -0
- package/src/lib/transformers/leading-space.spec.ts +55 -0
- package/src/lib/transformers/leading-space.ts +17 -0
- package/src/lib/transformers/line-group.spec.ts +48 -0
- package/src/lib/transformers/line-group.ts +37 -0
- package/src/lib/transformers/line.spec.ts +54 -0
- package/src/lib/transformers/line.ts +27 -0
- package/src/lib/transformers/link.spec.ts +61 -0
- package/src/lib/transformers/link.ts +27 -0
- package/src/lib/transformers/list-item.spec.ts +48 -0
- package/src/lib/transformers/list-item.ts +37 -0
- package/src/lib/transformers/list.spec.ts +58 -0
- package/src/lib/transformers/list.ts +42 -0
- package/src/lib/transformers/mantra.spec.ts +58 -0
- package/src/lib/transformers/mantra.ts +28 -0
- package/src/lib/transformers/mention.ts +70 -0
- package/src/lib/transformers/paragraph.spec.ts +46 -0
- package/src/lib/transformers/paragraph.ts +26 -0
- package/src/lib/transformers/quote.spec.ts +42 -0
- package/src/lib/transformers/quote.ts +3 -0
- package/src/lib/transformers/quoted.ts +3 -0
- package/src/lib/transformers/recurse.ts +76 -0
- package/src/lib/transformers/reference.ts +3 -0
- package/src/lib/transformers/span.spec.ts +68 -0
- package/src/lib/transformers/span.ts +78 -0
- package/src/lib/transformers/split-at.ts +58 -0
- package/src/lib/transformers/split-block.ts +110 -0
- package/src/lib/transformers/split-content.ts +67 -0
- package/src/lib/transformers/split-insert.ts +76 -0
- package/src/lib/transformers/split-marks.ts +42 -0
- package/src/lib/transformers/split-node.ts +138 -0
- package/src/lib/transformers/table-body-data.spec.ts +44 -0
- package/src/lib/transformers/table-body-data.ts +29 -0
- package/src/lib/transformers/table-body-header.spec.ts +44 -0
- package/src/lib/transformers/table-body-header.ts +29 -0
- package/src/lib/transformers/table-body-row.spec.ts +44 -0
- package/src/lib/transformers/table-body-row.ts +29 -0
- package/src/lib/transformers/table.spec.ts +47 -0
- package/src/lib/transformers/table.ts +29 -0
- package/src/lib/transformers/trailer.spec.ts +43 -0
- package/src/lib/transformers/trailer.ts +26 -0
- package/src/lib/transformers/transformer.ts +25 -0
- package/src/lib/transformers/unknown.ts +8 -0
- package/src/lib/transformers/util.ts +20 -0
- package/src/lib/types.ts +10 -0
- package/src/ssr.ts +1 -0
- package/tsconfig.json +20 -0
- package/tsconfig.lib.json +29 -0
- package/tsconfig.spec.json +22 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Button } from '@eightyfourthousand/design-system';
|
|
4
|
+
import { parseToh } from '@eightyfourthousand/lib-utils';
|
|
5
|
+
import { FormEvent, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
export const SuggestRevisionForm = ({
|
|
8
|
+
toh,
|
|
9
|
+
type,
|
|
10
|
+
label,
|
|
11
|
+
onClose,
|
|
12
|
+
}: {
|
|
13
|
+
toh: string;
|
|
14
|
+
type: string;
|
|
15
|
+
label: string;
|
|
16
|
+
onClose: () => void;
|
|
17
|
+
}) => {
|
|
18
|
+
const [body, setBody] = useState('');
|
|
19
|
+
const [status, setStatus] = useState<
|
|
20
|
+
'idle' | 'loading' | 'success' | 'error'
|
|
21
|
+
>('idle');
|
|
22
|
+
const [errorMessage, setErrorMessage] = useState('');
|
|
23
|
+
|
|
24
|
+
const handleSubmit = async (e: FormEvent) => {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
|
|
27
|
+
if (!body.trim()) {
|
|
28
|
+
setStatus('error');
|
|
29
|
+
setErrorMessage('Please enter a message.');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
setStatus('loading');
|
|
34
|
+
setErrorMessage('');
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const res = await fetch('/api/feedback', {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
headers: { 'Content-Type': 'application/json' },
|
|
40
|
+
body: JSON.stringify({ toh, type, label, body: body.trim() }),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
const data = await res.json().catch(() => ({}));
|
|
45
|
+
throw new Error(data.error || 'Failed to send feedback');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setStatus('success');
|
|
49
|
+
setTimeout(() => onClose(), 1500);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
setStatus('error');
|
|
52
|
+
setErrorMessage(
|
|
53
|
+
err instanceof Error ? err.message : 'Failed to send feedback',
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className="p-1">
|
|
60
|
+
<p className="text-sm font-semibold">Suggest a Revision</p>
|
|
61
|
+
<p className="text-secondary text-xs capitalize py-2">
|
|
62
|
+
{parseToh(toh)} · {type} {label}
|
|
63
|
+
</p>
|
|
64
|
+
<form onSubmit={handleSubmit}>
|
|
65
|
+
<textarea
|
|
66
|
+
className="border-input bg-background placeholder:text-muted-foreground w-full rounded-md border px-3 py-2 text-sm shadow-xs focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring min-h-24 resize-y"
|
|
67
|
+
placeholder="Describe the revision you'd like to suggest..."
|
|
68
|
+
value={body}
|
|
69
|
+
onChange={(e) => {
|
|
70
|
+
setBody(e.target.value);
|
|
71
|
+
if (status === 'error') setStatus('idle');
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
{status === 'error' && (
|
|
75
|
+
<p className="text-destructive text-sm mt-1">{errorMessage}</p>
|
|
76
|
+
)}
|
|
77
|
+
{status === 'success' && (
|
|
78
|
+
<p className="text-green-600 text-sm mt-1">
|
|
79
|
+
Feedback sent. Thank you!
|
|
80
|
+
</p>
|
|
81
|
+
)}
|
|
82
|
+
<div className="flex justify-end gap-2 mt-2">
|
|
83
|
+
<Button variant="outline" size="sm" type="button" onClick={onClose}>
|
|
84
|
+
Cancel
|
|
85
|
+
</Button>
|
|
86
|
+
<Button
|
|
87
|
+
variant="default"
|
|
88
|
+
size="sm"
|
|
89
|
+
type="submit"
|
|
90
|
+
className="px-3"
|
|
91
|
+
disabled={status === 'loading' || status === 'success'}
|
|
92
|
+
>
|
|
93
|
+
{status === 'loading' ? 'Sending...' : 'Submit'}
|
|
94
|
+
</Button>
|
|
95
|
+
</div>
|
|
96
|
+
</form>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Toc, TocEntry, TohokuCatalogEntry, Work } from '@eightyfourthousand/data-access';
|
|
4
|
+
import {
|
|
5
|
+
Accordion,
|
|
6
|
+
AccordionContent,
|
|
7
|
+
AccordionItem,
|
|
8
|
+
AccordionTrigger,
|
|
9
|
+
Select,
|
|
10
|
+
SelectContent,
|
|
11
|
+
SelectItem,
|
|
12
|
+
SelectTrigger,
|
|
13
|
+
SelectValue,
|
|
14
|
+
Separator,
|
|
15
|
+
} from '@eightyfourthousand/design-system';
|
|
16
|
+
import { cn, parseToh } from '@eightyfourthousand/lib-utils';
|
|
17
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
18
|
+
import { useNavigation } from './NavigationProvider';
|
|
19
|
+
import {
|
|
20
|
+
PanelName,
|
|
21
|
+
TAB_FOR_SECTION,
|
|
22
|
+
PANEL_FOR_SECTION,
|
|
23
|
+
} from './types';
|
|
24
|
+
import { BookOpenIcon, HashIcon, LibraryBigIcon } from 'lucide-react';
|
|
25
|
+
|
|
26
|
+
export const TableOfContentsSection = ({
|
|
27
|
+
node,
|
|
28
|
+
className,
|
|
29
|
+
depth = 0,
|
|
30
|
+
panel,
|
|
31
|
+
}: {
|
|
32
|
+
node: TocEntry;
|
|
33
|
+
className?: string;
|
|
34
|
+
depth?: number;
|
|
35
|
+
panel?: PanelName;
|
|
36
|
+
}) => {
|
|
37
|
+
const { updatePanel } = useNavigation();
|
|
38
|
+
|
|
39
|
+
const baseStyle =
|
|
40
|
+
'w-full py-0.75 font-light leading-5 text-sm hover:text-foreground/40 hover:no-underline hover:cursor-pointer';
|
|
41
|
+
|
|
42
|
+
const onClick = useCallback(
|
|
43
|
+
(entry: TocEntry) => {
|
|
44
|
+
const { section } = entry;
|
|
45
|
+
updatePanel({
|
|
46
|
+
name: PANEL_FOR_SECTION[section] || panel,
|
|
47
|
+
state: {
|
|
48
|
+
open: true,
|
|
49
|
+
tab: TAB_FOR_SECTION[section] || 'translation',
|
|
50
|
+
hash: entry.uuid,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
[updatePanel, panel],
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (!node.children?.length) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Accordion type="multiple" className={cn(depth && 'pl-2.5')}>
|
|
63
|
+
{node.children.map((child) => {
|
|
64
|
+
// 'The Translation' is always bold
|
|
65
|
+
const maybeBold =
|
|
66
|
+
child.content === 'The Translation' ? 'font-bold' : '';
|
|
67
|
+
return child.children?.length ? (
|
|
68
|
+
<AccordionItem
|
|
69
|
+
key={child.uuid}
|
|
70
|
+
value={child.uuid}
|
|
71
|
+
className="border-b-0"
|
|
72
|
+
>
|
|
73
|
+
<AccordionTrigger className={cn(baseStyle, className)}>
|
|
74
|
+
<span
|
|
75
|
+
className={cn('line-clamp-2', maybeBold)}
|
|
76
|
+
onClick={() => onClick(child)}
|
|
77
|
+
>
|
|
78
|
+
{child.content}
|
|
79
|
+
</span>
|
|
80
|
+
</AccordionTrigger>
|
|
81
|
+
<AccordionContent className="border-l border-dotted py-0">
|
|
82
|
+
<TableOfContentsSection node={child} depth={depth + 1} />
|
|
83
|
+
</AccordionContent>
|
|
84
|
+
</AccordionItem>
|
|
85
|
+
) : (
|
|
86
|
+
<div key={child.uuid} className={baseStyle}>
|
|
87
|
+
<span
|
|
88
|
+
className={cn('line-clamp-2', maybeBold)}
|
|
89
|
+
onClick={() => onClick(child)}
|
|
90
|
+
>
|
|
91
|
+
{child.content}
|
|
92
|
+
</span>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
})}
|
|
96
|
+
</Accordion>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const TableOfContents = ({
|
|
101
|
+
toc,
|
|
102
|
+
work,
|
|
103
|
+
limitWhenNoTranslation = false,
|
|
104
|
+
}: {
|
|
105
|
+
toc?: Toc;
|
|
106
|
+
work: Work;
|
|
107
|
+
limitWhenNoTranslation?: boolean;
|
|
108
|
+
}) => {
|
|
109
|
+
const {
|
|
110
|
+
toh,
|
|
111
|
+
imprint,
|
|
112
|
+
setToh,
|
|
113
|
+
hasTranslationContent,
|
|
114
|
+
setHasTranslationContent,
|
|
115
|
+
} = useNavigation();
|
|
116
|
+
const [localToh, setLocalToh] = useState<TohokuCatalogEntry>(
|
|
117
|
+
work.toh[0] || '',
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const title = imprint?.mainTitles?.en || work.title;
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
const currentToh = toh || work.toh[0] || '';
|
|
124
|
+
setLocalToh(currentToh);
|
|
125
|
+
}, [toh, work.toh, setToh]);
|
|
126
|
+
|
|
127
|
+
const baseStyle = 'w-full py-2 leading-6 text-sm font-light text-foreground';
|
|
128
|
+
const inferredHasTranslationContent = useMemo(() => {
|
|
129
|
+
if (!toc) {
|
|
130
|
+
return hasTranslationContent;
|
|
131
|
+
}
|
|
132
|
+
return (toc.body?.length || 0) > 0;
|
|
133
|
+
}, [toc, hasTranslationContent]);
|
|
134
|
+
const allowTranslationSections = limitWhenNoTranslation
|
|
135
|
+
? inferredHasTranslationContent
|
|
136
|
+
: true;
|
|
137
|
+
const imprintEntry: TocEntry = {
|
|
138
|
+
uuid: 'imprint',
|
|
139
|
+
content: 'Imprint',
|
|
140
|
+
sort: 0,
|
|
141
|
+
level: 0,
|
|
142
|
+
section: 'imprint',
|
|
143
|
+
children: [],
|
|
144
|
+
};
|
|
145
|
+
const frontMatterChildren = allowTranslationSections
|
|
146
|
+
? [imprintEntry, ...(toc?.frontMatter || [])]
|
|
147
|
+
: [imprintEntry];
|
|
148
|
+
const frontMatter: TocEntry = {
|
|
149
|
+
uuid: 'front-matter',
|
|
150
|
+
content: 'Front Matter',
|
|
151
|
+
sort: 0,
|
|
152
|
+
level: 0,
|
|
153
|
+
section: 'front',
|
|
154
|
+
children: frontMatterChildren,
|
|
155
|
+
};
|
|
156
|
+
const body: TocEntry = {
|
|
157
|
+
uuid: 'root',
|
|
158
|
+
content: 'Body',
|
|
159
|
+
sort: 0,
|
|
160
|
+
level: 0,
|
|
161
|
+
section: 'translation',
|
|
162
|
+
children: toc?.body || [],
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const endnotes = toc?.backMatter?.find(
|
|
166
|
+
(entry) => entry.section === 'endnotes',
|
|
167
|
+
);
|
|
168
|
+
const abbreviations = toc?.backMatter?.find(
|
|
169
|
+
(entry) => entry.section === 'abbreviations',
|
|
170
|
+
);
|
|
171
|
+
const otherBackMatter = toc?.backMatter?.filter(
|
|
172
|
+
(entry) =>
|
|
173
|
+
entry.section !== 'endnotes' && entry.section !== 'abbreviations',
|
|
174
|
+
);
|
|
175
|
+
const backMatter: TocEntry = {
|
|
176
|
+
uuid: 'back-matter',
|
|
177
|
+
content: 'Back Matter',
|
|
178
|
+
sort: 0,
|
|
179
|
+
level: 0,
|
|
180
|
+
section: 'back',
|
|
181
|
+
children: [
|
|
182
|
+
...(endnotes ? [endnotes] : []),
|
|
183
|
+
...(otherBackMatter || []),
|
|
184
|
+
{
|
|
185
|
+
uuid: 'glossary',
|
|
186
|
+
content: 'Glossary',
|
|
187
|
+
sort: 0,
|
|
188
|
+
level: 0,
|
|
189
|
+
section: 'glossary',
|
|
190
|
+
children: [],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
uuid: 'bibliography',
|
|
194
|
+
content: 'Bibliography',
|
|
195
|
+
sort: 0,
|
|
196
|
+
level: 0,
|
|
197
|
+
section: 'bibliography',
|
|
198
|
+
children: [],
|
|
199
|
+
},
|
|
200
|
+
...(abbreviations ? [abbreviations] : []),
|
|
201
|
+
],
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
if (!toc || !limitWhenNoTranslation) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
setHasTranslationContent(inferredHasTranslationContent);
|
|
209
|
+
}, [
|
|
210
|
+
toc,
|
|
211
|
+
inferredHasTranslationContent,
|
|
212
|
+
limitWhenNoTranslation,
|
|
213
|
+
setHasTranslationContent,
|
|
214
|
+
]);
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<div>
|
|
218
|
+
<div className={cn(baseStyle, 'flex gap-2 mt-6')}>
|
|
219
|
+
<div className="size-5 text-primary-200 [&_svg]:stroke-1 [&_svg]:size-5 my-auto">
|
|
220
|
+
<LibraryBigIcon />
|
|
221
|
+
</div>
|
|
222
|
+
<span className="my-auto font-light">
|
|
223
|
+
{imprint?.section || work.section}
|
|
224
|
+
</span>
|
|
225
|
+
</div>
|
|
226
|
+
<div className={cn(baseStyle, 'flex gap-2')}>
|
|
227
|
+
<div className="size-5 text-primary-200 [&_svg]:stroke-1 [&_svg]:size-5 my-auto">
|
|
228
|
+
<BookOpenIcon />
|
|
229
|
+
</div>
|
|
230
|
+
<span className="my-auto font-semibold">{title}</span>
|
|
231
|
+
</div>
|
|
232
|
+
<div className="flex gap-2">
|
|
233
|
+
<div className="size-5 text-primary-200 [&_svg]:stroke-1 [&_svg]:size-5 my-auto">
|
|
234
|
+
<HashIcon />
|
|
235
|
+
</div>
|
|
236
|
+
{work.toh.length > 1 ? (
|
|
237
|
+
<Select
|
|
238
|
+
value={localToh}
|
|
239
|
+
onValueChange={(value) => {
|
|
240
|
+
setToh(value as TohokuCatalogEntry);
|
|
241
|
+
}}
|
|
242
|
+
>
|
|
243
|
+
<SelectTrigger
|
|
244
|
+
className={cn(
|
|
245
|
+
baseStyle,
|
|
246
|
+
'p-0 font-light bg-transparent border-none',
|
|
247
|
+
)}
|
|
248
|
+
>
|
|
249
|
+
<SelectValue placeholder="Select TOH" />
|
|
250
|
+
</SelectTrigger>
|
|
251
|
+
<SelectContent>
|
|
252
|
+
{work.toh.map((tohEntry) => {
|
|
253
|
+
const parsedToh = parseToh(tohEntry);
|
|
254
|
+
return (
|
|
255
|
+
<SelectItem key={tohEntry} value={tohEntry}>
|
|
256
|
+
{parsedToh}
|
|
257
|
+
</SelectItem>
|
|
258
|
+
);
|
|
259
|
+
})}
|
|
260
|
+
</SelectContent>
|
|
261
|
+
</Select>
|
|
262
|
+
) : (
|
|
263
|
+
<div className={cn(baseStyle, 'font-light')}>
|
|
264
|
+
{parseToh(localToh || '')}
|
|
265
|
+
</div>
|
|
266
|
+
)}
|
|
267
|
+
</div>
|
|
268
|
+
<Separator className="my-4" />
|
|
269
|
+
<TableOfContentsSection node={frontMatter} panel="left" />
|
|
270
|
+
{allowTranslationSections && (
|
|
271
|
+
<>
|
|
272
|
+
<Separator className="my-4" />
|
|
273
|
+
<TableOfContentsSection node={body} panel="main" />
|
|
274
|
+
<Separator className="my-4" />
|
|
275
|
+
<TableOfContentsSection node={backMatter} panel="right" />
|
|
276
|
+
</>
|
|
277
|
+
)}
|
|
278
|
+
</div>
|
|
279
|
+
);
|
|
280
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ThreeColumns } from '@eightyfourthousand/design-system';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { useNavigation } from './NavigationProvider';
|
|
6
|
+
import { cn } from '@eightyfourthousand/lib-utils';
|
|
7
|
+
import { TranslationHeader } from './TranslationHeader';
|
|
8
|
+
|
|
9
|
+
export const ThreeColumnRenderer = ({
|
|
10
|
+
withHeader = false,
|
|
11
|
+
children,
|
|
12
|
+
}: {
|
|
13
|
+
withHeader?: boolean;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}) => {
|
|
16
|
+
const { panels, updatePanel, hasTranslationContent } = useNavigation();
|
|
17
|
+
const rightPanelEnabled = hasTranslationContent;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
className={cn(
|
|
22
|
+
'fixed flex flex-col size-full p-2 bg-canvas',
|
|
23
|
+
withHeader ? 'pb-20' : '',
|
|
24
|
+
)}
|
|
25
|
+
>
|
|
26
|
+
<div className="pb-2.5">
|
|
27
|
+
<TranslationHeader className="rounded-full shadow-lg" />
|
|
28
|
+
</div>
|
|
29
|
+
<ThreeColumns
|
|
30
|
+
leftPanelOpen={panels.left.open}
|
|
31
|
+
rightPanelOpen={rightPanelEnabled ? panels.right.open : false}
|
|
32
|
+
rightPanelEnabled={rightPanelEnabled}
|
|
33
|
+
onLeftPanelOpenChange={(open) => {
|
|
34
|
+
updatePanel({
|
|
35
|
+
name: 'left',
|
|
36
|
+
state: { open, tab: panels.left.tab },
|
|
37
|
+
});
|
|
38
|
+
}}
|
|
39
|
+
onRightPanelOpenChange={
|
|
40
|
+
rightPanelEnabled
|
|
41
|
+
? (open) => {
|
|
42
|
+
updatePanel({
|
|
43
|
+
name: 'right',
|
|
44
|
+
state: { open, tab: panels.right.tab },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
: undefined
|
|
48
|
+
}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</ThreeColumns>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { MiniLogo } from '@eightyfourthousand/design-system';
|
|
4
|
+
import { PassageMatch, SearchButton, SearchResult } from '@eightyfourthousand/lib-search';
|
|
5
|
+
import { useNavigation } from './NavigationProvider';
|
|
6
|
+
import { useCallback } from 'react';
|
|
7
|
+
import { PanelName, PanelState, TabName } from './types';
|
|
8
|
+
import { BodyItemType } from '@eightyfourthousand/data-access';
|
|
9
|
+
import { cn } from '@eightyfourthousand/lib-utils';
|
|
10
|
+
|
|
11
|
+
export const TranslationHeader = ({ className }: { className?: string }) => {
|
|
12
|
+
const { imprint, uuid, toh, updatePanel } = useNavigation();
|
|
13
|
+
|
|
14
|
+
const onResultSelected = useCallback(
|
|
15
|
+
(result: SearchResult) => {
|
|
16
|
+
let side: PanelName = 'main';
|
|
17
|
+
const panelState: PanelState = {
|
|
18
|
+
open: true,
|
|
19
|
+
hash: result.uuid,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const TAB_FOR_PASSAGE_SECTION: Partial<Record<BodyItemType, TabName>> = {
|
|
23
|
+
abbreviations: 'abbreviations',
|
|
24
|
+
endnotes: 'endnotes',
|
|
25
|
+
summary: 'front',
|
|
26
|
+
introduction: 'front',
|
|
27
|
+
acknowledgements: 'front',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const SIDE_FOR_PASSAGE_SECTION: Partial<Record<BodyItemType, PanelName>> =
|
|
31
|
+
{
|
|
32
|
+
abbreviations: 'right',
|
|
33
|
+
endnotes: 'right',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
switch (result.type) {
|
|
37
|
+
case 'passage':
|
|
38
|
+
{
|
|
39
|
+
const passage = result as PassageMatch;
|
|
40
|
+
side = SIDE_FOR_PASSAGE_SECTION[passage.section] || 'main';
|
|
41
|
+
panelState.tab =
|
|
42
|
+
TAB_FOR_PASSAGE_SECTION[passage.section] || 'translation';
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case 'alignment':
|
|
46
|
+
side = 'main';
|
|
47
|
+
panelState.tab = 'compare';
|
|
48
|
+
break;
|
|
49
|
+
case 'bibliography':
|
|
50
|
+
side = 'right';
|
|
51
|
+
panelState.tab = 'bibliography';
|
|
52
|
+
break;
|
|
53
|
+
case 'glossary':
|
|
54
|
+
side = 'right';
|
|
55
|
+
panelState.tab = 'glossary';
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
updatePanel({
|
|
60
|
+
name: side,
|
|
61
|
+
state: panelState,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
[updatePanel],
|
|
65
|
+
);
|
|
66
|
+
return (
|
|
67
|
+
<div
|
|
68
|
+
className={cn(
|
|
69
|
+
'h-11 w-full px-0 lg:px-3 flex justify-between text-lg bg-background',
|
|
70
|
+
className,
|
|
71
|
+
)}
|
|
72
|
+
>
|
|
73
|
+
<div className="flex gap-2 md:gap-5 min-w-0">
|
|
74
|
+
<MiniLogo className="ms-3 me-1 my-auto" width={32} height={32} />
|
|
75
|
+
<span className="font-serif font-light truncate text-darkgray text-xs sm:text-sm my-auto flex-shrink">
|
|
76
|
+
{`${imprint?.mainTitles?.en ? `${imprint?.mainTitles?.en}` : ''}${imprint?.section ? ` from ${imprint?.section}` : ''}`}
|
|
77
|
+
</span>
|
|
78
|
+
</div>
|
|
79
|
+
<SearchButton
|
|
80
|
+
workUuid={uuid}
|
|
81
|
+
toh={toh}
|
|
82
|
+
onResultSelected={onResultSelected}
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
autoUpdate,
|
|
3
|
+
flip,
|
|
4
|
+
inline,
|
|
5
|
+
offset,
|
|
6
|
+
shift,
|
|
7
|
+
useFloating,
|
|
8
|
+
} from '@floating-ui/react';
|
|
9
|
+
import { ReactNode, useEffect, useRef, useState } from 'react';
|
|
10
|
+
import { cn } from '@eightyfourthousand/lib-utils';
|
|
11
|
+
import { DEFAULT_HOVER_CARD_SIDE_OFFSET } from '@eightyfourthousand/design-system';
|
|
12
|
+
|
|
13
|
+
export const TranslationHoverCard = ({
|
|
14
|
+
anchor,
|
|
15
|
+
className = '',
|
|
16
|
+
children,
|
|
17
|
+
setCard,
|
|
18
|
+
}: {
|
|
19
|
+
anchor: HTMLElement;
|
|
20
|
+
className?: string;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
setCard: (card: HTMLElement | null) => void;
|
|
23
|
+
}) => {
|
|
24
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
25
|
+
|
|
26
|
+
const { refs, floatingStyles } = useFloating({
|
|
27
|
+
placement: 'bottom-start',
|
|
28
|
+
middleware: [
|
|
29
|
+
inline(),
|
|
30
|
+
offset(DEFAULT_HOVER_CARD_SIDE_OFFSET),
|
|
31
|
+
flip(),
|
|
32
|
+
shift(),
|
|
33
|
+
],
|
|
34
|
+
whileElementsMounted: autoUpdate,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const innerRef = useRef<HTMLDivElement>(null);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
refs.setReference(anchor);
|
|
41
|
+
}, [anchor, refs]);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
setCard(innerRef.current);
|
|
45
|
+
|
|
46
|
+
return () => {
|
|
47
|
+
setCard(null);
|
|
48
|
+
};
|
|
49
|
+
}, [innerRef, setCard]);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!refs.floating.current) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
requestAnimationFrame(() => {
|
|
57
|
+
setIsVisible(true);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return () => {
|
|
61
|
+
setIsVisible(false);
|
|
62
|
+
};
|
|
63
|
+
}, [refs]);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
ref={refs.setFloating}
|
|
68
|
+
style={{ ...floatingStyles, pointerEvents: 'auto', cursor: 'default' }}
|
|
69
|
+
className="z-100"
|
|
70
|
+
>
|
|
71
|
+
<div
|
|
72
|
+
ref={innerRef}
|
|
73
|
+
className={cn(
|
|
74
|
+
'bg-popover text-popover-foreground rounded-md border p-4 shadow-md outline-hidden hover:cursor-default',
|
|
75
|
+
'transition-[opacity,scale] duration-150 origin-center ease-out',
|
|
76
|
+
isVisible ? 'opacity-100 scale-100' : 'opacity-0 scale-99',
|
|
77
|
+
className,
|
|
78
|
+
)}
|
|
79
|
+
>
|
|
80
|
+
{children}
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Skeleton } from '@eightyfourthousand/design-system';
|
|
2
|
+
import { cn } from '@eightyfourthousand/lib-utils';
|
|
3
|
+
|
|
4
|
+
export const TranslationSkeleton = ({ className }: { className?: string }) => {
|
|
5
|
+
return (
|
|
6
|
+
<div className={cn('flex h-full', className)}>
|
|
7
|
+
<div className="flex flex-col gap-6 pt-8">
|
|
8
|
+
<Skeleton className="h-12 mb-4" />
|
|
9
|
+
<Skeleton className="h-20 w-1/2" />
|
|
10
|
+
<Skeleton className="h-48" />
|
|
11
|
+
<Skeleton className="h-24 w-5/6" />
|
|
12
|
+
<Skeleton className="h-64" />
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
};
|