2 Commits
Author SHA1 Message Date
CatoandClaude Sonnet 5.5 a198f6a9f7 fix: icon scales with the field's text; codemod skips comments (0.3.1)
A fixed 20px calendar icon made a dense 12px input taller than its
neighbours (34px vs 30px). The icon is now 1.25em. The browser check has a
compact input and fails on the old icon (it first passed on it — the limit
was exactly the old height; tightened and re-proven).

The codemod no longer edits comments or files already on whenkit (it
rewrote its own shim, whose comment mentioned the tag).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
2026-10-08 14:56:11 +02:00
CatoandClaude Sonnet 5.5 15ed5a9c84 chore: codemod to migrate date inputs to DateInput
A JSX tag scanner (braces, strings, template literals — not a regex over
attributes) that changes <input type=date|datetime-local> to DateInput and
adds one import. Lists what it will not guess. Tested on tricky fixtures,
including the blank-line-after-imports bug its own test caught; a second run
changes nothing.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
2026-10-08 14:40:38 +02:00
8 changed files with 9 additions and 69 deletions

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ length chips, a readable date field over the native picker, and a booking
request that resolves to `{ startsAt, endsAt }` in the provider's time zone.
```bash
pnpm add github:bitbaum/whenkit#v0.3.2
pnpm add github:bitbaum/whenkit#v0.3.1
```
```tsx
-6
View File
@@ -47,12 +47,6 @@ createRoot(document.getElementById("dialog")!).render(
createRoot(document.getElementById("own-class")!).render(
<DateInput className="app-input" defaultValue="2026-10-11" id="own" />,
);
createRoot(document.getElementById("match-date")!).render(
<DateInput className="match-input" defaultValue="2026-10-11" id="match" />,
);
createRoot(document.getElementById("block-class")!).render(
<DateInput className="block-input" defaultValue="2026-10-11" id="blocked" />,
);
createRoot(document.getElementById("compact-class")!).render(
<DateInput className="compact-input" defaultValue="2026-10-11" id="compact" />,
);
-20
View File
@@ -67,21 +67,6 @@
border-color: rgb(0, 0, 255);
}
}
/* An app's input, applied to a native input AND to DateInput: they must end up
the same height (a serif so its natural line height differs from 1.3). */
.match-input {
font-family: Georgia, serif;
font-size: 14px;
padding: 10px 14px;
border: 1.5px solid rgb(150, 150, 150);
border-radius: 10px;
width: 100%;
box-sizing: border-box;
}
/* A hostile app class: display:block on the same element (unlayered, later). */
.block-input {
display: block;
}
.resolved {
font-size: 11px;
opacity: 0.5;
@@ -110,11 +95,6 @@
<section><div id="own-class"></div></section>
<section><div id="util-class"></div></section>
<section><div id="compact-class"></div></section>
<section>
<input id="match-native" class="match-input" value="Bello" />
<div id="match-date" style="margin-top: 8px"></div>
</section>
<section><div id="block-class"></div></section>
</div>
<div class="dialog-like" id="dialog"></div>
</main>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@bitbaum/whenkit",
"version": "0.3.2",
"version": "0.3.1",
"description": "Dates and times people can pick without typing: day chips, time chips, length chips, a readable date field over the native picker, and a low-friction booking request that resolves to {startsAt, endsAt} in the provider's zone.",
"license": "MIT",
"author": "Cato",
+1 -3
View File
@@ -116,9 +116,7 @@ for (const file of walk(root)) {
last = m.index + m[0].length;
count++;
const line = src.slice(0, m.index).split("\n").length;
// A JSX prop spread is `{...x}` at attribute level; `({ ...form, a })` inside
// an onChange arrow is an object literal and is not worth a human's time.
if (/(^|[\s"'}/])\{\s*\.\.\.[A-Za-z_$]/.test(attrs.replace(/=\{[^}]*\}/g, "=")))
if (/\{\s*\.\.\./.test(attrs))
review.push(`${relative(root, file)}:${line} spreads props — check they are input props`);
} else if (TYPE_ANY.test(attrs) && /date/i.test(src.slice(m.index, m.index + 400))) {
const line = src.slice(0, m.index).split("\n").length;
+6 -11
View File
@@ -225,9 +225,7 @@
looks like the app's other inputs, not like ours. (Unlayered defaults would
have beaten Tailwind's layered utilities.) No min-height: a compact input
stays compact; the picker sets its own 44px where it needs it. */
/* span.wk-input, not .wk-input: structure must hold even when an app's own
unlayered input class sets display:block on this same element. */
span.wk-input {
.wk-input {
position: relative;
display: flex;
align-items: center;
@@ -246,9 +244,7 @@ span.wk-input {
color: inherit;
font: inherit;
font-size: var(--wk-text);
/* The font's own line height, exactly like a native input — a fixed 1.3
made the date box a different height from its neighbours. */
line-height: normal;
line-height: 1.3;
}
}
@@ -285,11 +281,10 @@ span.wk-input {
}
.wk-input-icon {
/* em, not rem, and no taller than a normal line: the icon scales with the
field's own text, so neither a dense 12px input nor a serif-font one is made
taller than its neighbours by it. */
width: 1.1em;
height: 1.1em;
/* em, not rem: the icon scales with the field's own text, so a dense 12px
input is not made taller than its neighbours by a fixed 20px icon. */
width: 1.25em;
height: 1.25em;
flex: 0 0 auto;
opacity: 0.7;
}
-17
View File
@@ -128,23 +128,6 @@ try {
`${name}: a 12px compact date input stays compact (${Math.round(compactHeight)}px)`,
);
// The date box is the same height as a native input given the same class —
// so a form row does not step when one field is a date.
const heights = await page.evaluate(() => ({
native: document.getElementById("match-native").getBoundingClientRect().height,
date: document.querySelector("#match-date .wk-input").getBoundingClientRect().height,
}));
check(
Math.abs(heights.native - heights.date) <= 1,
`${name}: date box matches a native input's height (${heights.date} vs ${heights.native})`,
);
// An app class with display:block on the same element must not break the layout.
const stacked = await page.evaluate(() => {
const box = document.querySelector("#block-class .wk-input");
return getComputedStyle(box).display;
});
check(stacked === "flex", `${name}: an app's display:block cannot break the box (${stacked})`);
const small = await page.evaluate(
() =>
[
-10
View File
@@ -160,13 +160,3 @@ test("a URL in a string does not hide the rest of the line", () => {
run(dir, ["--write"]);
assert.match(read(dir, "a.tsx"), /<DateInput type="date" \/>; \/\/ after/);
});
test("an object spread inside onChange is not flagged; a JSX prop spread still is", () => {
const dir = project({
"a.tsx": `import x from "x";\nexport const A = () => <input type="date" onChange={(e) => set({ ...form, date: e.target.value })} />;\n`,
"b.tsx": `import x from "x";\nexport const B = () => <input type="date" {...register("when")} />;\n`,
});
const out = run(dir);
assert.doesNotMatch(out, /a\.tsx:\d+ spreads props/);
assert.match(out, /b\.tsx:\d+ spreads props/);
});