Files
Aislo/M01_MasterData/M01_MasterData_UI_LogicLab_Pill.ts
T
eomsangdonandClaude Sonnet 5.5 8cd30cc64d feat(734-1): 계산식 열 단추 낮은 단(20) · 옵션값 / 요소 연결 갈래 색 · 풍선 글
- 부품 상자 단추에 갈래 색(tone: option · link) 더함 — 공통 값(--color-warning · --color-info) 혼합 · 밝음 4.5 이상 · 어두움 6 이상
- 알약(요소 연결) · 입력 칩(옵션값) 24 → 20 · 마우스 풍선 「요소 연결」 · 「옵션」
- 지킴 시험 test_734_calc_buttons 새로

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-02 15:40:02 +09:00

50 lines
2.1 KiB
TypeScript

/* =============================================================================
* M01_MasterData_UI_LogicLab_Pill.ts
* 알약 단추 — 수량 칸 안 조각(표 찾기 등)을 누르면 곧장 그 자료 모달을 엶.
* (이전에는 알약을 늘어놓고 아래 자리에서 펼쳤으나, 알약이 수량 칸 안으로 들어가며
* 「누르면 모달」 로 바뀜 — 모달 안에 알약 목록을 또 두지 않음.)
* ========================================================================== */
import { el } from "@ui/ui_template_elements";
import { createButton } from "@ui/ui_template_button";
import { tl } from "./M01_MasterData_UI_LogicLab_Text";
export interface Pill {
/** 알약 글 — 보기 「표 QF000421」 */
label: string;
/** 누르면 할 일 — 그 자료 모달을 엶 */
onClick: () => void;
}
/** 알약 하나 — 글자 조각 사이에 끼워 쓰는 단추 */
export function pillButton(p: Pill): HTMLButtonElement {
// 알약 = 요소 연결 단추(보조 · 낮은 20 · 정보색 갈래) — data-pill 은 시험 · 촬영이 잡음
const b = createButton({ label: p.label, variant: "ghost", size: 20, tone: "link" });
b.title = tl("Pill_Tone");
b.classList.add("m01lab__pill");
b.dataset.pill = p.label;
b.addEventListener("click", (ev) => {
ev.stopPropagation(); // 줄 전체 누르기(행 모달)와 안 겹치게
p.onClick();
});
return b;
}
/** 수량 칸 조각 — 알약 아니면 그냥 글자(연산기호·숫자·중간값 이름) · `dim` = 계산 안 된 갈래(흐리게) */
export type Fragment = { pill: Pill; dim?: boolean } | { text: string; dim?: boolean };
/** 조각을 이어 그림 — 칸 폭을 넘으면 자동으로 줄바꿈(`flex-wrap`) */
export function fragmentRow(fragments: Fragment[]): HTMLElement {
return el("span", {
className: "m01lab__qty-frags",
children: fragments.map((f) => {
const one =
"pill" in f
? pillButton(f.pill)
: el("span", { className: "m01lab__qty-text", text: f.text });
if (f.dim) one.classList.add("m01lab__qty-dim");
return one;
}),
});
}