Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions apps/roam/src/components/settings/DiscourseNodeCanvasSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {
InputGroup,
Label,
Radio,
RadioGroup,
Tooltip,
Icon,
ControlGroup,
} from "@blueprintjs/core";
import React, { useState, useMemo } from "react";
import getBasicTreeByParentUid from "roamjs-components/queries/getBasicTreeByParentUid";
Expand Down Expand Up @@ -37,10 +35,6 @@ const DiscourseNodeCanvasSettings = ({
uid: string;
}) => {
const tree = useMemo(() => getBasicTreeByParentUid(uid), [uid]);
const [color, setColor] = useState<string>(() => {
const color = getSettingValueFromTree({ tree, key: "color" });
return formatHexColor(color);
});
const alias = getSettingValueFromTree({ tree, key: "alias" });
const [queryBuilderAlias, setQueryBuilderAlias] = useState<string>(() =>
getSettingValueFromTree({ tree, key: "query-builder-alias" }),
Expand All @@ -54,49 +48,6 @@ const DiscourseNodeCanvasSettings = ({

return (
<div>
<div className="mb-4">
<Label style={{ marginBottom: "4px" }}>Color picker</Label>
<ControlGroup>
<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: uid,
key: "color",
value: colorValue,
});
setDiscourseNodeSetting(
nodeType,
["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: uid,
key: "color",
value: "",
});
setDiscourseNodeSetting(
nodeType,
["canvasSettings", "color"],
"",
);
}}
/>
</Tooltip>
</ControlGroup>
</div>
<DiscourseNodeTextPanel
nodeType={nodeType}
title="Display alias"
Expand Down
74 changes: 72 additions & 2 deletions apps/roam/src/components/settings/NodeConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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("");
Expand Down Expand Up @@ -180,7 +206,51 @@ const NodeConfig = ({
order={2}
parentUid={node.type}
uid={tagUid}
inputStyle={color ? { color } : undefined}
Copy link
Copy Markdown
Member

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)

/>
<div>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap ControlGroup in Label to match other fields above, ref

and remove the marginBottom: 4px (this covered by blueprint styling of bp3-label)

<ControlGroup>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add ToolTip after Color to match the other fields (which the above components are using Description, see DiscourseNodeTextPanel).
"Changes the color of tags and canvas nodes"

<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>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type BaseTextPanelProps = {
multiline?: boolean;
error?: string;
onChange?: (value: string) => void;
inputStyle?: React.CSSProperties;
} & RoamBlockSyncProps;

type BaseFlagPanelProps = {
Expand Down Expand Up @@ -105,6 +106,7 @@ const BaseTextPanel = ({
multiline,
error,
onChange,
inputStyle,
parentUid,
uid,
order,
Expand Down Expand Up @@ -162,6 +164,7 @@ const BaseTextPanel = ({
value={value}
onChange={handleChange}
placeholder={placeholder || initialValue}
style={inputStyle}
/>
)}
</Label>
Expand Down Expand Up @@ -612,6 +615,7 @@ export const DiscourseNodeTextPanel = ({
multiline?: boolean;
error?: string;
onChange?: (value: string) => void;
inputStyle?: React.CSSProperties;
}) => (
<BaseTextPanel {...props} setter={createDiscourseNodeSetter(nodeType)} />
);
Expand Down
Loading