add template and icons comps
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { templateIcon } from '$lib/templateIcons';
|
||||||
|
|
||||||
|
let { name = undefined, size = 18, color = undefined }: {
|
||||||
|
name?: string;
|
||||||
|
size?: number;
|
||||||
|
color?: string;
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
const Cmp = $derived(templateIcon(name));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Cmp {size} {color} />
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import {
|
||||||
|
Bed,
|
||||||
|
Sparkles,
|
||||||
|
BookOpen,
|
||||||
|
Utensils,
|
||||||
|
Wallet,
|
||||||
|
Trophy,
|
||||||
|
Star,
|
||||||
|
Moon,
|
||||||
|
Sun,
|
||||||
|
Apple,
|
||||||
|
Car,
|
||||||
|
Gamepad2,
|
||||||
|
Music,
|
||||||
|
Shirt,
|
||||||
|
Leaf,
|
||||||
|
Heart,
|
||||||
|
Gift,
|
||||||
|
Timer
|
||||||
|
} from '@lucide/svelte';
|
||||||
|
|
||||||
|
export const ICON_MAP: Record<string, any> = {
|
||||||
|
Bed,
|
||||||
|
Sparkles,
|
||||||
|
BookOpen,
|
||||||
|
Utensils,
|
||||||
|
Wallet,
|
||||||
|
Trophy,
|
||||||
|
Star,
|
||||||
|
Moon,
|
||||||
|
Sun,
|
||||||
|
Apple,
|
||||||
|
Car,
|
||||||
|
Gamepad2,
|
||||||
|
Music,
|
||||||
|
Shirt,
|
||||||
|
Leaf,
|
||||||
|
Heart,
|
||||||
|
Gift,
|
||||||
|
Timer
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ICON_NAMES = Object.keys(ICON_MAP);
|
||||||
|
|
||||||
|
export function templateIcon(name?: string): any {
|
||||||
|
if (name && ICON_MAP[name]) return ICON_MAP[name];
|
||||||
|
return Star;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 8 normal colours + 1 dark (chromatic) + 1 transparent (default accent).
|
||||||
|
// `value: ''` means transparent — no accent background, neutral outline.
|
||||||
|
export interface TemplateColor {
|
||||||
|
value: string;
|
||||||
|
label: string;
|
||||||
|
chromatic?: 'dark' | 'transparent';
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TEMPLATE_COLORS: TemplateColor[] = [
|
||||||
|
{ value: '', label: 'Transparent', chromatic: 'transparent' },
|
||||||
|
{ value: '#ef4444', label: 'Red' },
|
||||||
|
{ value: '#f97316', label: 'Orange' },
|
||||||
|
{ value: '#f59e0b', label: 'Amber' },
|
||||||
|
{ value: '#22c55e', label: 'Green' },
|
||||||
|
{ value: '#14b8a6', label: 'Teal' },
|
||||||
|
{ value: '#3b82f6', label: 'Blue' },
|
||||||
|
{ value: '#6366f1', label: 'Indigo' },
|
||||||
|
{ value: '#a855f7', label: 'Purple' },
|
||||||
|
{ value: '#1f2937', label: 'Dark', chromatic: 'dark' }
|
||||||
|
];
|
||||||
|
|
||||||
|
export function accentBg(color?: string): string {
|
||||||
|
if (!color) return 'transparent';
|
||||||
|
const hex = color.replace('#', '');
|
||||||
|
const r = parseInt(hex.slice(0, 2), 16);
|
||||||
|
const g = parseInt(hex.slice(2, 4), 16);
|
||||||
|
const b = parseInt(hex.slice(4, 6), 16);
|
||||||
|
return `rgba(${r}, ${g}, ${b}, 0.3)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function outlineColor(color?: string): string {
|
||||||
|
return color || '#e5e7eb';
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user