mirror of
https://github.com/zadam/trilium.git
synced 2025-10-08 14:42:29 +08:00
refactor(react): use component for map type switcher
This commit is contained in:
parent
20dcbff68f
commit
ad5ff6e41a
1 changed files with 19 additions and 15 deletions
|
@ -67,21 +67,8 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) {
|
|||
return (
|
||||
<div className="note-map-widget">
|
||||
<div className="btn-group btn-group-sm map-type-switcher content-floating-buttons top-left" role="group">
|
||||
<ActionButton
|
||||
icon="bx bx-network-chart"
|
||||
text={t("note-map.button-link-map")}
|
||||
disabled={mapType === "link"}
|
||||
onClick={() => setMapType("link")}
|
||||
frame
|
||||
/>
|
||||
|
||||
<ActionButton
|
||||
icon="bx bx-sitemap"
|
||||
text={t("note-map.button-tree-map")}
|
||||
disabled={mapType === "tree"}
|
||||
onClick={() => setMapType("tree")}
|
||||
frame
|
||||
/>
|
||||
<MapTypeSwitcher type="link" icon="bx bx-network-chart" text={t("note-map.button-link-map")} currentMapType={mapType} setMapType={setMapType} />
|
||||
<MapTypeSwitcher type="tree" icon="bx bx-sitemap" text={t("note-map.button-tree-map")} currentMapType={mapType} setMapType={setMapType} />
|
||||
</div>
|
||||
|
||||
<div ref={styleResolverRef} class="style-resolver" />
|
||||
|
@ -90,6 +77,23 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) {
|
|||
)
|
||||
}
|
||||
|
||||
function MapTypeSwitcher({ icon, text, type, currentMapType, setMapType }: {
|
||||
icon: string;
|
||||
text: string;
|
||||
type: MapType;
|
||||
currentMapType: MapType;
|
||||
setMapType: (type: MapType) => void;
|
||||
}) {
|
||||
return (
|
||||
<ActionButton
|
||||
icon={icon} text={text}
|
||||
disabled={currentMapType === type}
|
||||
onClick={() => setMapType(type)}
|
||||
frame
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function getCssData(container: HTMLElement, styleResolver: HTMLElement): CssData {
|
||||
const containerStyle = window.getComputedStyle(container);
|
||||
const styleResolverStyle = window.getComputedStyle(styleResolver);
|
||||
|
|
Loading…
Add table
Reference in a new issue