mirror of https://github.com/flightphp/core
Allow class components to return full <style> or <script> tags from css() and js(), while preserving default wrapping for raw CSS/JS strings. Add data-provider coverage and fixtures for both custom style and custom script tag behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>580-view-class-steroids
parent
dd238319da
commit
48035d6a92
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use flight\template\Component;
|
||||||
|
|
||||||
|
return new class extends Component
|
||||||
|
{
|
||||||
|
public function html(): string
|
||||||
|
{
|
||||||
|
return 'my-class-component-with-custom-script-tag';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function js(): string
|
||||||
|
{
|
||||||
|
return <<<'js'
|
||||||
|
<script type="module" data-component="my-class-component-with-custom-script-tag">
|
||||||
|
console.log('my-class-component-with-custom-script-tag')
|
||||||
|
</script>
|
||||||
|
js;
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use flight\template\Component;
|
||||||
|
|
||||||
|
return new class extends Component
|
||||||
|
{
|
||||||
|
public function html(): string
|
||||||
|
{
|
||||||
|
return <<<'html'
|
||||||
|
<span class="my-class-component-with-custom-style-tag">
|
||||||
|
my-class-component-with-custom-style-tag
|
||||||
|
</span>
|
||||||
|
html;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function css(): string
|
||||||
|
{
|
||||||
|
return <<<'css'
|
||||||
|
<style media="print" data-component="my-class-component-with-custom-style-tag">
|
||||||
|
.my-class-component-with-custom-style-tag {
|
||||||
|
color: purple;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
css;
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<f-my-class-component-with-custom-script-tag />
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<f-my-class-component-with-custom-style-tag />
|
||||||
Loading…
Reference in new issue