-
Notifications
You must be signed in to change notification settings - Fork 4
ENG-739 Move color selector from Canvas to General tab #945
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -3,13 +3,27 @@ import { DiscourseNode } from "~/utils/getDiscourseNodes"; | |
| import DualWriteBlocksPanel from "./components/EphemeralBlocksPanel"; | ||
| import { getSubTree } from "roamjs-components/util"; | ||
| import Description from "roamjs-components/components/Description"; | ||
| import { Label, Tabs, Tab, TabId } from "@blueprintjs/core"; | ||
| import { | ||
| Label, | ||
| Tabs, | ||
| Tab, | ||
| TabId, | ||
| InputGroup, | ||
| ControlGroup, | ||
| Tooltip, | ||
| Icon, | ||
| } from "@blueprintjs/core"; | ||
| import DiscourseNodeSpecification from "./DiscourseNodeSpecification"; | ||
| import DiscourseNodeAttributes from "./DiscourseNodeAttributes"; | ||
| import DiscourseNodeCanvasSettings from "./DiscourseNodeCanvasSettings"; | ||
| import DiscourseNodeCanvasSettings, { | ||
| formatHexColor, | ||
| } from "./DiscourseNodeCanvasSettings"; | ||
| import DiscourseNodeIndex from "./DiscourseNodeIndex"; | ||
| import { OnloadArgs } from "roamjs-components/types"; | ||
| import getBasicTreeByParentUid from "roamjs-components/queries/getBasicTreeByParentUid"; | ||
| import getSettingValueFromTree from "roamjs-components/util/getSettingValueFromTree"; | ||
| import setInputSetting from "roamjs-components/util/setInputSetting"; | ||
| import { setDiscourseNodeSetting } from "~/components/settings/utils/accessors"; | ||
| import DiscourseNodeSuggestiveRules from "./DiscourseNodeSuggestiveRules"; | ||
| import { getFormattedConfigTree } from "~/utils/discourseConfigRef"; | ||
| import refreshConfigTree from "~/utils/refreshConfigTree"; | ||
|
|
@@ -70,6 +84,18 @@ const NodeConfig = ({ | |
| key: "Attributes", | ||
| }); | ||
|
|
||
| const canvasTree = useMemo( | ||
| () => getBasicTreeByParentUid(canvasUid), | ||
| [canvasUid], | ||
| ); | ||
| const [color, setColor] = useState<string>(() => { | ||
| const colorValue = getSettingValueFromTree({ | ||
| tree: canvasTree, | ||
| key: "color", | ||
| }); | ||
| return formatHexColor(colorValue); | ||
| }); | ||
|
|
||
| const [selectedTabId, setSelectedTabId] = useState<TabId>("general"); | ||
| const [tagError, setTagError] = useState(""); | ||
| const [formatError, setFormatError] = useState(""); | ||
|
|
@@ -180,7 +206,51 @@ const NodeConfig = ({ | |
| order={2} | ||
| parentUid={node.type} | ||
| uid={tagUid} | ||
| inputStyle={color ? { color } : undefined} | ||
| /> | ||
| <div> | ||
|
Member
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. If we no longer need the 4px bottom margin, change this to |
||
| <Label style={{ marginBottom: "4px" }}>Color</Label> | ||
|
Member
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. Wrap and remove the |
||
| <ControlGroup> | ||
|
Member
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. Add ToolTip after |
||
| <InputGroup | ||
| style={{ width: 120 }} | ||
| type={"color"} | ||
| value={color} | ||
| onChange={(e) => { | ||
| const colorValue = e.target.value.replace("#", ""); // remove hash to not create roam link | ||
| setColor(e.target.value); | ||
| void setInputSetting({ | ||
| blockUid: canvasUid, | ||
| key: "color", | ||
| value: colorValue, | ||
| }); | ||
| setDiscourseNodeSetting( | ||
| node.type, | ||
| ["canvasSettings", "color"], | ||
| colorValue, | ||
| ); | ||
| }} | ||
| /> | ||
| <Tooltip content={color ? "Unset" : "Color not set"}> | ||
| <Icon | ||
| className={"ml-2 align-middle opacity-80"} | ||
| icon={color ? "delete" : "info-sign"} | ||
| onClick={() => { | ||
| setColor(""); | ||
| void setInputSetting({ | ||
| blockUid: canvasUid, | ||
| key: "color", | ||
| value: "", | ||
| }); | ||
| setDiscourseNodeSetting( | ||
| node.type, | ||
| ["canvasSettings", "color"], | ||
| "", | ||
| ); | ||
| }} | ||
| /> | ||
| </Tooltip> | ||
| </ControlGroup> | ||
| </div> | ||
| </div> | ||
| } | ||
| /> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When set to white (or dark if user has a dark theme), the text would be not visible. So let's revert this in favor of ENG-906: Add node tag below tag input in setting (which is out of scope for this PR)