feat(ui) : add site colors, dark mode toggle and card styling improvements
- Site color field with color picker in create/edit modals - Dark mode theme (mytheme-dark) with toggle in navbar - Stronger site color visibility on cards (gradient, top border, badges) - Bigger action buttons (btn-sm) on machine cards - White card backgrounds with proper dark mode support Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
26
app/composables/useDarkMode.ts
Normal file
26
app/composables/useDarkMode.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
const isDark = ref(false)
|
||||
|
||||
export function useDarkMode() {
|
||||
const toggle = () => {
|
||||
isDark.value = !isDark.value
|
||||
applyTheme()
|
||||
}
|
||||
|
||||
const applyTheme = () => {
|
||||
const theme = isDark.value ? 'mytheme-dark' : 'mytheme'
|
||||
document.documentElement.setAttribute('data-theme', theme)
|
||||
localStorage.setItem('theme', theme)
|
||||
}
|
||||
|
||||
const init = () => {
|
||||
const saved = localStorage.getItem('theme')
|
||||
if (saved === 'mytheme-dark') {
|
||||
isDark.value = true
|
||||
} else if (!saved && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
isDark.value = true
|
||||
}
|
||||
applyTheme()
|
||||
}
|
||||
|
||||
return { isDark, toggle, init }
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import { canPreviewDocument } from '~/utils/documentPreview'
|
||||
|
||||
type SiteForm = {
|
||||
name: string
|
||||
color: string
|
||||
contactName: string
|
||||
contactPhone: string
|
||||
contactAddress: string
|
||||
@@ -31,6 +32,7 @@ type SiteDocument = {
|
||||
type SiteWithDocuments = {
|
||||
id: string
|
||||
name?: string
|
||||
color?: string
|
||||
contactName?: string
|
||||
contactPhone?: string
|
||||
contactAddress?: string
|
||||
@@ -54,6 +56,7 @@ export function useSiteManagement() {
|
||||
|
||||
const newSite = reactive<SiteForm>({
|
||||
name: '',
|
||||
color: '',
|
||||
contactName: '',
|
||||
contactPhone: '',
|
||||
contactAddress: '',
|
||||
@@ -63,6 +66,7 @@ export function useSiteManagement() {
|
||||
|
||||
const editSiteForm = reactive<SiteForm>({
|
||||
name: '',
|
||||
color: '',
|
||||
contactName: '',
|
||||
contactPhone: '',
|
||||
contactAddress: '',
|
||||
@@ -81,6 +85,7 @@ export function useSiteManagement() {
|
||||
|
||||
const resetNewSite = () => {
|
||||
newSite.name = ''
|
||||
newSite.color = ''
|
||||
newSite.contactName = ''
|
||||
newSite.contactPhone = ''
|
||||
newSite.contactAddress = ''
|
||||
@@ -101,6 +106,7 @@ export function useSiteManagement() {
|
||||
const handleCreateSite = async () => {
|
||||
const result = await createSite({
|
||||
name: newSite.name,
|
||||
color: newSite.color,
|
||||
contactName: newSite.contactName,
|
||||
contactPhone: newSite.contactPhone,
|
||||
contactAddress: newSite.contactAddress,
|
||||
@@ -116,6 +122,7 @@ export function useSiteManagement() {
|
||||
const editSite = (site: SiteWithDocuments) => {
|
||||
siteBeingEdited.value = site
|
||||
editSiteForm.name = site.name || ''
|
||||
editSiteForm.color = site.color || ''
|
||||
editSiteForm.contactName = site.contactName || ''
|
||||
editSiteForm.contactPhone = site.contactPhone || ''
|
||||
editSiteForm.contactAddress = site.contactAddress || ''
|
||||
@@ -148,6 +155,7 @@ export function useSiteManagement() {
|
||||
|
||||
const baseUpdate = {
|
||||
name: editSiteForm.name,
|
||||
color: editSiteForm.color,
|
||||
contactName: editSiteForm.contactName,
|
||||
contactPhone: editSiteForm.contactPhone,
|
||||
contactAddress: editSiteForm.contactAddress,
|
||||
|
||||
@@ -6,6 +6,7 @@ import { extractCollection } from '~/shared/utils/apiHelpers'
|
||||
export interface Site {
|
||||
id: string
|
||||
name?: string
|
||||
color?: string
|
||||
contactName?: string
|
||||
contactPhone?: string
|
||||
contactAddress?: string
|
||||
|
||||
Reference in New Issue
Block a user