Skip to content

Build your personal knowledge base with Trilium Notes

feat(import): card-based layout for the import dialog

Elian Doran99df34607c1a
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index ffa87a8fc4..6547e51e3d 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -201,6 +201,7 @@
},
"import": {
"importIntoNote": "Import into note",
+ "import_from": "Import from",
"cardName": "Files & other formats",
"cardDescription": "ZIP, ENEX, OPML, Markdown, HTML, images and more",
"chooseImportFile": "Choose import file",
diff --git a/apps/client/src/widgets/dialogs/import/anytype.tsx b/apps/client/src/widgets/dialogs/import/anytype.tsx
index b8998d0edd..2a1a0436a2 100644
--- a/apps/client/src/widgets/dialogs/import/anytype.tsx
+++ b/apps/client/src/widgets/dialogs/import/anytype.tsx
@@ -3,8 +3,8 @@ import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import { t } from "../../../services/i18n.js";
import importService from "../../../services/import.js";
import Button from "../../react/Button.js";
+import { Card, CardSection } from "../../react/Card.js";
import FileDropZone from "../../react/FileDropZone.js";
-import FormGroup from "../../react/FormGroup.js";
import iconUrl from "./icons/anytype.svg?url";
import type { ImportProvider, ImportProviderPanelProps } from "./types.js";
@@ -45,12 +45,12 @@ function AnytypePanel({ parentNoteId, closeDialog, setFooter }: ImportProviderPa
}, [file, setFooter]);
return (
- <div className="anytype-panel">
- <p>{t("anytype_import.description_long")}</p>
- <FormGroup name="anytype-file" label={t("anytype_import.choose_file")}>
+ <Card heading={t("anytype_import.choose_file")}>
+ <CardSection>
+ <p className="import-files-description">{t("anytype_import.description_long")}</p>
<FileDropZone onChange={onChange} />
- </FormGroup>
- </div>
+ </CardSection>
+ </Card>
);
}
diff --git a/apps/client/src/widgets/dialogs/import/evernote.tsx b/apps/client/src/widgets/dialogs/import/evernote.tsx
index 38a080746f..fb1c93181e 100644
--- a/apps/client/src/widgets/dialogs/import/evernote.tsx
+++ b/apps/client/src/widgets/dialogs/import/evernote.tsx
@@ -3,8 +3,8 @@ import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import { t } from "../../../services/i18n.js";
import importService from "../../../services/import.js";
import Button from "../../react/Button.js";
+import { Card, CardSection } from "../../react/Card.js";
import FileDropZone from "../../react/FileDropZone.js";
-import FormGroup from "../../react/FormGroup.js";
import iconUrl from "./icons/evernote.svg?url";
import type { ImportProvider, ImportProviderPanelProps } from "./types.js";
@@ -46,12 +46,12 @@ function EvernotePanel({ parentNoteId, closeDialog, setFooter }: ImportProviderP
}, [files.length, setFooter]);
return (
- <div className="evernote-panel">
- <p>{t("evernote_import.description_long")}</p>
- <FormGroup name="evernote-file" label={t("evernote_import.choose_file")}>
+ <Card heading={t("evernote_import.choose_file")}>
+ <CardSection>
+ <p className="import-files-description">{t("evernote_import.description_long")}</p>
<FileDropZone multiple onChange={onChange} />
- </FormGroup>
- </div>
+ </CardSection>
+ </Card>
);
}
diff --git a/apps/client/src/widgets/dialogs/import/files.tsx b/apps/client/src/widgets/dialogs/import/files.tsx
index beba1100da..b27551322a 100644
--- a/apps/client/src/widgets/dialogs/import/files.tsx
+++ b/apps/client/src/widgets/dialogs/import/files.tsx
@@ -4,11 +4,11 @@ import { t } from "../../../services/i18n.js";
import importService, { type UploadFilesOptions } from "../../../services/import.js";
import tree from "../../../services/tree.js";
import Button from "../../react/Button.js";
+import { Card, CardSection } from "../../react/Card.js";
import FileDropZone from "../../react/FileDropZone.js";
-import FormCheckbox from "../../react/FormCheckbox.js";
-import FormGroup, { FormMultiGroup } from "../../react/FormGroup.js";
import { useTriliumOptionBool } from "../../react/hooks.js";
import RawHtml from "../../react/RawHtml.js";
+import { OptionsRowWithToggle } from "../../type_widgets/options/components/OptionsRow.js";
import type { ImportProvider, ImportProviderPanelProps } from "./types.js";
function FilesPanel({ parentNoteId, closeDialog, setFooter }: ImportProviderPanelProps) {
@@ -62,48 +62,50 @@ function FilesPanel({ parentNoteId, closeDialog, setFooter }: ImportProviderPane
}, [files, setFooter]);
return (
- <div className="files-panel">
- <FormGroup name="files" label={t("import.chooseImportFile")} description={
- <>
- {t("import.importDescription")} <strong>{noteTitle}</strong>.<br />
- {t("import.importZipRecommendation")}
- </>
- }>
- <FileDropZone multiple onChange={setFiles} />
- </FormGroup>
+ <>
+ <Card heading={t("import.chooseImportFile")}>
+ <CardSection>
+ <p className="import-files-description">
+ {t("import.importDescription")} <strong>{noteTitle}</strong>.<br />
+ {t("import.importZipRecommendation")}
+ </p>
+ <FileDropZone multiple onChange={setFiles} />
+ </CardSection>
+ </Card>
- <FormMultiGroup label={t("import.options")}>
- <FormCheckbox
- name="safe-import" hint={t("import.safeImportTooltip")} label={t("import.safeImport")}
- currentValue={safeImport} onChange={setSafeImport}
- />
- <FormCheckbox
- name="explode-archives" hint={t("import.explodeArchivesTooltip")} label={<RawHtml html={t("import.explodeArchives")} />}
- currentValue={explodeArchives} onChange={setExplodeArchives}
- />
- <FormCheckbox
- name="shrink-images" hint={t("import.shrinkImagesTooltip")} label={t("import.shrinkImages")}
- currentValue={compressImages && shrinkImages} onChange={setShrinkImages}
- disabled={!compressImages}
- />
- <FormCheckbox
- name="text-imported-as-text" label={t("import.textImportedAsText")}
- currentValue={textImportedAsText} onChange={setTextImportedAsText}
- />
- <FormCheckbox
- name="code-imported-as-code" label={<RawHtml html={t("import.codeImportedAsCode")} />}
- currentValue={codeImportedAsCode} onChange={setCodeImportedAsCode}
- />
- <FormCheckbox
- name="spreadsheet-imported-as-spreadsheet" label={t("import.spreadsheetImportedAsSpreadsheet")}
- currentValue={spreadsheetImportedAsSpreadsheet} onChange={setSpreadsheetImportedAsSpreadsheet}
- />
- <FormCheckbox
- name="replace-underscores-with-spaces" label={t("import.replaceUnderscoresWithSpaces")}
- currentValue={replaceUnderscoresWithSpaces} onChange={setReplaceUnderscoresWithSpaces}
- />
- </FormMultiGroup>
- </div>
+ <Card heading={t("import.options")}>
+ <CardSection>
+ <OptionsRowWithToggle
+ name="safe-import" label={t("import.safeImport")} description={<RawHtml html={t("import.safeImportTooltip")} />}
+ currentValue={safeImport} onChange={setSafeImport}
+ />
+ <OptionsRowWithToggle
+ name="explode-archives" label={<RawHtml html={t("import.explodeArchives")} />} description={<RawHtml html={t("import.explodeArchivesTooltip")} />}
+ currentValue={explodeArchives} onChange={setExplodeArchives}
+ />
+ <OptionsRowWithToggle
+ name="shrink-images" label={t("import.shrinkImages")} description={<RawHtml html={t("import.shrinkImagesTooltip")} />}
+ currentValue={compressImages && shrinkImages} onChange={setShrinkImages} disabled={!compressImages}
+ />
+ <OptionsRowWithToggle
+ name="text-imported-as-text" label={t("import.textImportedAsText")}
+ currentValue={textImportedAsText} onChange={setTextImportedAsText}
+ />
+ <OptionsRowWithToggle
+ name="code-imported-as-code" label={<RawHtml html={t("import.codeImportedAsCode")} />}
+ currentValue={codeImportedAsCode} onChange={setCodeImportedAsCode}
+ />
+ <OptionsRowWithToggle
+ name="spreadsheet-imported-as-spreadsheet" label={t("import.spreadsheetImportedAsSpreadsheet")}
+ currentValue={spreadsheetImportedAsSpreadsheet} onChange={setSpreadsheetImportedAsSpreadsheet}
+ />
+ <OptionsRowWithToggle
+ name="replace-underscores-with-spaces" label={t("import.replaceUnderscoresWithSpaces")}
+ currentValue={replaceUnderscoresWithSpaces} onChange={setReplaceUnderscoresWithSpaces}
+ />
+ </CardSection>
+ </Card>
+ </>
);
}
diff --git a/apps/client/src/widgets/dialogs/import/import_dialog.css b/apps/client/src/widgets/dialogs/import/import_dialog.css
index d06e4aead1..af500bc8a9 100644
--- a/apps/client/src/widgets/dialogs/import/import_dialog.css
+++ b/apps/client/src/widgets/dialogs/import/import_dialog.css
@@ -1,4 +1,13 @@
.modal.import-provider-dialog {
+ /* Each region (provider picker, file upload, options) is its own card, like the delete dialog. */
+ .tn-card {
+ margin-bottom: 1rem;
+ }
+
+ .tn-card:last-child {
+ margin-bottom: 0;
+ }
+
.import-provider-picker {
display: grid;
grid-template-columns: repeat(3, 1fr);
@@ -13,7 +22,20 @@
margin-top: 1em;
padding-top: 1em;
border-top: 1px solid var(--main-border-color);
- margin-bottom: 1.5em;
+ }
+
+ .import-files-description {
+ margin-bottom: 0.75em;
+ color: var(--muted-text-color);
+ }
+
+ /* Some option descriptions carry rich HTML (e.g. multi-paragraph hints); keep them tight. */
+ .option-row-description p {
+ margin: 0;
+ }
+
+ .option-row-description p + p {
+ margin-top: 0.4em;
}
.import-provider-card {
@@ -75,11 +97,6 @@
opacity: 0.8;
}
- .import-provider-panel {
- border-top: 1px solid var(--main-border-color);
- padding-top: 1.25em;
- }
-
.import-provider-hint {
color: var(--muted-text-color);
text-align: center;
diff --git a/apps/client/src/widgets/dialogs/import/import_dialog.tsx b/apps/client/src/widgets/dialogs/import/import_dialog.tsx
index 6d51e8141a..27cf9f4211 100644
--- a/apps/client/src/widgets/dialogs/import/import_dialog.tsx
+++ b/apps/client/src/widgets/dialogs/import/import_dialog.tsx
@@ -4,6 +4,7 @@ import type { ComponentChildren } from "preact";
import { useCallback, useState } from "preact/hooks";
import { t } from "../../../services/i18n.js";
+import { Card, CardSection } from "../../react/Card.js";
import { useTriliumEvent } from "../../react/hooks.js";
import Modal from "../../react/Modal.js";
import { importProviders } from "./index.js";
@@ -45,25 +46,27 @@ export default function ImportDialog() {
onHidden={() => setShown(false)}
show={shown}
>
- <div className="import-provider-picker">
- {serviceProviders.map((p) => (
- <ImportProviderCard key={p.id} provider={p} selected={p.id === providerId} onSelect={() => setProviderId(p.id)} />
- ))}
- </div>
+ <Card heading={t("import.import_from")}>
+ <CardSection>
+ <div className="import-provider-picker">
+ {serviceProviders.map((p) => (
+ <ImportProviderCard key={p.id} provider={p} selected={p.id === providerId} onSelect={() => setProviderId(p.id)} />
+ ))}
+ </div>
- {localProviders.length > 0 && (
- <div className="import-provider-local">
- {localProviders.map((p) => (
- <ImportProviderCard key={p.id} provider={p} selected={p.id === providerId} onSelect={() => setProviderId(p.id)} />
- ))}
- </div>
- )}
+ {localProviders.length > 0 && (
+ <div className="import-provider-local">
+ {localProviders.map((p) => (
+ <ImportProviderCard key={p.id} provider={p} selected={p.id === providerId} onSelect={() => setProviderId(p.id)} />
+ ))}
+ </div>
+ )}
+ </CardSection>
+ </Card>
- <div className="import-provider-panel">
- {provider && parentNoteId
- ? <provider.Panel key={provider.id} parentNoteId={parentNoteId} closeDialog={closeDialog} setFooter={setFooter} />
- : <p className="import-provider-hint">{t("import_provider.choose_provider")}</p>}
- </div>
+ {provider && parentNoteId
+ ? <provider.Panel key={provider.id} parentNoteId={parentNoteId} closeDialog={closeDialog} setFooter={setFooter} />
+ : <p className="import-provider-hint">{t("import_provider.choose_provider")}</p>}
</Modal>
);
}
diff --git a/apps/client/src/widgets/dialogs/import/keep.tsx b/apps/client/src/widgets/dialogs/import/keep.tsx
index 0e3ba625f6..26903e7766 100644
--- a/apps/client/src/widgets/dialogs/import/keep.tsx
+++ b/apps/client/src/widgets/dialogs/import/keep.tsx
@@ -3,8 +3,8 @@ import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import { t } from "../../../services/i18n.js";
import importService from "../../../services/import.js";
import Button from "../../react/Button.js";
+import { Card, CardSection } from "../../react/Card.js";
import FileDropZone from "../../react/FileDropZone.js";
-import FormGroup from "../../react/FormGroup.js";
import iconUrl from "./icons/keep.svg?url";
import type { ImportProvider, ImportProviderPanelProps } from "./types.js";
@@ -45,12 +45,12 @@ function KeepPanel({ parentNoteId, closeDialog, setFooter }: ImportProviderPanel
}, [file, setFooter]);
return (
- <div className="keep-panel">
- <p>{t("keep_import.description_long")}</p>
- <FormGroup name="keep-file" label={t("keep_import.choose_file")}>
+ <Card heading={t("keep_import.choose_file")}>
+ <CardSection>
+ <p className="import-files-description">{t("keep_import.description_long")}</p>
<FileDropZone onChange={onChange} />
- </FormGroup>
- </div>
+ </CardSection>
+ </Card>
);
}
diff --git a/apps/client/src/widgets/dialogs/import/notion.tsx b/apps/client/src/widgets/dialogs/import/notion.tsx
index f374be3031..51335c4604 100644
--- a/apps/client/src/widgets/dialogs/import/notion.tsx
+++ b/apps/client/src/widgets/dialogs/import/notion.tsx
@@ -3,8 +3,8 @@ import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import { t } from "../../../services/i18n.js";
import importService from "../../../services/import.js";
import Button from "../../react/Button.js";
+import { Card, CardSection } from "../../react/Card.js";
import FileDropZone from "../../react/FileDropZone.js";
-import FormGroup from "../../react/FormGroup.js";
import iconUrl from "./icons/notion.svg?url";
import type { ImportProvider, ImportProviderPanelProps } from "./types.js";
@@ -45,12 +45,12 @@ function NotionPanel({ parentNoteId, closeDialog, setFooter }: ImportProviderPan
}, [file, setFooter]);
return (
- <div className="notion-panel">
- <p>{t("notion_import.description_long")}</p>
- <FormGroup name="notion-file" label={t("notion_import.choose_file")}>
+ <Card heading={t("notion_import.choose_file")}>
+ <CardSection>
+ <p className="import-files-description">{t("notion_import.description_long")}</p>
<FileDropZone onChange={onChange} />
- </FormGroup>
- </div>
+ </CardSection>
+ </Card>
);
}
diff --git a/apps/client/src/widgets/dialogs/import/onenote.tsx b/apps/client/src/widgets/dialogs/import/onenote.tsx
index ef518e7df2..08b0c5c49a 100644
--- a/apps/client/src/widgets/dialogs/import/onenote.tsx
+++ b/apps/client/src/widgets/dialogs/import/onenote.tsx
@@ -6,6 +6,7 @@ import toast from "../../../services/toast.js";
import { isElectron, randomString } from "../../../services/utils.js";
import { ExtendedAdmonition } from "../../react/Admonition.js";
import Button from "../../react/Button.js";
+import { Card, CardSection } from "../../react/Card.js";
import FormCheckbox from "../../react/FormCheckbox.js";
import LoadingSpinner from "../../react/LoadingSpinner.js";
import iconUrl from "./icons/onenote.svg?url";
@@ -169,46 +170,50 @@ function OneNotePanel({ parentNoteId, closeDialog, setFooter }: ImportProviderPa
}, [phase, debug, importDisabled, setFooter]);
if (phase === "checking") {
- return <div className="onenote-panel"><LoadingSpinner /></div>;
+ return <Card><CardSection className="onenote-panel"><LoadingSpinner /></CardSection></Card>;
}
if (phase === "disconnected" || phase === "connecting") {
return (
- <div className="onenote-panel">
- <p>{t("onenote_import.connect_description")}</p>
- {phase === "connecting"
- ? <p className="onenote-status"><LoadingSpinner /> {t("onenote_import.connecting")}</p>
- : <Button text={t("onenote_import.connect")} kind="primary" icon="bxl-microsoft" onClick={connect} />}
- </div>
+ <Card>
+ <CardSection className="onenote-panel">
+ <p>{t("onenote_import.connect_description")}</p>
+ {phase === "connecting"
+ ? <p className="onenote-status"><LoadingSpinner /> {t("onenote_import.connecting")}</p>
+ : <Button text={t("onenote_import.connect")} kind="primary" icon="bxl-microsoft" onClick={connect} />}
+ </CardSection>
+ </Card>
);
}
return (
- <div className="onenote-panel">
- <div className="onenote-account">
- <span>{t("onenote_import.connected_as", { name: account?.name ?? "" })}</span>
- <Button text={t("onenote_import.disconnect")} kind="lowProfile" size="small" onClick={disconnect} />
- </div>
-
- {notebooks.length === 0
- ? <p>{t("onenote_import.no_notebooks")}</p>
- : (
- <>
- <p>{t("onenote_import.select_sections")}</p>
- <div className="onenote-notebooks">
- {notebooks.map((notebook) => (
- <div className="onenote-notebook" key={notebook.id}>
- <strong>{notebook.title}</strong>
- <SectionTree container={notebook} selectedIds={selectedIds} onToggle={toggleSection} />
- </div>
- ))}
- </div>
- <ExtendedAdmonition type="note" icon="bx bx-info-circle" title={t("onenote_import.order_hint_title")}>
- {t("onenote_import.order_hint")}
- </ExtendedAdmonition>
- </>
- )}
- </div>
+ <Card>
+ <CardSection className="onenote-panel">
+ <div className="onenote-account">
+ <span>{t("onenote_import.connected_as", { name: account?.name ?? "" })}</span>
+ <Button text={t("onenote_import.disconnect")} kind="lowProfile" size="small" onClick={disconnect} />
+ </div>
+
+ {notebooks.length === 0
+ ? <p>{t("onenote_import.no_notebooks")}</p>
+ : (
+ <>
+ <p>{t("onenote_import.select_sections")}</p>
+ <div className="onenote-notebooks">
+ {notebooks.map((notebook) => (
+ <div className="onenote-notebook" key={notebook.id}>
+ <strong>{notebook.title}</strong>
+ <SectionTree container={notebook} selectedIds={selectedIds} onToggle={toggleSection} />
+ </div>
+ ))}
+ </div>
+ <ExtendedAdmonition type="note" icon="bx bx-info-circle" title={t("onenote_import.order_hint_title")}>
+ {t("onenote_import.order_hint")}
+ </ExtendedAdmonition>
+ </>
+ )}
+ </CardSection>
+ </Card>
);
}