forked from FreeTubeApp/FreeTube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme-settings.js
188 lines (166 loc) · 5.6 KB
/
theme-settings.js
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import { defineComponent } from 'vue'
import { mapActions } from 'vuex'
import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtSelect from '../ft-select/ft-select.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
import FtSlider from '../ft-slider/ft-slider.vue'
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
import FtPrompt from '../ft-prompt/ft-prompt.vue'
import { colors, getColorTranslations } from '../../helpers/colors'
import { IpcChannels } from '../../../constants'
export default defineComponent({
name: 'ThemeSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-select': FtSelect,
'ft-toggle-switch': FtToggleSwitch,
'ft-slider': FtSlider,
'ft-flex-box': FtFlexBox,
'ft-prompt': FtPrompt
},
data: function () {
return {
usingElectron: process.env.IS_ELECTRON,
minUiScale: 50,
maxUiScale: 300,
uiScaleStep: 5,
disableSmoothScrollingToggleValue: false,
showRestartPrompt: false,
restartPromptValues: [
'restart',
'cancel'
],
/* Themes are devided into 3 groups. The first group contains the default themes. The second group are themes that don't have specific primary and secondary colors. The third group are themes that do have specific primary and secondary colors available. */
baseThemeValues: [
// First group
'system',
'light',
'dark',
'black',
// Second group
'nordic',
'hotPink',
'pastelPink',
// Third group
'catppuccinMocha',
'dracula',
'gruvboxDark',
'gruvboxLight',
'solarizedDark',
'solarizedLight'
]
}
},
computed: {
barColor: function () {
return this.$store.getters.getBarColor
},
baseTheme: function () {
return this.$store.getters.getBaseTheme
},
mainColor: function () {
return this.$store.getters.getMainColor
},
secColor: function () {
return this.$store.getters.getSecColor
},
isSideNavOpen: function () {
return this.$store.getters.getIsSideNavOpen
},
uiScale: function () {
return this.$store.getters.getUiScale
},
disableSmoothScrolling: function () {
return this.$store.getters.getDisableSmoothScrolling
},
expandSideBar: function () {
return this.$store.getters.getExpandSideBar
},
hideLabelsSideBar: function () {
return this.$store.getters.getHideLabelsSideBar
},
hideHeaderLogo: function () {
return this.$store.getters.getHideHeaderLogo
},
restartPromptMessage: function () {
return this.$t('Settings["The app needs to restart for changes to take effect. Restart and apply change?"]')
},
restartPromptNames: function () {
return [
this.$t('Yes, Restart'),
this.$t('Cancel')
]
},
/* Themes are devided into 3 groups. The first group contains the default themes. The second group are themes that don't have specific primary and secondary colors. The third group are themes that do have specific primary and secondary colors available. */
baseThemeNames: function () {
return [
// First group
this.$t('Settings.Theme Settings.Base Theme.System Default'),
this.$t('Settings.Theme Settings.Base Theme.Light'),
this.$t('Settings.Theme Settings.Base Theme.Dark'),
this.$t('Settings.Theme Settings.Base Theme.Black'),
// Second group
this.$t('Settings.Theme Settings.Base Theme.Nordic'),
this.$t('Settings.Theme Settings.Base Theme.Hot Pink'),
this.$t('Settings.Theme Settings.Base Theme.Pastel Pink'),
// Third group
this.$t('Settings.Theme Settings.Base Theme.Catppuccin Mocha'),
this.$t('Settings.Theme Settings.Base Theme.Dracula'),
this.$t('Settings.Theme Settings.Base Theme.Gruvbox Dark'),
this.$t('Settings.Theme Settings.Base Theme.Gruvbox Light'),
this.$t('Settings.Theme Settings.Base Theme.Solarized Dark'),
this.$t('Settings.Theme Settings.Base Theme.Solarized Light')
]
},
colorValues: function () {
return colors.map(color => color.name)
},
colorNames: function () {
return getColorTranslations()
},
areColorThemesEnabled: function() {
return this.baseTheme !== 'hotPink'
}
},
created: function () {
this.disableSmoothScrollingToggleValue = this.disableSmoothScrolling
},
methods: {
handleExpandSideBar: function (value) {
if (this.isSideNavOpen !== value) {
this.$store.commit('toggleSideNav')
}
this.updateExpandSideBar(value)
},
handleRestartPrompt: function (value) {
this.disableSmoothScrollingToggleValue = value
this.showRestartPrompt = true
},
handleSmoothScrolling: function (value) {
this.showRestartPrompt = false
if (value === null || value === 'cancel') {
this.disableSmoothScrollingToggleValue = !this.disableSmoothScrollingToggleValue
return
}
if (process.env.IS_ELECTRON) {
this.updateDisableSmoothScrolling(
this.disableSmoothScrollingToggleValue
).then(() => {
const { ipcRenderer } = require('electron')
ipcRenderer.send(IpcChannels.RELAUNCH_REQUEST)
})
}
},
...mapActions([
'updateBarColor',
'updateBaseTheme',
'updateMainColor',
'updateSecColor',
'updateExpandSideBar',
'updateUiScale',
'updateDisableSmoothScrolling',
'updateHideLabelsSideBar',
'updateHideHeaderLogo'
])
}
})