-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathColorSchemeDialog.vue
More file actions
99 lines (94 loc) · 2.85 KB
/
ColorSchemeDialog.vue
File metadata and controls
99 lines (94 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<script setup lang="ts">
import { onMounted, watch, PropType } from 'vue';
import useState from '@use/useState';
import ColorSchemeSelect from './ColorSchemeSelect.vue';
import ColorPickerMenu from './ColorPickerMenu.vue';
const {
configuration,
colorSchemes,
colorScheme,
backgroundColor,
} = useState();
defineProps({
displayMode: {
type: String as PropType<'dialog' | 'menu'>,
default: 'dialog',
},
});
onMounted(() => {
const localBackgroundColor = localStorage.getItem('spectrogramBackgroundColor');
if (localBackgroundColor) {
backgroundColor.value = localBackgroundColor;
} else {
backgroundColor.value = configuration.value.default_spectrogram_background_color || 'rgb(0, 0, 0)';
}
const localColorScheme = localStorage.getItem('spectrogramColorScheme');
if (localColorScheme) {
colorScheme.value = colorSchemes.find((scheme) => scheme.value === localColorScheme) || colorSchemes[0];
} else if (configuration.value.default_color_scheme) {
colorScheme.value = colorSchemes.find((scheme) => scheme.value === configuration.value.default_color_scheme) || colorSchemes[0];
}
});
watch(backgroundColor, () => {
localStorage.setItem('spectrogramBackgroundColor', backgroundColor.value);
});
watch(colorScheme, () => {
localStorage.setItem('spectrogramColorScheme', colorScheme.value.value);
});
</script>
<template>
<v-dialog max-width="300">
<template #activator="{ props: modalProps }">
<v-tooltip>
<template #activator="{ props: tooltipProps }">
<v-icon
v-if="displayMode === 'dialog'"
v-bind="{ ...modalProps, ...tooltipProps }"
size="30"
>
mdi-palette
</v-icon>
<span
v-else
v-bind="{ ...modalProps, ...tooltipProps }"
>
<v-icon size="30">mdi-palette</v-icon>
<span>Change Color Scheme</span>
</span>
</template>
View spectrogram color options
</v-tooltip>
</template>
<template #default="{ isActive }">
<v-card>
<v-card-title>
Spectrogram Color Options
</v-card-title>
<v-card-text>
<v-row>
<v-col cols="8">
<color-scheme-select
v-model="colorScheme"
label="Color Scheme"
:color-schemes="colorSchemes"
class="pt-3"
/>
</v-col>
<v-col cols="4">
<color-picker-menu
v-model="backgroundColor"
tooltip-text="Spectrogram background color"
/>
</v-col>
</v-row>
</v-card-text>
<v-card-actions>
<v-btn
text="Close"
@click="isActive.value = false"
/>
</v-card-actions>
</v-card>
</template>
</v-dialog>
</template>