Skip to content

Commit

Permalink
chore: add theme switcher hallowen theme (#4414)
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ksem authored Oct 30, 2024
1 parent e9a51d9 commit cc2b98f
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 97 deletions.
8 changes: 2 additions & 6 deletions packages/docs/components/layout/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<VaNavbar
v-show="!isOptionsVisible"
class="header"
class="header docs-header"
color="background-secondary"
>
<template #left>
Expand Down Expand Up @@ -44,7 +44,7 @@
>
{{ link.text }}
</VaButton>
<ColorDropdown class="mr-2" />
<!-- <ColorDropdown class="mr-2" /> -->
<ThemeSwitch class="mr-4" />
<VersionDropdown />
</div>
Expand Down Expand Up @@ -194,11 +194,7 @@ onMounted(() => {
}
.header {
// Halloween background
box-shadow: 0 2px 8px var(--va-shadow);
background-image: url("https://i.imgur.com/BNkuj2J.png");
background-position: center;
background-blend-mode: multiply;
&.va-navbar {
padding: var(--navbar-padding);
Expand Down
7 changes: 1 addition & 6 deletions packages/docs/components/layout/Sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<VaSidebar
v-model="writableVisible"
class="sidebar"
class="sidebar docs-sidebar"
:width="sidebarWidth"
>
<VaAccordion
Expand Down Expand Up @@ -178,11 +178,6 @@ export default defineComponent({
@import "@/assets/smart-grid.scss";
.sidebar {
// Halloween background
background-image: url("https://i.imgur.com/fLEstk9.png");
background-repeat: no-repeat;
background-blend-mode: multiply;
&__collapse-custom-header {
position: relative;
padding: 1rem 1.2rem;
Expand Down
74 changes: 33 additions & 41 deletions packages/docs/components/layout/header/ThemeSwitch.vue
Original file line number Diff line number Diff line change
@@ -1,57 +1,49 @@
<template>
<div>
<VaSwitch
:model-value="false"
color="#5123a1"
off-color="#ffd300"
style="--va-switch-checker-background-color: #252723;"
class="theme-switch-button"
name="Switch theme"
:aria-label="`Switch theme to ${isDark ? 'light' : 'dark'}`"
>
<template #innerLabel>
<div class="va-text-center">
<VaIcon
size="24px"
:name="'fas-ghost'"
/>
</div>
<VaMenu>
<template #anchor>
<VaButton
:icon="currentTheme?.icon"
preset="secondary"
/>
</template>
</VaSwitch>
<!-- <VaSwitch
v-model="isDark"
color="#5123a1"
off-color="#ffd300"
style="--va-switch-checker-background-color: #252723;"
class="theme-switch-button"
name="Switch theme"
:aria-label="`Switch theme to ${isDark ? 'light' : 'dark'}`"
>
<template #innerLabel>
<div class="va-text-center">
<VaIcon
size="24px"
:name="isDark ? 'dark_mode' : 'light_mode'"
/>
</div>
</template>
</VaSwitch> -->
<VaMenuItem
v-for="(theme) in themes"
:key="theme"
:icon="theme.icon"
:child:left-icon="{
color: theme.color
}"
class="h-[40px]"
@selected="applyPreset(theme.key)"
>
{{ theme.name }}

<template #right-icon>
<VaColorIndicator :color="presets[theme.key].backgroundPrimary" />
<VaColorIndicator class="-ml-2" :color="presets[theme.key].secondary" />
<VaColorIndicator class="-ml-2" :color="presets[theme.key].primary" />
</template>
</VaMenuItem>
</VaMenu>
</div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
const { currentPresetName, applyPreset } = useColors()
const { currentPresetName, applyPreset, presets } = useColors()
const isDark = computed({
get: () => currentPresetName.value === 'dark',
set: (value) => applyPreset(value ? 'dark' : 'light'),
})
const themes = [
{ name: 'Light', icon: 'light_mode', key: 'light', color: '#ffd300' },
{ name: 'Dark', icon: 'dark_mode', key: 'dark', color: '#5123a1' },
{ name: 'Spooky', icon: 'fas-ghost', key: 'halloween', color: '#e36414' },
]
const currentTheme = computed(() => themes.find((theme) => theme.key === currentPresetName.value))
</script>

<style lang="scss">
.theme-switch-button {
--va-switch-checker-wrapper-width: 4rem;
--va-switch-inner-height: 2.25rem;
Expand Down
28 changes: 14 additions & 14 deletions packages/docs/config/vuestic-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const halloweenColors = {
backgroundSidebar: '#130C0C',
backgroundLanding: '#f4f9fc',
backgroundLandingBorder: 'rgba(155, 179, 206, 0.8)',
textPrimary: '#FFFFFF',
textInverted: '#FFFFFF',
shadow: 'rgba(0, 0, 0, 0.30)',
}

export const VuesticConfig = defineVuesticConfig({
Expand Down Expand Up @@ -72,23 +75,19 @@ export const VuesticConfig = defineVuesticConfig({
presets: {
// Halloween colors
light: {
...halloweenColors
secondary: '#666E75',
backgroundPrimary: '#FFFFFF',
backgroundLanding: '#f4f9fc',
backgroundLandingBorder: 'rgba(155, 179, 206, 0.8)',
backgroundSidebar: '#ECF0F1',
},
dark: {
...halloweenColors
secondary: '#818992',
backgroundLanding: '#070d14',
backgroundLandingBorder: 'rgba(43, 49, 56, 0.8)',
backgroundSidebar: '#131A22',
shadow: 'rgba(0, 0, 0, 0.12)',
},

// light: {
// secondary: '#666E75',
// backgroundPrimary: '#FFFFFF',
// backgroundLanding: '#f4f9fc',
// backgroundLandingBorder: 'rgba(155, 179, 206, 0.8)',
// },
// dark: {
// secondary: '#818992',
// backgroundLanding: '#070d14',
// backgroundLandingBorder: 'rgba(43, 49, 56, 0.8)',
// },
landing: {
// primary: '#1827A7',
// secondary: '#767C88',
Expand All @@ -113,6 +112,7 @@ export const VuesticConfig = defineVuesticConfig({

...halloweenColors,
},
halloween: halloweenColors,
},
},
})
81 changes: 54 additions & 27 deletions packages/docs/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div
class="docs-layout"
:class="[`docs-layout--theme-${currentPresetName}`]"
>
<div
v-show="doShowLoader"
Expand Down Expand Up @@ -41,6 +42,8 @@
<script setup lang="ts">
const breakpoints = useBreakpoint()
const { currentPresetName } = useColors()
const isSidebarVisible = ref(!breakpoints.smDown)
const isOptionsVisible = ref(false)
const doShowLoader = ref(true)
Expand Down Expand Up @@ -78,6 +81,11 @@ onMounted(() => {
doShowLoader.value = false
}, 300);
if (!window.localStorage.getItem('eventConfig')) {
window.localStorage.setItem('eventConfig', 'halloween')
currentPresetName.value = 'halloween'
}
window.addEventListener('mousemove', onMouseMove)
const resetInertia = () => {
Expand Down Expand Up @@ -126,29 +134,53 @@ html {
// Halloween background
position: relative;
&::before {
content: '';
position: absolute;
height: 100%;
min-height: 100vh;
width: 100%;
background-image: url("https://i.imgur.com/rpnciUN.png");
background-size: 30%;
background-color: #000;
z-index: 0;
opacity: 0.5;
}
&--theme-halloween {
&::before {
content: '';
position: absolute;
height: 100%;
min-height: 100vh;
width: 100%;
background-image: url("https://i.imgur.com/rpnciUN.png");
background-size: 30%;
background-color: #000;
z-index: 0;
opacity: 0.5;
}
&::after {
content: '';
position: fixed;
top: 0;
height: 100%;
width: 100%;
background: radial-gradient(circle at v-bind("mouse.x + 'px'") v-bind("mouse.y + 'px'"), transparent 0%, #000 v-bind("(mouseInertia.x + mouseInertia.y) * 0.5 + 'px'"));
background-size: 200%;
z-index: 0;
pointer-events: none;
&::after {
content: '';
position: fixed;
top: 0;
height: 100%;
width: 100%;
background: radial-gradient(circle at v-bind("mouse.x + 'px'") v-bind("mouse.y + 'px'"), transparent 0%, #000 v-bind("(mouseInertia.x + mouseInertia.y) * 0.5 + 'px'"));
background-size: 200%;
z-index: 0;
pointer-events: none;
}
.docs-layout__loader {
// Halloween loader
background-image: url("https://i.imgur.com/yLvFZoB.png");
background-position: center;
background-repeat: no-repeat;
animation: background-jump 1s infinite;
}
.docs-sidebar {
// Halloween background
background-image: url("https://i.imgur.com/fLEstk9.png");
background-repeat: no-repeat;
background-blend-mode: multiply;
}
.docs-header {
// Halloween background
background-image: url("https://i.imgur.com/BNkuj2J.png");
background-position: center;
background-blend-mode: multiply;
}
}
& > * {
Expand All @@ -175,11 +207,6 @@ html {
height: 100%;
z-index: 9999999;
background: var(--va-background-primary);
// Halloween loader
background-image: url("https://i.imgur.com/yLvFZoB.png");
background-position: center;
background-repeat: no-repeat;
animation: background-jump 1s infinite;
}
&__main-section {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const useDropdown = (
result.push(
// boundary doesn't work with ssr (trying to access document)
flip({
boundary: target.value,
boundary: target.value ?? 'clippingAncestors',
}),
)
}
Expand Down
12 changes: 10 additions & 2 deletions packages/ui/src/components/va-menu-list/components/VaMenuItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
>
<td class="va-menu-item__cell va-menu-item__cell--left">
<slot name="left-icon">
<VaIcon class="va-menu-item__icon--left" v-if="icon" :name="icon" />
<VaIcon class="va-menu-item__icon--left" v-if="icon" :name="icon" va-child="leftIcon" />
</slot>
</td>

Expand All @@ -25,7 +25,7 @@

<td class="va-menu-item__cell va-menu-item__cell--right">
<slot name="right-icon">
<VaIcon v-if="rightIcon" class="va-menu-item__icon--right" :name="rightIcon" />
<VaIcon v-if="rightIcon" class="va-menu-item__icon--right" :name="rightIcon" va-child="rightIcon" />
</slot>
</td>
</tr>
Expand All @@ -36,6 +36,7 @@ import { ref, computed } from 'vue'
import { VaIcon } from '../../va-icon/'
import { useKeyboardOnlyFocusGlobal } from '../../../composables'
import { makeMenuItemAttributes } from '../composables/useMenuKeyboardNavigation'
import { defineChildProps, useChildComponents } from '../../../composables/useChildComponents'
defineOptions({
name: 'VaMenuItem',
Expand All @@ -46,11 +47,17 @@ const props = defineProps({
icon: { type: String, defatult: '' },
rightIcon: { type: String, defatult: '' },
disabled: { type: Boolean, default: false },
...defineChildProps({
leftIcon: VaIcon,
rightIcon: VaIcon,
}),
})
const emit = defineEmits(['selected'])
const { hasKeyboardFocus, keyboardFocusListeners } = useKeyboardOnlyFocusGlobal()
useChildComponents(props)
</script>

<style lang="scss">
Expand Down Expand Up @@ -82,6 +89,7 @@ const { hasKeyboardFocus, keyboardFocusListeners } = useKeyboardOnlyFocusGlobal(
&:empty {
padding: 0;
width: 0;
}
}
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/src/components/va-menu/VaMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { extractComponentProps, extractComponentEmits, filterComponentProps } fr
import { useImmediateFocus, useComponentPresetProp } from '../../composables'
import { focusFirstFocusableChild } from '../../utils/focus'
import { unwrapEl } from '../../utils/unwrapEl'
import { useChildComponents, defineChildProps } from '../../composables/useChildComponents'
const VaMenuListProps = extractComponentProps(VaMenuList)
const VaMenuListEmits = extractComponentEmits(VaMenuList)
Expand All @@ -39,6 +40,10 @@ const props = defineProps({
...useComponentPresetProp,
...VaMenuListProps,
...VaDropdownProps,
...defineChildProps({
menuList: VaMenuList,
dropdown: VaDropdown,
}),
stickToEdges: { type: Boolean, default: true },
})
Expand Down Expand Up @@ -73,6 +78,8 @@ const onKeydown = (event: KeyboardEvent) => {
const menuListProps = filterComponentProps(VaMenuListProps)
const dropdownProps = filterComponentProps(VaDropdownProps)
useChildComponents(props)
defineExpose({
close,
})
Expand Down

0 comments on commit cc2b98f

Please sign in to comment.