Files
InvoiceShelf/resources/scripts/components/base/BaseSwitch.vue
Darko Gjorgjijoski 88adfe0e50 Add dark mode with CSS custom property theme system
Define 13 semantic color tokens (surface, text, border, hover) with
light/dark values in themes.css. Register with Tailwind via @theme inline.
Migrate all 335 Vue files from hardcoded gray/white classes to semantic
tokens. Add theme toggle (sun/moon/system) in user avatar dropdown.
Replace @tailwindcss/forms with custom form reset using theme vars.
Add status badge and alert tokens for dark mode. Theme-aware chart
grid/labels, skeleton placeholders, and editor. Inline script in
<head> prevents flash of wrong theme on load.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:05:00 +02:00

69 lines
1.4 KiB
Vue

<template>
<SwitchGroup>
<div class="flex flex-row items-start">
<SwitchLabel v-if="labelLeft" class="mr-4 cursor-pointer">{{
labelLeft
}}</SwitchLabel>
<Switch
v-model="enabled"
:class="enabled ? 'bg-primary-500' : 'bg-surface-muted'"
class="
relative
inline-flex
items-center
h-6
transition-colors
rounded-full
w-11
focus:outline-hidden focus:ring-primary-500
"
v-bind="$attrs"
>
<span
:class="enabled ? 'translate-x-6' : 'translate-x-1'"
class="
inline-block
w-4
h-4
transition-transform
bg-white
rounded-full
"
/>
</Switch>
<SwitchLabel v-if="labelRight" class="ml-4 cursor-pointer">{{
labelRight
}}</SwitchLabel>
</div>
</SwitchGroup>
</template>
<script setup>
import { computed } from 'vue'
import { Switch, SwitchGroup, SwitchLabel } from '@headlessui/vue'
const props = defineProps({
labelLeft: {
type: String,
default: '',
},
labelRight: {
type: String,
default: '',
},
modelValue: {
type: Boolean,
default: false,
},
})
const emit = defineEmits(['update:modelValue'])
const enabled = computed({
get: () => props.modelValue,
set: (value) => emit('update:modelValue', value),
})
</script>