diff options
author | Kristóf Marussy <kristof@marussy.com> | 2024-01-03 18:38:22 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2024-01-03 21:14:04 +0100 |
commit | baa28c9d6b6562a54eee0ad726e22d1b8811751b (patch) | |
tree | 76daca5944872f0b21d6cef472c5cb0b393dff8b /subprojects/frontend/src/graph | |
parent | refactor(web): subtler error predicate highlight (diff) | |
download | refinery-baa28c9d6b6562a54eee0ad726e22d1b8811751b.tar.gz refinery-baa28c9d6b6562a54eee0ad726e22d1b8811751b.tar.zst refinery-baa28c9d6b6562a54eee0ad726e22d1b8811751b.zip |
feat(web): toggle identifier coloring
Diffstat (limited to 'subprojects/frontend/src/graph')
-rw-r--r-- | subprojects/frontend/src/graph/DotGraphVisualizer.tsx | 4 | ||||
-rw-r--r-- | subprojects/frontend/src/graph/GraphStore.ts | 12 | ||||
-rw-r--r-- | subprojects/frontend/src/graph/GraphTheme.tsx | 9 |
3 files changed, 17 insertions, 8 deletions
diff --git a/subprojects/frontend/src/graph/DotGraphVisualizer.tsx b/subprojects/frontend/src/graph/DotGraphVisualizer.tsx index eec72a7d..72ac58fa 100644 --- a/subprojects/frontend/src/graph/DotGraphVisualizer.tsx +++ b/subprojects/frontend/src/graph/DotGraphVisualizer.tsx | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2023-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
@@ -150,7 +150,7 @@ function DotGraphVisualizer({ | |||
150 | ], | 150 | ], |
151 | ); | 151 | ); |
152 | 152 | ||
153 | return <GraphTheme ref={setElement} />; | 153 | return <GraphTheme ref={setElement} colorNodes={graph.colorNodes} />; |
154 | } | 154 | } |
155 | 155 | ||
156 | DotGraphVisualizer.defaultProps = { | 156 | DotGraphVisualizer.defaultProps = { |
diff --git a/subprojects/frontend/src/graph/GraphStore.ts b/subprojects/frontend/src/graph/GraphStore.ts index ecb016b5..58c4422d 100644 --- a/subprojects/frontend/src/graph/GraphStore.ts +++ b/subprojects/frontend/src/graph/GraphStore.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2023-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | import { makeAutoObservable, observable } from 'mobx'; | 7 | import { makeAutoObservable, observable } from 'mobx'; |
8 | 8 | ||
9 | import type EditorStore from '../editor/EditorStore'; | ||
9 | import type { | 10 | import type { |
10 | RelationMetadata, | 11 | RelationMetadata, |
11 | SemanticsSuccessResult, | 12 | SemanticsSuccessResult, |
@@ -65,8 +66,9 @@ export default class GraphStore { | |||
65 | 66 | ||
66 | selectedSymbol: RelationMetadata | undefined; | 67 | selectedSymbol: RelationMetadata | undefined; |
67 | 68 | ||
68 | constructor() { | 69 | constructor(private readonly editorStore: EditorStore) { |
69 | makeAutoObservable(this, { | 70 | makeAutoObservable<GraphStore, 'editorStore'>(this, { |
71 | editorStore: false, | ||
70 | semantics: observable.ref, | 72 | semantics: observable.ref, |
71 | }); | 73 | }); |
72 | } | 74 | } |
@@ -184,4 +186,8 @@ export default class GraphStore { | |||
184 | }); | 186 | }); |
185 | this.setSelectedSymbol(this.selectedSymbol); | 187 | this.setSelectedSymbol(this.selectedSymbol); |
186 | } | 188 | } |
189 | |||
190 | get colorNodes(): boolean { | ||
191 | return this.editorStore.colorIdentifiers; | ||
192 | } | ||
187 | } | 193 | } |
diff --git a/subprojects/frontend/src/graph/GraphTheme.tsx b/subprojects/frontend/src/graph/GraphTheme.tsx index 60fd7925..7334f559 100644 --- a/subprojects/frontend/src/graph/GraphTheme.tsx +++ b/subprojects/frontend/src/graph/GraphTheme.tsx | |||
@@ -37,7 +37,10 @@ function createEdgeColor( | |||
37 | }; | 37 | }; |
38 | } | 38 | } |
39 | 39 | ||
40 | function createTypeHashStyles(theme: Theme): CSSObject { | 40 | function createTypeHashStyles(theme: Theme, colorNodes: boolean): CSSObject { |
41 | if (!colorNodes) { | ||
42 | return {}; | ||
43 | } | ||
41 | const result: CSSObject = {}; | 44 | const result: CSSObject = {}; |
42 | range(theme.palette.highlight.typeHash.length).forEach((i) => { | 45 | range(theme.palette.highlight.typeHash.length).forEach((i) => { |
43 | result[`.node-typeHash-${i}`] = { | 46 | result[`.node-typeHash-${i}`] = { |
@@ -51,7 +54,7 @@ function createTypeHashStyles(theme: Theme): CSSObject { | |||
51 | 54 | ||
52 | export default styled('div', { | 55 | export default styled('div', { |
53 | name: 'GraphTheme', | 56 | name: 'GraphTheme', |
54 | })(({ theme }) => ({ | 57 | })<{ colorNodes: boolean }>(({ theme, colorNodes }) => ({ |
55 | '& svg': { | 58 | '& svg': { |
56 | userSelect: 'none', | 59 | userSelect: 'none', |
57 | '.node': { | 60 | '.node': { |
@@ -86,7 +89,7 @@ export default styled('div', { | |||
86 | '.node-exists-UNKNOWN [stroke="black"]': { | 89 | '.node-exists-UNKNOWN [stroke="black"]': { |
87 | strokeDasharray: '5 2', | 90 | strokeDasharray: '5 2', |
88 | }, | 91 | }, |
89 | ...createTypeHashStyles(theme), | 92 | ...createTypeHashStyles(theme, colorNodes), |
90 | '.edge': { | 93 | '.edge': { |
91 | '& text': { | 94 | '& text': { |
92 | fontFamily: theme.typography.fontFamily, | 95 | fontFamily: theme.typography.fontFamily, |