chore: clean up repo for public release
- Remove BMAD framework, IDE configs, dev screenshots, test files, internal docs, and backup files - Rename keep-notes/ to memento-note/ - Update all references from keep-notes to memento-note - Add Apache 2.0 license with Commons Clause (non-commercial restriction) - Add clean .gitignore and .env.docker.example
This commit is contained in:
57
memento-note/lib/label-storage.ts
Normal file
57
memento-note/lib/label-storage.ts
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user