Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
75 changes: 73 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,28 @@
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,
Tag,

Check warning on line 15 in apps/roam/src/components/settings/NodeConfig.tsx

View workflow job for this annotation

GitHub Actions / eslint (apps/roam)

[eslint (apps/roam)] apps/roam/src/components/settings/NodeConfig.tsx#L15

'Tag' is defined but never used @typescript-eslint/no-unused-vars
Raw output
  15:3  warning  'Tag' is defined but never used  @typescript-eslint/no-unused-vars
} 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 +85,18 @@
key: "Attributes",
});

const canvasTree = useMemo(
() => getBasicTreeByParentUid(canvasUid),
[canvasUid],
);
const [color, setColor] = useState<string>(() => {
const colorValue = getSettingValueFromTree({
tree: canvasTree,
key: "color",
});
return formatHexColor(colorValue);
});

Comment thread
trangdoan982 marked this conversation as resolved.
Outdated
const [selectedTabId, setSelectedTabId] = useState<TabId>("general");
const [tagError, setTagError] = useState("");
const [formatError, setFormatError] = useState("");
Expand Down Expand Up @@ -180,7 +207,51 @@
order={2}
parentUid={node.type}
uid={tagUid}
inputStyle={color ? { color } : undefined}
Comment thread
trangdoan982 marked this conversation as resolved.
Outdated
/>
<div>
Comment thread
trangdoan982 marked this conversation as resolved.
Outdated
<Label style={{ marginBottom: "4px" }}>Color</Label>
Comment thread
trangdoan982 marked this conversation as resolved.
Outdated
<ControlGroup>
Comment thread
trangdoan982 marked this conversation as resolved.
Outdated
<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