Skip to content

Commit cd6b0ad

Browse files
committed
UI adjustments
1 parent d85b443 commit cd6b0ad

File tree

2 files changed

+66
-37
lines changed

2 files changed

+66
-37
lines changed

src/components/Export.tsx

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const ExportProgress = ({ id }: { id: string }) => {
7474
export type ExportDialogProps = {
7575
results?: Result[] | ((isSamePageEnabled: boolean) => Promise<Result[]>);
7676
title?: string;
77+
isExportDiscourseGraph?: boolean;
7778
};
7879

7980
type ExportDialogComponent = (
@@ -94,6 +95,7 @@ const ExportDialog: ExportDialogComponent = ({
9495
isOpen,
9596
results = [],
9697
title = "Share Data",
98+
isExportDiscourseGraph = false,
9799
}) => {
98100
const exportId = useMemo(() => nanoid(), []);
99101
useEffect(() => {
@@ -137,6 +139,10 @@ const ExportDialog: ExportDialogComponent = ({
137139
const isCanvasPage = checkForCanvasPage(selectedPageTitle);
138140
const [isSendToGraph, setIsSendToGraph] = useState(false);
139141
const [livePages, setLivePages] = useState<Result[]>([]);
142+
const [selectedTabId, setSelectedTabId] = useState("sendto");
143+
useEffect(() => {
144+
if (isExportDiscourseGraph) setSelectedTabId("export");
145+
}, [isExportDiscourseGraph]);
140146
const getDiscourseGraphSetting = () =>
141147
getExtensionAPI().settings.get("discourse-graphs");
142148
const [discourseGraphSetting, setDiscourseGraphSetting] = useState(
@@ -294,48 +300,65 @@ const ExportDialog: ExportDialogComponent = ({
294300
onChange={(e) => setFilename(e.target.value)}
295301
/>
296302
</Label>
297-
<FormGroup
298-
className={discourseGraphEnabled ? "" : "hidden"}
299-
label="Include Discourse Context"
300-
inline
301-
>
302-
<Checkbox
303-
checked={includeDiscourseContext}
304-
onChange={(e) => {
305-
setIncludeDiscourseContext(
306-
(e.target as HTMLInputElement).checked
307-
);
308-
}}
309-
/>
310-
</FormGroup>
311-
<div className="text-right">
303+
304+
<div className="flex justify-between items-end">
312305
<span>
313306
{typeof results === "function"
314307
? "Calculating number of results..."
315308
: `Exporting ${results.length} results`}
316309
</span>
317-
{window.samepage && (
318-
<Checkbox
319-
checked={isSamePageEnabled}
320-
onChange={(e) =>
321-
setIsSamePageEnabled((e.target as HTMLInputElement).checked)
322-
}
323-
style={{ marginBottom: 0 }}
324-
labelElement={
325-
<Tooltip
326-
content={
327-
"Use SamePage's backend to gather this export [EXPERIMENTAL]."
310+
<div className="flex flex-col items-end">
311+
<FormGroup
312+
className={`m-0 ${discourseGraphEnabled ? "" : "hidden"}`}
313+
inline
314+
>
315+
<Checkbox
316+
alignIndicator={"right"}
317+
checked={includeDiscourseContext}
318+
onChange={(e) => {
319+
setIncludeDiscourseContext(
320+
(e.target as HTMLInputElement).checked
321+
);
322+
}}
323+
labelElement={
324+
<Tooltip
325+
className="m-0"
326+
content={
327+
"Include the Discourse Context of each result in the export."
328+
}
329+
>
330+
<span>Discourse Context</span>
331+
</Tooltip>
332+
}
333+
/>
334+
</FormGroup>
335+
{window.samepage && (
336+
<FormGroup className="m-0 " inline>
337+
<Checkbox
338+
alignIndicator={"right"}
339+
checked={isSamePageEnabled}
340+
onChange={(e) =>
341+
setIsSamePageEnabled((e.target as HTMLInputElement).checked)
328342
}
329-
>
330-
<img
331-
src="https://samepage.network/images/logo.png"
332-
height={24}
333-
width={24}
334-
/>
335-
</Tooltip>
336-
}
337-
/>
338-
)}
343+
style={{ marginBottom: 0 }}
344+
labelElement={
345+
<Tooltip
346+
className="m-0"
347+
content={
348+
"Use SamePage's backend to gather this export [EXPERIMENTAL]."
349+
}
350+
>
351+
<img
352+
src="https://samepage.network/images/logo.png"
353+
height={24}
354+
width={24}
355+
/>
356+
</Tooltip>
357+
}
358+
/>
359+
</FormGroup>
360+
)}
361+
</div>
339362
</div>
340363
</div>
341364
<div className={Classes.DIALOG_FOOTER}>
@@ -479,7 +502,12 @@ const ExportDialog: ExportDialogComponent = ({
479502
enforceFocus={false}
480503
portalClassName={"roamjs-export-dialog-body"}
481504
>
482-
<Tabs id="export-tabs" large={true}>
505+
<Tabs
506+
id="export-tabs"
507+
large={true}
508+
selectedTabId={selectedTabId}
509+
onChange={(newTabId: string) => setSelectedTabId(newTabId)}
510+
>
483511
<Tab id="sendto" title="Send To" panel={SendToPanel} />
484512
<Tab id="export" title="Export" panel={ExportPanel} />
485513
</Tabs>

src/discourseGraphsMode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ const initializeDiscourseGraphsMode = async (args: OnloadArgs) => {
896896
exportRender({
897897
results,
898898
title: "Export Discourse Graph",
899+
isExportDiscourseGraph: true,
899900
});
900901
},
901902
});

0 commit comments

Comments
 (0)