Draw the loading indicator without Tailwind
Plan step 36. <x-loading> renders data-md-loading and data-md-contained, and loading.css in material.components draws the 48px indicator in primary, the contained circle and the still shape under reduced motion. The view no longer reads the caller's classes to decide its size and colour: a caller's utility outranks the package's layer on its own. ActionStylesheetsTest checks the group's stylesheets for the package's shape (layer statement, plain imports, material.components, tokens, px breakpoints, imports of rendered components) and its views for class lists; tests/Support/ComponentStylesheet reads a rule's declarations. 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
d7653aa6d0
commit
6c7414d60e
@@ -1,30 +1,47 @@
|
||||
<?php
|
||||
|
||||
it('is a named progressbar in the primary colour, 48px by default', function () {
|
||||
use NoNameWeb\LivewireMaterial\Tests\Support\ComponentStylesheet;
|
||||
|
||||
it('is a named progressbar, drawn by its stylesheet rather than by classes', function () {
|
||||
$html = (string) $this->blade('<x-loading />');
|
||||
|
||||
expect($html)
|
||||
->toContain('data-md-loading')
|
||||
->toContain('role="progressbar"')
|
||||
->toContain('aria-label="Loading"')
|
||||
->toContain('size-12')
|
||||
->toContain('text-primary')
|
||||
->toContain('<animateTransform')
|
||||
->toContain('class="size-full motion-reduce:hidden"')
|
||||
->toContain('class="hidden size-full motion-reduce:block"');
|
||||
->toMatch('/<svg data-md-loading-animated="data-md-loading-animated" aria-hidden="true" focusable="false"/')
|
||||
->toMatch('/<svg data-md-loading-still="data-md-loading-still" aria-hidden="true" focusable="false"/')
|
||||
->not->toContain('class=');
|
||||
});
|
||||
|
||||
it('sits on a primary-container circle when contained', function () {
|
||||
expect((string) $this->blade('<x-loading contained class="size-8" label="Uploading" />'))
|
||||
->toContain('rounded-corner-full bg-primary-container text-on-primary-container')
|
||||
->toContain('size-8')
|
||||
->not->toContain('size-12')
|
||||
it('is 48px in the primary colour unless the caller sizes or colours it', function () {
|
||||
$css = ComponentStylesheet::read('loading');
|
||||
|
||||
expect($css->declarations('[data-md-loading]'))
|
||||
->toMatchArray(['inline-size' => '48px', 'block-size' => '48px', 'color' => 'var(--md-sys-color-primary)'])
|
||||
// A caller's class lands on the root untouched, and outranks the package's layer.
|
||||
->and((string) $this->blade('<x-loading class="size-24 text-tertiary" label="Uploading" />'))
|
||||
->toContain('class="size-24 text-tertiary"')
|
||||
->toContain('aria-label="Uploading"');
|
||||
});
|
||||
|
||||
it('takes the caller\'s colour', function () {
|
||||
expect((string) $this->blade('<x-loading class="text-tertiary" />'))
|
||||
->toContain('text-tertiary')
|
||||
->not->toContain('text-primary');
|
||||
it('sits on a primary-container circle when contained', function () {
|
||||
expect((string) $this->blade('<x-loading contained />'))->toContain('data-md-contained')
|
||||
->and((string) $this->blade('<x-loading />'))->not->toContain('data-md-contained')
|
||||
->and(ComponentStylesheet::read('loading')->declarations('[data-md-loading][data-md-contained]'))->toBe([
|
||||
'border-radius' => 'var(--md-sys-shape-corner-full)',
|
||||
'background-color' => 'var(--md-sys-color-primary-container)',
|
||||
'color' => 'var(--md-sys-color-on-primary-container)',
|
||||
]);
|
||||
});
|
||||
|
||||
it('rests the same shape under reduced motion', function () {
|
||||
$css = ComponentStylesheet::read('loading');
|
||||
|
||||
expect($css->declarations('[data-md-loading] > [data-md-loading-still]'))->toBe(['display' => 'none'])
|
||||
->and($css->declarations('[data-md-loading] > [data-md-loading-animated]', ['@media (prefers-reduced-motion: reduce)']))->toBe(['display' => 'none'])
|
||||
->and($css->declarations('[data-md-loading] > [data-md-loading-still]', ['@media (prefers-reduced-motion: reduce)']))->toBe(['display' => 'block']);
|
||||
});
|
||||
|
||||
it('says nothing where something else already does', function () {
|
||||
|
||||
Reference in New Issue
Block a user