Skip to content

Commit

Permalink
Add a duotone icon to represent the "system" theme (#5236)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkb authored Dec 2, 2024
1 parent 64e1098 commit 1f9f87b
Show file tree
Hide file tree
Showing 103 changed files with 16 additions and 14 deletions.
9 changes: 9 additions & 0 deletions frontend/src/assets/svg/raw/duotone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/src/assets/svg/sprite/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 6 additions & 14 deletions frontend/src/components/VThemeSelect/VThemeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const uiStore = useUiStore()
const THEME_ICON_NAME = Object.freeze({
light: "sun",
dark: "moon",
system: "duotone",
})

const THEME_TEXT = {
Expand All @@ -41,14 +42,8 @@ const setIsDarkModeSeen = () => {

const darkMode = useDarkMode()

/**
* The icon always reflects the actual theme applied to the site.
* Therefore, it must be based on the value of `effectiveColorMode`.
*/
const currentThemeIcon: Ref<"sun" | "moon" | undefined> = ref(
darkMode.effectiveColorMode.value
? THEME_ICON_NAME[darkMode.effectiveColorMode.value]
: undefined
const currentThemeIcon: Ref<"sun" | "moon" | "duotone"> = ref(
THEME_ICON_NAME[darkMode.colorMode.value]
)

/**
Expand All @@ -64,15 +59,12 @@ const choices: Ref<Choice[]> = ref([

const updateRefs = () => {
colorMode.value = uiStore.colorMode
currentThemeIcon.value = THEME_ICON_NAME[darkMode.effectiveColorMode.value]
currentThemeIcon.value = THEME_ICON_NAME[darkMode.colorMode.value]
choices.value[2].text = `${THEME_TEXT.system} (${THEME_TEXT[darkMode.osColorMode.value]})`
}

onMounted(updateRefs)
watch(
() => [darkMode.effectiveColorMode.value, darkMode.osColorMode.value],
updateRefs
)
watch(() => [darkMode.colorMode.value, darkMode.osColorMode.value], updateRefs)
</script>

<template>
Expand All @@ -88,7 +80,7 @@ watch(
@update:model-value="handleUpdateModelValue"
>
<template #start>
<VIcon v-if="currentThemeIcon" :name="currentThemeIcon" />
<VIcon :name="currentThemeIcon" />
</template>
</VSelectField>
</template>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1f9f87b

Please sign in to comment.