"use client"; import { createContext, useContext } from "react"; import { BADGE_CLASS } from "@/lib/colors"; import { FILE_ROLES, fileRole, type FileRoleStyles } from "@/lib/file-roles"; import { cn } from "@/lib/utils"; const defaults = Object.fromEntries( Object.entries(FILE_ROLES).map(([role, r]) => [role, { label: r.label, color: r.color }]), ) as FileRoleStyles; const LabelContext = createContext(defaults); /** Provides the label settings (from the Settings page) to client components. */ export function LabelSettingsProvider({ fileRoles, children }: { fileRoles: FileRoleStyles; children: React.ReactNode }) { return {children}; } export function useFileRoleStyles(): FileRoleStyles { return useContext(LabelContext); } /** Label in front of a file name telling what the file is (Model, MTP, Vision, …). */ export function FileRoleBadge({ path, className }: { path: string; className?: string }) { const styles = useFileRoleStyles(); const role = fileRole(path); const style = styles[role]; return ( {style.label} ); }