-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16612 from ElectronicBlueberry/workflow-annotations
Workflow Comments 💬
- Loading branch information
Showing
50 changed files
with
4,133 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
client/src/components/Workflow/Editor/Comments/ColourSelector.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { mount } from "@vue/test-utils"; | ||
import { nextTick } from "vue"; | ||
|
||
import { colours } from "./colours"; | ||
|
||
import ColourSelector from "./ColourSelector.vue"; | ||
|
||
describe("ColourSelector", () => { | ||
it("shows a button for each colour and 'none'", () => { | ||
const wrapper = mount(ColourSelector, { propsData: { colour: "none" } }); | ||
const buttons = wrapper.findAll("button"); | ||
expect(buttons.length).toBe(Object.keys(colours).length + 1); | ||
}); | ||
|
||
it("highlights the selected colour", async () => { | ||
const wrapper = mount(ColourSelector, { propsData: { colour: "none" } }); | ||
const allSelected = wrapper.findAll(".selected"); | ||
expect(allSelected.length).toBe(1); | ||
|
||
let selected = allSelected.wrappers[0]; | ||
expect(selected.element.getAttribute("title")).toBe("No Colour"); | ||
|
||
const colourNames = Object.keys(colours); | ||
|
||
for (let i = 0; i < colourNames.length; i++) { | ||
const colour = colourNames[i]; | ||
wrapper.setProps({ colour }); | ||
await nextTick(); | ||
|
||
selected = wrapper.find(".selected"); | ||
|
||
expect(selected.element.getAttribute("title")).toContain(colour); | ||
} | ||
}); | ||
|
||
it("emits the set colour", async () => { | ||
const wrapper = mount(ColourSelector, { propsData: { colour: "none" } }); | ||
|
||
const colourNames = Object.keys(colours); | ||
|
||
for (let i = 0; i < colourNames.length; i++) { | ||
const colour = colourNames[i]; | ||
await wrapper.find(`[title="Colour ${colour}"]`).trigger("click"); | ||
expect(wrapper.emitted()["set-colour"][i][0]).toBe(colour); | ||
} | ||
}); | ||
}); |
100 changes: 100 additions & 0 deletions
100
client/src/components/Workflow/Editor/Comments/ColourSelector.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<script setup lang="ts"> | ||
import type { WorkflowCommentColour } from "@/stores/workflowEditorCommentStore"; | ||
import { brightColours, colours } from "./colours"; | ||
const props = defineProps<{ | ||
colour: WorkflowCommentColour; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(e: "set-colour", colour: WorkflowCommentColour): void; | ||
}>(); | ||
function onClickColour(colour: WorkflowCommentColour) { | ||
emit("set-colour", colour); | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="comment-colour-selector"> | ||
<button | ||
class="colour-button prevent-zoom" | ||
title="No Colour" | ||
data-colour="none" | ||
:class="{ selected: props.colour === 'none' }" | ||
@click="() => onClickColour('none')"></button> | ||
<button | ||
v-for="(hex, name) in colours" | ||
:key="name" | ||
class="colour-button prevent-zoom" | ||
:data-colour="name" | ||
:title="`Colour ${name}`" | ||
:class="{ selected: props.colour === name }" | ||
:style="{ | ||
'--colour': hex, | ||
'--colour-bright': brightColours[name], | ||
}" | ||
@click="() => onClickColour(name)"></button> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
@import "theme/blue.scss"; | ||
.comment-colour-selector { | ||
position: absolute; | ||
z-index: 10000; | ||
display: grid; | ||
grid-template-rows: 1rem 1rem; | ||
grid-template-columns: repeat(5, 1rem); | ||
grid-auto-flow: column; | ||
overflow: hidden; | ||
border-radius: 0.25rem; | ||
.colour-button { | ||
--colour: #{$brand-primary}; | ||
--colour-bright: #{$brand-secondary}; | ||
background-color: var(--colour); | ||
border-color: var(--colour-bright); | ||
border-width: 0; | ||
border-radius: 0; | ||
padding: 0; | ||
width: 100%; | ||
height: 100%; | ||
display: grid; | ||
place-items: center; | ||
transition: none; | ||
&:hover { | ||
background-color: var(--colour-bright); | ||
} | ||
&:focus, | ||
&:focus-visible { | ||
border-color: var(--colour-bright); | ||
border-width: 2px; | ||
box-shadow: none; | ||
} | ||
&.selected::after { | ||
content: ""; | ||
display: block; | ||
width: 50%; | ||
height: 50%; | ||
border-radius: 50%; | ||
background-color: var(--colour-bright); | ||
} | ||
&.selected:hover::after { | ||
background-color: var(--colour); | ||
} | ||
} | ||
} | ||
</style> |
Oops, something went wrong.