Fix tests and add changelog

This commit is contained in:
2026-01-04 21:33:10 +01:00
parent f0b41572bc
commit a154192410
56 changed files with 4464 additions and 236 deletions

View File

@@ -0,0 +1,57 @@
import { LabelColorName } from './types'
const STORAGE_KEY = 'memento-label-colors'
// Store label colors in localStorage
export function getLabelColor(label: string): LabelColorName {
if (typeof window === 'undefined') return 'gray'
try {
const stored = localStorage.getItem(STORAGE_KEY)
if (!stored) return 'gray'
const colors = JSON.parse(stored) as Record<string, LabelColorName>
return colors[label] || 'gray'
} catch {
return 'gray'
}
}
export function setLabelColor(label: string, color: LabelColorName) {
if (typeof window === 'undefined') return
try {
const stored = localStorage.getItem(STORAGE_KEY)
const colors = stored ? JSON.parse(stored) as Record<string, LabelColorName> : {}
colors[label] = color
localStorage.setItem(STORAGE_KEY, JSON.stringify(colors))
} catch (error) {
console.error('Failed to save label color:', error)
}
}
export function getAllLabelColors(): Record<string, LabelColorName> {
if (typeof window === 'undefined') return {}
try {
const stored = localStorage.getItem(STORAGE_KEY)
return stored ? JSON.parse(stored) : {}
} catch {
return {}
}
}
export function deleteLabelColor(label: string) {
if (typeof window === 'undefined') return
try {
const stored = localStorage.getItem(STORAGE_KEY)
if (!stored) return
const colors = JSON.parse(stored) as Record<string, LabelColorName>
delete colors[label]
localStorage.setItem(STORAGE_KEY, JSON.stringify(colors))
} catch (error) {
console.error('Failed to delete label color:', error)
}
}