Draw the checkbox and the selection controls' row without Tailwind
<x-checkbox> renders data-md-checkbox, its box, tick and dash, and its row, text and errors as data-md-* attributes; the 18px tick takes a size prop and a label-less box md-touch-target (plan step 36). selection.css moves into material.components as the row, text and state layer the three controls share, and each control's drawing goes to its own file: checkbox.css, radio.css, toggle.css, on the state tokens. The radio and the switch take the renamed shared hooks now and lose their layout classes in their own commits. field.js follows data-md-indeterminate. Renaming the switch's data-handle also stops selection.css matching the slider's handles, which it drew 24px above the track. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
co-authored by
Claude Opus 5
parent
3083fe28b2
commit
f86afc0542
@@ -51,6 +51,11 @@ class FieldProbe extends Component
|
||||
<x-input id="off-field" label="Off" value="Not editable" disabled />
|
||||
<x-input id="plain-name-field" label="Name, plain" wire:model="name" />
|
||||
<x-file id="upload-field" label="Upload" />
|
||||
<div style="display: flex; gap: 48px; padding: 24px">
|
||||
<x-checkbox id="bare-check" aria-label="Select every row" />
|
||||
<x-toggle id="bare-switch" aria-label="Bare switch" />
|
||||
<x-radio name="bare-radio" :options="[['id' => 'only', 'name' => '']]" />
|
||||
</div>
|
||||
|
||||
<x-button label="Save" wire:click="save" />
|
||||
</div>
|
||||
@@ -146,12 +151,12 @@ it('keeps a partly ticked checkbox in step with the server', function () {
|
||||
|
||||
$page->click('label[for="file-a"]')
|
||||
->assertSeeIn('#files', 'a')
|
||||
->assertScript("{$all}.hasAttribute('data-indeterminate') && {$all}.indeterminate");
|
||||
->assertScript("{$all}.hasAttribute('data-md-indeterminate') && {$all}.indeterminate");
|
||||
|
||||
$page->click('label[for="file-b"]')
|
||||
->click('label[for="file-c"]')
|
||||
->assertSeeIn('#files', 'a,b,c')
|
||||
->assertScript("! {$all}.hasAttribute('data-indeterminate') && ! {$all}.indeterminate");
|
||||
->assertScript("! {$all}.hasAttribute('data-md-indeterminate') && ! {$all}.indeterminate");
|
||||
});
|
||||
|
||||
it('moves between radio buttons with the arrow keys', function () {
|
||||
@@ -289,3 +294,21 @@ it('draws the field at M3\'s geometry and the file picker\'s button as a tonal p
|
||||
->assertScript("getComputedStyle(document.querySelector('#upload-field'), '::file-selector-button').borderTopLeftRadius !== '0px'")
|
||||
->assertScript("getComputedStyle(document.querySelector('#upload-field')).color === 'rgba(0, 0, 0, 0)'");
|
||||
});
|
||||
|
||||
it('lets a selection control without a label be pressed at the edge of its 48px target', function () {
|
||||
// A press 22px from the centre, past the drawn box but inside M3's 48px, lands on the control.
|
||||
$pressAtEdge = fn (string $input, string $dx, string $dy): string => "(() => {
|
||||
const input = document.querySelector('{$input}');
|
||||
input.scrollIntoView({ block: 'center' });
|
||||
const box = input.parentElement.getBoundingClientRect();
|
||||
const target = document.elementFromPoint(box.left + box.width / 2 + {$dx}, box.top + box.height / 2 + {$dy});
|
||||
target.click();
|
||||
|
||||
return input.checked;
|
||||
})()";
|
||||
|
||||
fieldProbe()
|
||||
->assertScript($pressAtEdge('#bare-check', '22', '0'))
|
||||
->assertScript($pressAtEdge('#bare-switch', '0', '22'))
|
||||
->assertScript($pressAtEdge('input[name=\"bare-radio\"]', '0', '-22'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user