Skip to content

Commit dd8a416

Browse files
authored
Hide spectrogram controls in modals (#260)
* Make icons similar sizes visually * Make modal component for other user annotations * Made modal component for color scheme selection
1 parent c6f0a03 commit dd8a416

File tree

3 files changed

+199
-96
lines changed

3 files changed

+199
-96
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<script setup lang="ts">
2+
import { onMounted, watch } from 'vue';
3+
import useState from '@use/useState';
4+
import ColorSchemeSelect from './ColorSchemeSelect.vue';
5+
import ColorPickerMenu from './ColorPickerMenu.vue';
6+
7+
const {
8+
configuration,
9+
colorSchemes,
10+
colorScheme,
11+
backgroundColor,
12+
} = useState();
13+
14+
onMounted(() => {
15+
const localBackgroundColor = localStorage.getItem('spectrogramBackgroundColor');
16+
if (localBackgroundColor) {
17+
backgroundColor.value = localBackgroundColor;
18+
} else {
19+
backgroundColor.value = configuration.value.default_spectrogram_background_color || 'rgb(0, 0, 0)';
20+
}
21+
const localColorScheme = localStorage.getItem('spectrogramColorScheme');
22+
if (localColorScheme) {
23+
colorScheme.value = colorSchemes.find((scheme) => scheme.value === localColorScheme) || colorSchemes[0];
24+
} else if (configuration.value.default_color_scheme) {
25+
colorScheme.value = colorSchemes.find((scheme) => scheme.value === configuration.value.default_color_scheme) || colorSchemes[0];
26+
}
27+
});
28+
29+
watch(backgroundColor, () => {
30+
localStorage.setItem('spectrogramBackgroundColor', backgroundColor.value);
31+
});
32+
watch(colorScheme, () => {
33+
localStorage.setItem('spectrogramColorScheme', colorScheme.value.value);
34+
});
35+
</script>
36+
37+
<template>
38+
<v-dialog max-width="300">
39+
<template #activator="{ props: modalProps }">
40+
<v-tooltip>
41+
<template #activator="{ props: tooltipProps }">
42+
<v-icon
43+
v-bind="{ ...modalProps, ...tooltipProps }"
44+
size="25"
45+
>
46+
mdi-palette
47+
</v-icon>
48+
</template>
49+
View spectrogram color options
50+
</v-tooltip>
51+
</template>
52+
<template #default="{ isActive }">
53+
<v-card>
54+
<v-card-title>
55+
Spectrogram Color Options
56+
</v-card-title>
57+
<v-card-text>
58+
<v-row>
59+
<v-col cols="8">
60+
<color-scheme-select
61+
v-model="colorScheme"
62+
label="Color Scheme"
63+
:color-schemes="colorSchemes"
64+
class="pt-3"
65+
/>
66+
</v-col>
67+
<v-col cols="4">
68+
<color-picker-menu
69+
v-model="backgroundColor"
70+
tooltip-text="Spectrogram background color"
71+
/>
72+
</v-col>
73+
</v-row>
74+
</v-card-text>
75+
<v-card-actions>
76+
<v-btn
77+
text="Close"
78+
@click="isActive.value = false"
79+
/>
80+
</v-card-actions>
81+
</v-card>
82+
</template>
83+
</v-dialog>
84+
</template>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<script setup lang="ts">
2+
import { ref, Ref, watch } from 'vue';
3+
import { ScaleOrdinal } from 'd3';
4+
import useState from '@use/useState';
5+
6+
const props = defineProps<{
7+
colorScale: ScaleOrdinal<string, string, never>,
8+
otherUsers: string[],
9+
userEmails: string[],
10+
}>();
11+
const { createColorScale, setSelectedUsers } = useState();
12+
13+
const colorScale = props.colorScale ?? createColorScale(props.userEmails);
14+
15+
const selectedUsers: Ref<string[]> = ref([]);
16+
17+
const deleteChip = (item: string) => {
18+
const newSelectedUsers = selectedUsers.value.filter((user: string) => user !== item);
19+
selectedUsers.value = newSelectedUsers;
20+
setSelectedUsers(selectedUsers.value);
21+
};
22+
23+
watch(selectedUsers, () => {
24+
setSelectedUsers(selectedUsers.value);
25+
});
26+
</script>
27+
28+
<template>
29+
<v-dialog max-width="500">
30+
<template #activator="{ props: modalProps }">
31+
<v-tooltip>
32+
<template #activator="{ props: tooltipProps }">
33+
<v-icon
34+
v-bind="{ ...modalProps, ...tooltipProps }"
35+
size="25"
36+
:color="selectedUsers.length === 0 ? '' : 'blue'"
37+
>
38+
mdi-account-group
39+
</v-icon>
40+
</template>
41+
Select users to display their annotations
42+
</v-tooltip>
43+
</template>
44+
<template #default="{ isActive }">
45+
<v-card>
46+
<v-card-title>
47+
Other Users
48+
</v-card-title>
49+
<v-card-text>
50+
<v-select
51+
v-model="selectedUsers"
52+
:items="otherUsers"
53+
density="compact"
54+
label="Other Users"
55+
multiple
56+
single-line
57+
clearable
58+
variant="outlined"
59+
closable-chips
60+
hide-details
61+
>
62+
<template #selection="{ item }">
63+
<v-chip
64+
closable
65+
size="x-small"
66+
:color="colorScale(item.value)"
67+
text-color="gray"
68+
@click:close="deleteChip(item.value)"
69+
>
70+
{{ item.value.replace(/@.*/, "") }}
71+
</v-chip>
72+
</template>
73+
</v-select>
74+
</v-card-text>
75+
<v-card-actions>
76+
<v-btn
77+
text="Close"
78+
@click="isActive.value = false"
79+
/>
80+
</v-card-actions>
81+
</v-card>
82+
</template>
83+
</v-dialog>
84+
</template>

0 commit comments

Comments
 (0)