Fold the four groups' import check into one dataset over every component view
Action/Input/Containment/NavigationStylesheetsTest.php each carried the same "imports the stylesheet of every component its view renders" check on their own group's dataset. StylesheetsTest.php now runs it once, over every resources/views/components/*.blade.php backed by a stylesheet of its own (icon and shape included, no longer needing a group to run in at all; tabs/tab's shared stylesheet, N-16, still handled) — a new component gets the check by existing, not by being added to the right group's array too. Each group file keeps its own dataset for the checks that stay group-shaped (shape, tokens, breakpoints, the block it imports from). Plan step 42 (Phase F), Part A. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
4cf0997712
commit
34b77cfd31
@@ -7,10 +7,11 @@ use NoNameWeb\LivewireMaterial\Tests\Support\ViewClasses;
|
|||||||
/**
|
/**
|
||||||
* The actions and communication components, rewritten without Tailwind (plan step 36): each view
|
* The actions and communication components, rewritten without Tailwind (plan step 36): each view
|
||||||
* renders `data-md-*` attributes and no class list of its own beyond the interaction and text
|
* renders `data-md-*` attributes and no class list of its own beyond the interaction and text
|
||||||
* classes (tests/Support/ViewClasses.php), and each has a stylesheet in
|
* classes (tests/Support/ViewClasses.php), writes its values from the tokens and its breakpoints
|
||||||
* `material.components` that imports the stylesheets of the components its view renders, writes
|
* as px range queries, and is imported from the "Actions and communication" block of all.css.
|
||||||
* its values from the tokens and its breakpoints as px range queries, and is imported from the
|
* Every component stylesheet importing the stylesheets its view renders is
|
||||||
* "Actions and communication" block of all.css.
|
* tests/Feature/StylesheetsTest.php's now, folded into one dataset over every component view (step
|
||||||
|
* 42) rather than kept once per group.
|
||||||
*
|
*
|
||||||
* `icon` and `shape` are the two foundation components (`<x-icon>`, `<x-shape>`) — no group's view
|
* `icon` and `shape` are the two foundation components (`<x-icon>`, `<x-shape>`) — no group's view
|
||||||
* renders them exclusively, so they were in no group's dataset at all. They follow the same shape,
|
* renders them exclusively, so they were in no group's dataset at all. They follow the same shape,
|
||||||
@@ -57,20 +58,6 @@ it('draws the component from a stylesheet shaped like every package stylesheet',
|
|||||||
}
|
}
|
||||||
})->with('action components');
|
})->with('action components');
|
||||||
|
|
||||||
it('imports the stylesheet of every component its view renders', function (string $name) {
|
|
||||||
preg_match_all('/<x-livewire-material::([a-z-]+)/', File::get(__DIR__."/../../../resources/views/components/{$name}.blade.php"), $tags);
|
|
||||||
|
|
||||||
$rendered = collect($tags[1])->unique()
|
|
||||||
// A rendered tag that is not a components/ stylesheet at all (a layout component's, e.g.
|
|
||||||
// <x-pane>) has no import of its own to check here.
|
|
||||||
->filter(fn (string $tag): bool => is_file(ComponentStylesheet::path($tag)) && str_contains(File::get(ComponentStylesheet::path($tag)), '@layer material.components'))
|
|
||||||
->map(fn (string $tag): string => "./{$tag}.css")
|
|
||||||
->values()
|
|
||||||
->all();
|
|
||||||
|
|
||||||
expect(array_values(array_diff($rendered, ComponentStylesheet::read($name)->imports())))->toBe([]);
|
|
||||||
})->with('action components');
|
|
||||||
|
|
||||||
it('writes no class list into the view but the interaction and text classes', function (string $name) {
|
it('writes no class list into the view but the interaction and text classes', function (string $name) {
|
||||||
expect(ViewClasses::violations(File::get(__DIR__."/../../../resources/views/components/{$name}.blade.php")))->toBe([]);
|
expect(ViewClasses::violations(File::get(__DIR__."/../../../resources/views/components/{$name}.blade.php")))->toBe([]);
|
||||||
})->with('action components');
|
})->with('action components');
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ use NoNameWeb\LivewireMaterial\Tests\Support\ViewClasses;
|
|||||||
/**
|
/**
|
||||||
* The containment components, rewritten without Tailwind (plan step 36): each view renders
|
* The containment components, rewritten without Tailwind (plan step 36): each view renders
|
||||||
* `data-md-*` attributes and no class list of its own beyond the interaction and text classes
|
* `data-md-*` attributes and no class list of its own beyond the interaction and text classes
|
||||||
* (tests/Support/ViewClasses.php), and each has a stylesheet in `material.components` that imports
|
* (tests/Support/ViewClasses.php), writes its values from the tokens and its breakpoints as px
|
||||||
* the stylesheets of the components its view renders, writes its values from the tokens and its
|
* range queries, and is imported from the "Containment" block of all.css. Every component
|
||||||
* breakpoints as px range queries, and is imported from the "Containment" block of all.css.
|
* stylesheet importing the stylesheets its view renders is tests/Feature/StylesheetsTest.php's
|
||||||
|
* now, folded into one dataset over every component view (step 42) rather than kept once per
|
||||||
|
* group.
|
||||||
*
|
*
|
||||||
* The dataset grew by one name per component commit, the same rule InputStylesheetsTest.php and
|
* The dataset grew by one name per component commit, the same rule InputStylesheetsTest.php and
|
||||||
* ActionStylesheetsTest.php follow. The error layout, whose view is not a component, has the same
|
* ActionStylesheetsTest.php follow. The error layout, whose view is not a component, has the same
|
||||||
@@ -86,20 +88,6 @@ it('draws the component from a stylesheet shaped like every package stylesheet',
|
|||||||
}
|
}
|
||||||
})->with('containment components');
|
})->with('containment components');
|
||||||
|
|
||||||
it('imports the stylesheet of every component its view renders', function (string $name) {
|
|
||||||
preg_match_all('/<x-livewire-material::([a-z-]+)/', File::get(__DIR__."/../../../resources/views/components/{$name}.blade.php"), $tags);
|
|
||||||
|
|
||||||
$rendered = collect($tags[1])->unique()
|
|
||||||
// A rendered tag that is not a components/ stylesheet at all (a layout component's, e.g.
|
|
||||||
// <x-pane>) has no import of its own to check here.
|
|
||||||
->filter(fn (string $tag): bool => is_file(ComponentStylesheet::path($tag)) && str_contains(File::get(ComponentStylesheet::path($tag)), '@layer material.components'))
|
|
||||||
->map(fn (string $tag): string => "./{$tag}.css")
|
|
||||||
->values()
|
|
||||||
->all();
|
|
||||||
|
|
||||||
expect(array_values(array_diff($rendered, ComponentStylesheet::read($name)->imports())))->toBe([]);
|
|
||||||
})->with('containment components');
|
|
||||||
|
|
||||||
it('writes no class list into the view but the interaction and text classes', function (string $name) {
|
it('writes no class list into the view but the interaction and text classes', function (string $name) {
|
||||||
expect(ViewClasses::violations(File::get(__DIR__."/../../../resources/views/components/{$name}.blade.php")))->toBe([]);
|
expect(ViewClasses::violations(File::get(__DIR__."/../../../resources/views/components/{$name}.blade.php")))->toBe([]);
|
||||||
})->with('containment components');
|
})->with('containment components');
|
||||||
|
|||||||
@@ -7,15 +7,16 @@ use NoNameWeb\LivewireMaterial\Tests\Support\ViewClasses;
|
|||||||
/**
|
/**
|
||||||
* The inputs, selection and data components, rewritten without Tailwind (plan step 36): each view
|
* The inputs, selection and data components, rewritten without Tailwind (plan step 36): each view
|
||||||
* renders `data-md-*` attributes and no class list of its own beyond the interaction and text
|
* renders `data-md-*` attributes and no class list of its own beyond the interaction and text
|
||||||
* classes (tests/Support/ViewClasses.php), and each has a stylesheet in
|
* classes (tests/Support/ViewClasses.php), writes its values from the tokens and its breakpoints
|
||||||
* `material.components` that imports the stylesheets of the components its view renders, writes
|
* as px range queries, and is imported from the "Inputs, selection and data" block of all.css.
|
||||||
* its values from the tokens and its breakpoints as px range queries, and is imported from the
|
* Every component stylesheet importing the stylesheets its view renders is
|
||||||
* "Inputs, selection and data" block of all.css.
|
* tests/Feature/StylesheetsTest.php's now, folded into one dataset over every component view (step
|
||||||
|
* 42) rather than kept once per group.
|
||||||
*
|
*
|
||||||
* `pagination` is not in this dataset: its four views live in `resources/views/pagination/**`, not
|
* `pagination` is not in this dataset: its four views live in `resources/views/pagination/**`, not
|
||||||
* `resources/views/components/`, so the two checks that read a single `resources/views/components/
|
* `resources/views/components/`, so the check that reads a single `resources/views/components/
|
||||||
* {name}.blade.php` file do not apply to it. It gets the three checks that do not depend on that
|
* {name}.blade.php` file does not apply to it. It gets the two checks that do not depend on that
|
||||||
* path below, and its own small versions of the other two.
|
* path below, and its own small version of the third.
|
||||||
*/
|
*/
|
||||||
function inputComponents(): array
|
function inputComponents(): array
|
||||||
{
|
{
|
||||||
@@ -132,20 +133,6 @@ it('draws the component from a stylesheet shaped like every package stylesheet',
|
|||||||
}
|
}
|
||||||
})->with('input stylesheets');
|
})->with('input stylesheets');
|
||||||
|
|
||||||
it('imports the stylesheet of every component its view renders', function (string $name) {
|
|
||||||
preg_match_all('/<x-livewire-material::([a-z-]+)/', File::get(__DIR__."/../../../resources/views/components/{$name}.blade.php"), $tags);
|
|
||||||
|
|
||||||
$rendered = collect($tags[1])->unique()
|
|
||||||
// A rendered tag that is not a components/ stylesheet at all (a layout component's, e.g.
|
|
||||||
// <x-pane>) has no import of its own to check here.
|
|
||||||
->filter(fn (string $tag): bool => is_file(ComponentStylesheet::path($tag)) && str_contains(File::get(ComponentStylesheet::path($tag)), '@layer material.components'))
|
|
||||||
->map(fn (string $tag): string => "./{$tag}.css")
|
|
||||||
->values()
|
|
||||||
->all();
|
|
||||||
|
|
||||||
expect(array_values(array_diff($rendered, ComponentStylesheet::read($name)->imports())))->toBe([]);
|
|
||||||
})->with('input components');
|
|
||||||
|
|
||||||
it('writes no class list into the view but the interaction and text classes', function (string $name) {
|
it('writes no class list into the view but the interaction and text classes', function (string $name) {
|
||||||
expect(ViewClasses::violations(File::get(__DIR__."/../../../resources/views/components/{$name}.blade.php")))->toBe([]);
|
expect(ViewClasses::violations(File::get(__DIR__."/../../../resources/views/components/{$name}.blade.php")))->toBe([]);
|
||||||
})->with('input components');
|
})->with('input components');
|
||||||
|
|||||||
@@ -7,15 +7,14 @@ use NoNameWeb\LivewireMaterial\Tests\Support\ViewClasses;
|
|||||||
/**
|
/**
|
||||||
* The navigation components, rewritten without Tailwind (plan step 36, the last audit group): each
|
* The navigation components, rewritten without Tailwind (plan step 36, the last audit group): each
|
||||||
* view renders `data-md-*` attributes and no class list of its own beyond the interaction and text
|
* view renders `data-md-*` attributes and no class list of its own beyond the interaction and text
|
||||||
* classes (tests/Support/ViewClasses.php), and each has a stylesheet in `material.components` that
|
* classes (tests/Support/ViewClasses.php), writes its values from the tokens and its breakpoints
|
||||||
* imports the stylesheets of the components its view renders, writes its values from the tokens
|
* as px range queries, and is imported from the "Navigation" block of all.css. Every component
|
||||||
* and its breakpoints as px range queries, and is imported from the "Navigation" block of
|
* stylesheet importing the stylesheets its view renders is tests/Feature/StylesheetsTest.php's
|
||||||
* all.css.
|
* now, folded into one dataset over every component view (step 42, `tabs`/`tab`'s N-16 pairing
|
||||||
|
* included) rather than kept once per group.
|
||||||
*
|
*
|
||||||
* The dataset grows by one name per component commit, the same rule ContainmentStylesheetsTest.php
|
* The dataset grows by one name per component commit, the same rule ContainmentStylesheetsTest.php
|
||||||
* and the earlier groups follow. `<x-tabs>` and `<x-tab>` share one stylesheet (tabs.css) and one
|
* and the earlier groups follow. `navigation-bar` rejoined the dataset with the scaffold's own
|
||||||
* commit, so `navigationViews()` maps the 'tabs' entry onto both blade views; every other entry is
|
|
||||||
* one view, one stylesheet, as usual. `navigation-bar` rejoined the dataset with the scaffold's own
|
|
||||||
* rewrite: its one rule reading `--material-bottom-bar` stayed unlayered only while `<x-scaffold>`
|
* rewrite: its one rule reading `--material-bottom-bar` stayed unlayered only while `<x-scaffold>`
|
||||||
* published that variable through a Tailwind utility, which no layered rule could outrank; now
|
* published that variable through a Tailwind utility, which no layered rule could outrank; now
|
||||||
* scaffold.css sets it in `material.layout`, which this file's `material.components` always beats,
|
* scaffold.css sets it in `material.layout`, which this file's `material.components` always beats,
|
||||||
@@ -120,24 +119,6 @@ it('draws the component from a stylesheet shaped like every package stylesheet',
|
|||||||
}
|
}
|
||||||
})->with('navigation stylesheets');
|
})->with('navigation stylesheets');
|
||||||
|
|
||||||
it('imports the stylesheet of every component its view renders', function (string $name) {
|
|
||||||
$rendered = collect(navigationViews($name))
|
|
||||||
->flatMap(function (string $view): array {
|
|
||||||
preg_match_all('/<x-livewire-material::([a-z-]+)/', File::get(__DIR__."/../../../resources/views/components/{$view}.blade.php"), $tags);
|
|
||||||
|
|
||||||
return $tags[1];
|
|
||||||
})
|
|
||||||
->unique()
|
|
||||||
// A rendered tag that is not a components/ stylesheet at all (a layout component's, e.g.
|
|
||||||
// <x-pane>) has no import of its own to check here.
|
|
||||||
->filter(fn (string $tag): bool => is_file(ComponentStylesheet::path($tag)) && str_contains(File::get(ComponentStylesheet::path($tag)), '@layer material.components'))
|
|
||||||
->map(fn (string $tag): string => "./{$tag}.css")
|
|
||||||
->values()
|
|
||||||
->all();
|
|
||||||
|
|
||||||
expect(array_values(array_diff($rendered, ComponentStylesheet::read($name)->imports())))->toBe([]);
|
|
||||||
})->with('navigation components');
|
|
||||||
|
|
||||||
it('writes no class list into the view but the interaction and text classes', function (string $name) {
|
it('writes no class list into the view but the interaction and text classes', function (string $name) {
|
||||||
foreach (navigationViews($name) as $view) {
|
foreach (navigationViews($name) as $view) {
|
||||||
expect(ViewClasses::violations(File::get(__DIR__."/../../../resources/views/components/{$view}.blade.php")))->toBe([]);
|
expect(ViewClasses::violations(File::get(__DIR__."/../../../resources/views/components/{$view}.blade.php")))->toBe([]);
|
||||||
|
|||||||
@@ -471,6 +471,53 @@ it('gives every component view a stylesheet, or lists it on a short, documented
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Every component view the four group stylesheet tests (Action/Input/Containment/Navigation) used
|
||||||
|
* to check one at a time, in one dataset instead: every `resources/views/components/*.blade.php`
|
||||||
|
* backed by a `components/*.css` file of its own, `tabs` and `tab` folded into the one entry
|
||||||
|
* `imports…()` below already special-cases (they share tabs.css, N-16), `theme-script` (no
|
||||||
|
* stylesheet at all) and every layout component (the test above covers those) left out.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
function componentStylesheetViews(): array
|
||||||
|
{
|
||||||
|
// Plain glob(), not the File facade: dataset() below runs while the file is parsed, before
|
||||||
|
// Pest has booted the application the facade needs.
|
||||||
|
return collect(glob(__DIR__.'/../../resources/views/components/*.blade.php'))
|
||||||
|
->map(fn (string $file): string => basename($file, '.blade.php'))
|
||||||
|
->reject(fn (string $name): bool => in_array($name, ['theme-script', 'tab'], true))
|
||||||
|
->filter(fn (string $name): bool => is_file(__DIR__."/../../resources/css/components/{$name}.css"))
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
dataset('component stylesheet views', componentStylesheetViews());
|
||||||
|
|
||||||
|
it('imports, from every component stylesheet, the stylesheet of each component its view renders', function (string $name) {
|
||||||
|
// tabs.css is shared by two views, tabs.blade.php and tab.blade.php (N-16); every other
|
||||||
|
// component stylesheet in this dataset has exactly one view of its own name.
|
||||||
|
$views = $name === 'tabs' ? ['tabs', 'tab'] : [$name];
|
||||||
|
|
||||||
|
$rendered = collect($views)
|
||||||
|
->flatMap(function (string $view): array {
|
||||||
|
preg_match_all('/<x-livewire-material::([a-z-]+)/', File::get(__DIR__."/../../resources/views/components/{$view}.blade.php"), $tags);
|
||||||
|
|
||||||
|
return $tags[1];
|
||||||
|
})
|
||||||
|
->unique()
|
||||||
|
// A rendered tag that is not a components/ stylesheet at all (a layout component's, e.g.
|
||||||
|
// <x-pane>) has no import of its own to check here.
|
||||||
|
->filter(fn (string $tag): bool => is_file(stylesheetPath("components/{$tag}.css")) && str_contains(File::get(stylesheetPath("components/{$tag}.css")), '@layer material.components'))
|
||||||
|
->map(fn (string $tag): string => "./{$tag}.css")
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
|
||||||
|
$imports = stylesheetImports(stylesheetPath("components/{$name}.css"));
|
||||||
|
|
||||||
|
expect(array_values(array_diff($rendered, $imports)))->toBe([]);
|
||||||
|
})->with('component stylesheet views');
|
||||||
|
|
||||||
it('imports a stylesheet for every layout component from all.css, each beside its view', function () {
|
it('imports a stylesheet for every layout component from all.css, each beside its view', function () {
|
||||||
$imports = array_values(array_filter(
|
$imports = array_values(array_filter(
|
||||||
stylesheetImports(stylesheetPath('all.css')),
|
stylesheetImports(stylesheetPath('all.css')),
|
||||||
|
|||||||
Reference in New Issue
Block a user