diff options
author | dinhanhtruong <70963346+dinhanhtruong@users.noreply.github.com> | 2021-08-23 15:48:47 -0400 |
---|---|---|
committer | dinhanhtruong <70963346+dinhanhtruong@users.noreply.github.com> | 2021-08-23 15:48:47 -0400 |
commit | 9b0a043eeb272c69c1aac07c5a4df409f09400b7 (patch) | |
tree | f355e03faa49d960435e278f20c6830d07af2b7d | |
parent | f75810f3466fcbd2449bc5006316fea4865c2cd9 (diff) |
matched link group header background to color of relationship
-rw-r--r-- | src/client/views/linking/LinkEditor.tsx | 1 | ||||
-rw-r--r-- | src/client/views/linking/LinkMenuGroup.tsx | 21 | ||||
-rw-r--r-- | src/client/views/linking/LinkRelationshipSearch.tsx | 1 |
3 files changed, 19 insertions, 4 deletions
diff --git a/src/client/views/linking/LinkEditor.tsx b/src/client/views/linking/LinkEditor.tsx index 2d6a6942b..fba95cad2 100644 --- a/src/client/views/linking/LinkEditor.tsx +++ b/src/client/views/linking/LinkEditor.tsx @@ -115,7 +115,6 @@ export class LinkEditor extends React.Component<LinkEditorProps> { } toggleSearchIsActive = () => { this.searchIsActive = !this.searchIsActive; - console.log("toggle search to " + this.searchIsActive) } @action diff --git a/src/client/views/linking/LinkMenuGroup.tsx b/src/client/views/linking/LinkMenuGroup.tsx index c7586a467..cb6571f92 100644 --- a/src/client/views/linking/LinkMenuGroup.tsx +++ b/src/client/views/linking/LinkMenuGroup.tsx @@ -1,5 +1,5 @@ import { observer } from "mobx-react"; -import { Doc } from "../../../fields/Doc"; +import { Doc, StrListCast } from "../../../fields/Doc"; import { Id } from "../../../fields/FieldSymbols"; import { Cast } from "../../../fields/Types"; import { LinkManager } from "../../util/LinkManager"; @@ -20,6 +20,23 @@ interface LinkMenuGroupProps { export class LinkMenuGroup extends React.Component<LinkMenuGroupProps> { private _menuRef = React.createRef<HTMLDivElement>(); + getBackgroundColor = (): string => { + const linkRelationshipList = StrListCast(Doc.UserDoc().linkRelationshipList); + const linkColorList = StrListCast(Doc.UserDoc().linkColorList); + let color = "white"; + // if this link's relationship property is not default "link", set its color + if (linkRelationshipList) { + const relationshipIndex = linkRelationshipList.indexOf(this.props.groupType); + const RGBcolor: string = linkColorList[relationshipIndex]; + if (RGBcolor) { + //set opacity to 0.25 by modifiying the rgb string + color = RGBcolor.slice(0, RGBcolor.length - 1) + ", 0.25)"; + console.log(color); + } + } + return color; + } + render() { const set = new Set<Doc>(this.props.group); const groupItems = Array.from(set.keys()).map(linkDoc => { @@ -39,7 +56,7 @@ export class LinkMenuGroup extends React.Component<LinkMenuGroupProps> { return ( <div className="linkMenu-group" ref={this._menuRef}> - <div className="linkMenu-group-name"> + <div className="linkMenu-group-name" style={{ background: this.getBackgroundColor() }}> <p className={this.props.groupType === "*" || this.props.groupType === "" ? "" : "expand-one"}> {this.props.groupType}:</p> </div> <div className="linkMenu-group-wrapper"> diff --git a/src/client/views/linking/LinkRelationshipSearch.tsx b/src/client/views/linking/LinkRelationshipSearch.tsx index bb128f746..8f83f0e6e 100644 --- a/src/client/views/linking/LinkRelationshipSearch.tsx +++ b/src/client/views/linking/LinkRelationshipSearch.tsx @@ -13,7 +13,6 @@ interface LinkRelationshipSearchProps { export class LinkRelationshipSearch extends React.Component<LinkRelationshipSearchProps> { handleResultClick = (e: React.MouseEvent) => { - console.log("click"); const relationship = (e.target as HTMLParagraphElement).textContent; if (relationship) { this.props.handleRelationshipSearchChange(relationship) |