Skip to content

Commit

Permalink
Highlight the selected branch
Browse files Browse the repository at this point in the history
Highlight the selected branch with the same color as the selected node, but more translucent. This should make it more clear to see which branch is selected in large truth trees.
  • Loading branch information
connorjayr committed Mar 17, 2024
1 parent f2be045 commit 82baa68
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions public/css/colors.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
--premise-label: #808080;
--tt-chevron: #000000;
--selected: rgba(51, 153, 255, 0.5);
--selected-branch: rgba(51, 153, 255, 0.15);
--antecedent: rgba(128, 192, 128, 0.5);
--decomposition: rgba(192, 128, 128, 0.5);

Expand Down
4 changes: 4 additions & 0 deletions public/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
color: var(--tt-chevron);
}

.selected-branch {
background-color: var(--selected-branch);
}

.selected {
background-color: var(--selected);
}
Expand Down
1 change: 1 addition & 0 deletions public/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
--premise-label: #ffffff;
--tt-chevron: #ffffff;
--selected: rgba(34, 82, 130, 0.5);
--selected-branch: rgba(34, 82, 130, 0.15);
--antecedent: rgba(81, 130, 81, 0.5);
--decomposition: rgba(192, 128, 128, 0.5);

Expand Down
4 changes: 4 additions & 0 deletions src/client/component/truth-tree-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export const TruthTreeBranchComponent = defineComponent({
selectedNode(): TruthTreeNode | null {
return this.$store.getters.selectedNode;
},
selectedBranch(): Set<number> {
return this.$store.getters.selectedBranch;
},
/**
* Returns the node at the head of this branch.
* @returns the head node of this branch
Expand Down Expand Up @@ -215,6 +218,7 @@ export const TruthTreeBranchComponent = defineComponent({
@click="$store.commit('select', {id: id})"
:class="{
selected: selected === id,
'selected-branch': selectedBranch.has(id),
antecedent:
selectedNode !== null &&
selectedNode.antecedent === id,
Expand Down
9 changes: 9 additions & 0 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,15 @@ export const instance = vue
selectedNode(state) {
return state.tree.getNode(state.selected);
},
selectedBranch(state, getters) {
const selectedBranch: Set<number> = new Set();
let node: TruthTreeNode | null = getters.selectedNode;
while (node !== null) {
selectedBranch.add(node.id);
node = state.tree.getNode(node.parent);
}
return selectedBranch;
}
},
mutations: {
toggleDeveloperMode(state: StoreState) {
Expand Down

0 comments on commit 82baa68

Please sign in to comment.