From c50a8c06b617c170a725a4691af36cb07501691b Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 18 Oct 2023 07:13:21 +0200 Subject: [PATCH] use Enum for up/down settings --- src/stores/colors.ts | 11 +++++++++-- src/views/SettingsView.vue | 7 ++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/stores/colors.ts b/src/stores/colors.ts index 4ef7779c..2c0dc32d 100644 --- a/src/stores/colors.ts +++ b/src/stores/colors.ts @@ -2,11 +2,16 @@ import { defineStore } from 'pinia'; const STORE_UI_COLORS = 'ftUIColorSettings'; +export enum ColorPreferences { + GREEN_UP = 'greenUp', + RED_UP = 'redUp', +} + export const useColorStore = defineStore('colorStore', { // other options... state: () => { return { - colorPreference: 'greenUp', + colorPreference: ColorPreferences.GREEN_UP, colorUp: '#26A69A', colorDown: '#EF5350', colorProfit: '#26A69A', //12bb7b @@ -17,7 +22,9 @@ export const useColorStore = defineStore('colorStore', { actions: { updateProfitLossColor() { const [colorUp, colorDown] = - this.colorPreference === 'greenUp' ? ['#26A69A', '#ef5350'] : ['#ef5350', '#26A69A']; + this.colorPreference === ColorPreferences.GREEN_UP + ? ['#26A69A', '#ef5350'] + : ['#ef5350', '#26A69A']; this.colorUp = colorUp; this.colorDown = colorDown; }, diff --git a/src/views/SettingsView.vue b/src/views/SettingsView.vue index bd3e7066..d7e7db28 100644 --- a/src/views/SettingsView.vue +++ b/src/views/SettingsView.vue @@ -17,6 +17,7 @@ v-model="colorStore.colorPreference" :options="colorPreferenceOptions" name="color-preference-options" + @change="colorStore.updateProfitLossColor" >