Compare commits

...

3 commits

Author SHA1 Message Date
13255d9846 Add AppBar 2025-07-24 00:27:31 +02:00
c25141d53d Add theme prefs saving 2025-07-24 00:27:26 +02:00
fb0dba4e03 Update build script 2025-07-24 00:27:04 +02:00
6 changed files with 61 additions and 9 deletions

View file

@ -19,8 +19,7 @@ bun install
bun run build bun run build
echo "Building Go backend..." echo "Building Go backend..."
cd "$BACKEND_DIR" go build -C "$BACKEND_DIR" -v -o "$OUTPUT_DIR" $BACKEND_PKG
go build -v -o "$OUTPUT_DIR" $BACKEND_PKG
cd "$ROOT_DIR" cd "$ROOT_DIR"
echo "Build completed. Output located in: $OUTPUT_DIR" echo "Build completed. Output located in: $OUTPUT_DIR"

View file

@ -8,6 +8,7 @@ export {}
/* prettier-ignore */ /* prettier-ignore */
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
AppBar: typeof import('./components/AppBar.vue')['default']
HelloWorld: typeof import('./components/HelloWorld.vue')['default'] HelloWorld: typeof import('./components/HelloWorld.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView'] RouterView: typeof import('vue-router')['RouterView']

View file

@ -0,0 +1,45 @@
<!--
Alpacca: The modern package repository hosting platform.
Copyright (C) 2025, Zervó Zadachin
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
The full copyright notice can be found at https://git.zervo.org/zervo/Alpacca/src/branch/main/COPYRIGHT.
-->
<template>
<v-app-bar :elevation="5">
<template #prepend>
<v-img
:src="logoSrc"
:width="200"
/>
</template>
<template #append>
<v-btn :icon="themeIsDark ? 'mdi-weather-sunny' : 'mdi-weather-night'" @click="toggleTheme" />
</template>
</v-app-bar>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { useTheme } from 'vuetify'
import darkLogo from '@/assets/icon_darkmode.png'
import lightLogo from '@/assets/icon_lightmode.png'
const theme = useTheme()
const themeIsDark = computed(() => theme.global.current.value.dark)
const logoSrc = computed(() => {
return themeIsDark.value ? darkLogo : lightLogo
})
function toggleTheme () {
const newTheme = themeIsDark.value ? 'light' : 'dark'
theme.global.name.value = newTheme
localStorage.setItem('theme', newTheme)
}
</script>

View file

@ -10,12 +10,6 @@ The full copyright notice can be found at https://git.zervo.org/zervo/Alpacca/sr
<template> <template>
<v-container class="fill-height" max-width="900"> <v-container class="fill-height" max-width="900">
<div> <div>
<v-img
class="mb-4"
height="150"
src="@/assets/icon_darkmode.png"
/>
<div class="mb-8 text-center"> <div class="mb-8 text-center">
<div class="text-body-1 font-weight-light mb-n1">Welcome to</div> <div class="text-body-1 font-weight-light mb-n1">Welcome to</div>
<h1 class="text-h2 font-weight-bold">Alpacca</h1> <h1 class="text-h2 font-weight-bold">Alpacca</h1>

View file

@ -10,6 +10,7 @@ The full copyright notice can be found at https://git.zervo.org/zervo/Alpacca/sr
<template> <template>
<v-app> <v-app>
<v-main> <v-main>
<AppBar />
<slot /> <slot />
</v-main> </v-main>
</v-app> </v-app>

View file

@ -16,9 +16,21 @@ import { createVuetify } from 'vuetify'
import '@mdi/font/css/materialdesignicons.css' import '@mdi/font/css/materialdesignicons.css'
import 'vuetify/styles' import 'vuetify/styles'
// Detect system theme preferences
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
// Get saved theme or fallback to system
const savedTheme = localStorage.getItem('theme')
const initialTheme = savedTheme || (prefersDark ? 'dark' : 'light')
// Save if no theme was already saved
if (!savedTheme) {
localStorage.setItem('theme', initialTheme)
}
// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides // https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
export default createVuetify({ export default createVuetify({
theme: { theme: {
defaultTheme: 'system', defaultTheme: initialTheme,
}, },
}) })