diff --git a/apps/client/src/widgets/note_map.ts b/apps/client/src/widgets/note_map.ts index d0274fc86..6259157c6 100644 --- a/apps/client/src/widgets/note_map.ts +++ b/apps/client/src/widgets/note_map.ts @@ -13,85 +13,18 @@ import type FNote from "../entities/fnote.js"; const esc = utils.escapeHtml; const TPL = /*html*/`
`; @@ -148,12 +81,6 @@ interface GroupedLink { names: string[]; } -interface CssData { - fontFamily: string; - textColor: string; - mutedTextColor: string; -} - export default class NoteMapWidget extends NoteContextAwareWidget { private fixNodes: boolean; @@ -220,12 +147,6 @@ export default class NoteMapWidget extends NoteContextAwareWidget { async refreshWithNote(note: FNote) { this.$widget.show(); - this.cssData = { - fontFamily: this.$container.css("font-family"), - textColor: this.rgb2hex(this.$container.css("color")), - mutedTextColor: this.rgb2hex(this.$styleResolver.css("color")) - }; - this.mapType = note.getLabelValue("mapType") === "tree" ? "tree" : "link"; //variables for the hover effekt. We have to save the neighbours of a hovered node in a set. Also we need to save the links as well as the hovered node itself @@ -397,13 +318,6 @@ export default class NoteMapWidget extends NoteContextAwareWidget { return color; } - rgb2hex(rgb: string) { - return `#${(rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/) || []) - .slice(1) - .map((n) => parseInt(n, 10).toString(16).padStart(2, "0")) - .join("")}`; - } - setZoomLevel(level: number) { this.zoomLevel = level; } diff --git a/apps/client/src/widgets/note_map/NoteMap.css b/apps/client/src/widgets/note_map/NoteMap.css new file mode 100644 index 000000000..836444883 --- /dev/null +++ b/apps/client/src/widgets/note_map/NoteMap.css @@ -0,0 +1,62 @@ +.note-detail-note-map { + height: 100%; + overflow: hidden; +} + +/* Style Ui Element to Drag Nodes */ +.fixnodes-type-switcher { + display: flex; + align-items: center; + z-index: 10; /* should be below dropdown (note actions) */ + border-radius: .2rem; +} + +.fixnodes-type-switcher button.toggled { + background: var(--active-item-background-color); + color: var(--active-item-text-color); +} + +/* Start of styling the slider */ +.fixnodes-type-switcher input[type="range"] { + + /* removing default appearance */ + -webkit-appearance: none; + appearance: none; + margin-left: 15px; + width: 150px; +} + +/* Changing slider tracker */ +.fixnodes-type-switcher input[type="range"]::-webkit-slider-runnable-track { + height: 4px; + background-color: var(--main-border-color); + border-radius: 4px; +} + +/* Changing Slider Thumb */ +.fixnodes-type-switcher input[type="range"]::-webkit-slider-thumb { + /* removing default appearance */ + -webkit-appearance: none; + appearance: none; + /* creating a custom design */ + height: 15px; + width: 15px; + margin-top:-5px; + background-color: var(--accented-background-color); + border: 1px solid var(--main-text-color); + border-radius: 50%; +} + +.fixnodes-type-switcher input[type="range"]::-moz-range-track { + background-color: var(--main-border-color); + border-radius: 4px; +} + +.fixnodes-type-switcher input[type="range"]::-moz-range-thumb { + background-color: var(--accented-background-color); + border-color: var(--main-text-color); + height: 10px; + width: 10px; +} + +/* End of styling the slider */ \ No newline at end of file diff --git a/apps/client/src/widgets/note_map/NoteMap.tsx b/apps/client/src/widgets/note_map/NoteMap.tsx new file mode 100644 index 000000000..a53893cb3 --- /dev/null +++ b/apps/client/src/widgets/note_map/NoteMap.tsx @@ -0,0 +1,42 @@ +import { useEffect, useRef, useState } from "preact/hooks"; +import "./NoteMap.css"; +import { rgb2hex } from "./utils"; + +interface CssData { + fontFamily: string; + textColor: string; + mutedTextColor: string; +} + +export default function NoteMap() { + const containerRef = useRef