All files / src/components pill.ts

100% Statements 29/29
100% Branches 4/4
100% Functions 3/3
100% Lines 29/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 361x     1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x   1x 42x 42x 42x 42x 42x   1x 4x 4x 4x   1x 1x 1x  
import { MODEL_TASK } from "../types";
import { MESSAGES } from "../locales/en";
 
export const PILL_CLS = {
    PICK: "lilbee-pill-pick",
    TASK_CHAT: "lilbee-pill-task-chat",
    TASK_EMBEDDING: "lilbee-pill-task-embedding",
    TASK_VISION: "lilbee-pill-task-vision",
    TASK_RERANK: "lilbee-pill-task-rerank",
    INSTALLED: "lilbee-pill-installed",
    ACTIVE: "lilbee-pill-active",
} as const;
 
const TASK_PILL_MAP: Record<string, string> = {
    [MODEL_TASK.CHAT]: PILL_CLS.TASK_CHAT,
    [MODEL_TASK.EMBEDDING]: PILL_CLS.TASK_EMBEDDING,
    [MODEL_TASK.VISION]: PILL_CLS.TASK_VISION,
    [MODEL_TASK.RERANK]: PILL_CLS.TASK_RERANK,
};
 
export function renderPill(container: HTMLElement, text: string, cls: string): HTMLElement {
    return container.createEl("span", {
        text,
        cls: `lilbee-pill ${cls}`,
    });
}
 
export function renderTaskPill(container: HTMLElement, task: string): HTMLElement {
    const cls = TASK_PILL_MAP[task] ?? PILL_CLS.TASK_CHAT;
    return renderPill(container, task, cls);
}
 
export function renderPickPill(container: HTMLElement): HTMLElement {
    return renderPill(container, MESSAGES.LABEL_PICK, PILL_CLS.PICK);
}