-
Notifications
You must be signed in to change notification settings - Fork 3
ENG-737 Use Node Color to style Node Tags #414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,14 +44,24 @@ import { | |
| findBlockElementFromSelection, | ||
| } from "~/utils/renderTextSelectionPopup"; | ||
| import { renderNodeTagPopupButton } from "./renderNodeTagPopup"; | ||
| import { formatHexColor } from "~/components/settings/DiscourseNodeCanvasSettings"; | ||
|
|
||
| let discourseNodes: DiscourseNode[] = []; | ||
| let discourseTagSet: Set<string> = new Set(); | ||
| let discourseTagToStyle: Record<string, { color: string }> = {}; | ||
|
|
||
| const refreshDiscourseNodeCache = () => { | ||
| discourseNodes = getDiscourseNodes(); | ||
| discourseTagSet = new Set( | ||
| discourseNodes.flatMap((n) => (n.tag ? [n.tag.toLowerCase()] : [])), | ||
| discourseTagToStyle = discourseNodes.reduce( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should reuse the existing refreshConfigTree. No need to re-invent the wheel 😀 |
||
| (acc, n) => { | ||
| if (n.tag && n.canvasSettings?.color) { | ||
| const color = formatHexColor(n.canvasSettings.color); | ||
| acc[n.tag.toLowerCase()] = { | ||
| color, | ||
| }; | ||
| } | ||
| return acc; | ||
| }, | ||
| {} as Record<string, { color: string }>, | ||
| ); | ||
| }; | ||
|
|
||
|
|
@@ -115,8 +125,12 @@ export const initObservers = async ({ | |
| callback: (s: HTMLSpanElement) => { | ||
| const tag = s.getAttribute("data-tag"); | ||
| if (tag) { | ||
| if (discourseTagSet.has(tag.toLowerCase())) { | ||
| const style = discourseTagToStyle[tag.toLowerCase()]; | ||
| if (style) { | ||
| renderNodeTagPopupButton(s, discourseNodes, onloadArgs.extensionAPI); | ||
| s.style.color = style.color; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we put this color/style directly on the Blueprint button? That way it would all be in one place. Also, we could use tailwind/classes as much as possible so users could adjust the styles themselves.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, my bad. I was thinking of the popover. |
||
| s.style.padding = "2px 4px"; | ||
| s.style.borderRadius = "4px"; | ||
| } | ||
| } | ||
| }, | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.