fix(784-2): 단위 환산 칸 — 몫 1 = 몫 없음 · 칸 한 덩이로 묶음 · 화면 확인 뒤 다듬음
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -172,6 +172,12 @@
|
||||
width: 6em;
|
||||
}
|
||||
|
||||
.m02-hopyo__unit {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-4);
|
||||
}
|
||||
|
||||
/* 단위 환산 칸 앞뒤 글 — 「엑셀 1 ㎡ = 우리 [ ] 본」 */
|
||||
.m02-hopyo__unit-text {
|
||||
color: var(--color-text-secondary);
|
||||
|
||||
@@ -111,19 +111,18 @@ const stateChip = (line: HopyoLine): HTMLElement => {
|
||||
};
|
||||
|
||||
/** 단위 환산 칸 — 「엑셀 1 ㎡ = 우리 [ ] 본」(장부 화면도 같은 꼴) */
|
||||
export function unitField(
|
||||
input: HTMLInputElement,
|
||||
v: Pick<UnitView, "from" | "to">,
|
||||
): HTMLElement[] {
|
||||
export function unitField(input: HTMLInputElement, v: Pick<UnitView, "from" | "to">): HTMLElement {
|
||||
input.title = L("M02_HopyoUnitTip");
|
||||
return [
|
||||
el("span", {
|
||||
className: "m02-hopyo__unit-text",
|
||||
text: L("M02_HopyoUnitLead").replace("{from}", v.from || "?"),
|
||||
}),
|
||||
input,
|
||||
...(v.to ? [el("span", { className: "m02-hopyo__unit-text", text: v.to })] : []),
|
||||
];
|
||||
const word = (text: string): HTMLElement =>
|
||||
el("span", { className: "m02-hopyo__unit-text", text });
|
||||
return el("span", {
|
||||
className: "m02-hopyo__unit",
|
||||
children: [
|
||||
word(L("M02_HopyoUnitLead").replace("{from}", v.from || "?")),
|
||||
input,
|
||||
...(v.to ? [word(v.to)] : []),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
/** 대상마다 한 줄 — 키 · 이름 · 단위 환산(같음 = 글만 · 몫 줄 = 몫만 · 빈칸 · 추정 = 입력 칸) · 몫 */
|
||||
@@ -152,9 +151,9 @@ function partLines(line: HopyoLine, parts: HopyoPart[], ctx: RowsContext): HTMLE
|
||||
el("span", { className: "m02-labrow__key", text: key }),
|
||||
el("strong", { text: p.이름 ?? "" }),
|
||||
...(v.mode === "same" ? [small(L("M02_HopyoUnitSame"))] : []),
|
||||
...(v.mode === "input" ? unitField(times, v) : []),
|
||||
...(v.mode === "input" ? [unitField(times, v)] : []),
|
||||
...(note ? [small(note)] : []),
|
||||
...(p.몫 != null ? [small(`몫 ${p.몫}`)] : []),
|
||||
...(p.몫 != null && p.몫 !== 1 ? [small(`몫 ${p.몫}`)] : []),
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -184,7 +184,7 @@ export function buildHopyoLedger(opt: LedgerOptions): HTMLElement {
|
||||
times.addEventListener("change", () =>
|
||||
edit(r, { 짝: r.짝.map((x, i) => (i === at ? { ...x, 배: Number(times.value) } : x)) }),
|
||||
);
|
||||
parts.push(...unitField(times, { from: r.원래.단위, to: "" }));
|
||||
parts.push(unitField(times, { from: r.원래.단위, to: "" }));
|
||||
if (p.로직)
|
||||
parts.push(
|
||||
createButton({
|
||||
|
||||
@@ -41,7 +41,7 @@ export function unitView(
|
||||
): UnitView {
|
||||
const f = String(from ?? "").trim();
|
||||
const t = String(to ?? p.단위 ?? "").trim();
|
||||
const quota = p.몫 != null;
|
||||
const quota = p.몫 != null && p.몫 !== 1; // 몫 1 = 몫 없음과 같음
|
||||
const kind = p.환산?.갈래;
|
||||
const unitSame = kind
|
||||
? kind === "같음" || kind === "두 단위" || (kind === "단위표" && p.환산?.배 === 1)
|
||||
|
||||
@@ -604,10 +604,11 @@ def test_단위_환산_칸_보이기_784_2():
|
||||
{"part": {"배": 0.01, "몫": 0.1, "환산": {"배": 0.1, "갈래": "단위표"}}, "from": "a", "to": "b"},
|
||||
{"part": {"배": 1}, "from": "m2", "to": "㎡"},
|
||||
{"part": {"배": 1}, "from": "m", "to": "본"},
|
||||
{"part": {"배": 1, "몫": 1, "환산": {"배": 1, "갈래": "같음"}}, "from": "㎡", "to": "㎡"},
|
||||
] # fmt: skip
|
||||
got = _node("helper_m02_hopyo_unit.cjs", {"cases": cases})
|
||||
assert [g["mode"] for g in got] == [
|
||||
"same", "same", "quota", "input", "input", "input", "input", "input", "same", "input",
|
||||
"same", "same", "quota", "input", "input", "input", "input", "input", "same", "input", "same",
|
||||
] # fmt: skip
|
||||
assert (got[3]["from"], got[3]["to"]) == ("㎡", "본") # 「엑셀 1 ㎡ = 우리 [ ] 본」
|
||||
assert got[5]["estimated"] and got[5]["thick"] == 0.2 # 「두께 0.2m 로 추정」
|
||||
|
||||
Reference in New Issue
Block a user