mirror of
https://github.com/fmhy/edit.git
synced 2025-11-28 00:41:20 +11:00
just revert atp
This commit is contained in:
parent
f99ce02782
commit
94a431f8dd
1 changed files with 2 additions and 33 deletions
|
|
@ -2,7 +2,6 @@
|
||||||
import { colors } from '@fmhy/colors'
|
import { colors } from '@fmhy/colors'
|
||||||
import { useStorage, useStyleTag } from '@vueuse/core'
|
import { useStorage, useStyleTag } from '@vueuse/core'
|
||||||
import { watch } from 'vue'
|
import { watch } from 'vue'
|
||||||
import Switch from './Switch.vue'
|
|
||||||
|
|
||||||
const colorScales = [
|
const colorScales = [
|
||||||
'50',
|
'50',
|
||||||
|
|
@ -20,7 +19,6 @@ const colorScales = [
|
||||||
|
|
||||||
type ColorNames = keyof typeof colors
|
type ColorNames = keyof typeof colors
|
||||||
const selectedColor = useStorage<ColorNames>('preferred-color', 'swarm')
|
const selectedColor = useStorage<ColorNames>('preferred-color', 'swarm')
|
||||||
const isAmoledMode = useStorage('amoled-mode', false)
|
|
||||||
|
|
||||||
const colorOptions = Object.keys(colors).filter(
|
const colorOptions = Object.keys(colors).filter(
|
||||||
(key) => typeof colors[key as keyof typeof colors] === 'object'
|
(key) => typeof colors[key as keyof typeof colors] === 'object'
|
||||||
|
|
@ -28,7 +26,7 @@ const colorOptions = Object.keys(colors).filter(
|
||||||
|
|
||||||
const { css } = useStyleTag('', { id: 'brand-color' })
|
const { css } = useStyleTag('', { id: 'brand-color' })
|
||||||
|
|
||||||
const updateThemeColor = (colorName: ColorNames, amoledEnabled: boolean) => {
|
const updateThemeColor = (colorName: ColorNames) => {
|
||||||
const colorSet = colors[colorName]
|
const colorSet = colors[colorName]
|
||||||
|
|
||||||
const cssVars = colorScales
|
const cssVars = colorScales
|
||||||
|
|
@ -54,35 +52,10 @@ const updateThemeColor = (colorName: ColorNames, amoledEnabled: boolean) => {
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (amoledEnabled) {
|
|
||||||
htmlElement.classList.add('theme-amoled')
|
|
||||||
} else {
|
|
||||||
htmlElement.classList.remove('theme-amoled')
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine dark background color based on AMOLED mode
|
|
||||||
const darkBg = amoledEnabled ? '#000000' : 'rgb(26, 26, 26)'
|
|
||||||
const darkBgAlt = amoledEnabled ? '#000000' : 'rgb(23, 23, 23)'
|
|
||||||
const darkBgElv = amoledEnabled ? 'rgba(0, 0, 0, 0.9)' : 'rgba(23, 23, 23, 0.8)'
|
|
||||||
const darkBgSoft = amoledEnabled ? '#000000' : 'rgb(23, 23, 23)'
|
|
||||||
|
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
const storedTheme = localStorage.getItem('preferred-color')
|
|
||||||
const storedAmoled = localStorage.getItem('amoled-mode')
|
|
||||||
|
|
||||||
if (storedAmoled === 'true') {
|
|
||||||
document.documentElement.classList.add('theme-amoled')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize theme color
|
// Initialize theme color
|
||||||
updateThemeColor(selectedColor.value)
|
updateThemeColor(selectedColor.value)
|
||||||
|
|
||||||
watch(selectedColor, updateThemeColorm, isAmoledMode.value)
|
watch(selectedColor, updateThemeColor)
|
||||||
|
|
||||||
const normalizeColorName = (colorName: string) =>
|
const normalizeColorName = (colorName: string) =>
|
||||||
colorName.replaceAll(/-/g, ' ').charAt(0).toUpperCase() +
|
colorName.replaceAll(/-/g, ' ').charAt(0).toUpperCase() +
|
||||||
|
|
@ -110,10 +83,6 @@ const normalizeColorName = (colorName: string) =>
|
||||||
|
|
||||||
<div class="mt-2 text-sm text-$vp-c-text-2">
|
<div class="mt-2 text-sm text-$vp-c-text-2">
|
||||||
Selected: {{ normalizeColorName(selectedColor) }}
|
Selected: {{ normalizeColorName(selectedColor) }}
|
||||||
</div>
|
|
||||||
<div class="mt-4 flex items-center gap-2">
|
|
||||||
<span class="text-sm text-$vp-c-text-2">AMOLED</span>
|
|
||||||
<Switch @click="isAmoledMode = !isAmoledMode" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue