mirror of https://github.com/flightphp/core
parent
a94431ae05
commit
50c23de325
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace flight\template;
|
||||||
|
|
||||||
|
abstract class Component
|
||||||
|
{
|
||||||
|
abstract public function html(): string;
|
||||||
|
|
||||||
|
public function css(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function js(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use flight\template\Component;
|
||||||
|
|
||||||
|
return new class extends Component
|
||||||
|
{
|
||||||
|
#[Override]
|
||||||
|
public function html(): string
|
||||||
|
{
|
||||||
|
return <<<'html'
|
||||||
|
my-class-component-with-scripts
|
||||||
|
html;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Override]
|
||||||
|
public function js(): string
|
||||||
|
{
|
||||||
|
return <<<'js'
|
||||||
|
console.log('my-class-component-with-scripts')
|
||||||
|
js;
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use flight\template\Component;
|
||||||
|
|
||||||
|
return new class extends Component
|
||||||
|
{
|
||||||
|
#[Override]
|
||||||
|
public function html(): string
|
||||||
|
{
|
||||||
|
return <<<'html'
|
||||||
|
<span class="my-class-component-with-styles">
|
||||||
|
my-class-component-with-styles
|
||||||
|
</span>
|
||||||
|
html;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Override]
|
||||||
|
public function css(): string
|
||||||
|
{
|
||||||
|
return <<<'css'
|
||||||
|
.my-class-component-with-styles {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
css;
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use flight\template\Component;
|
||||||
|
|
||||||
|
return new class extends Component
|
||||||
|
{
|
||||||
|
#[Override]
|
||||||
|
public function html(): string
|
||||||
|
{
|
||||||
|
return <<<'html'
|
||||||
|
my-class-component
|
||||||
|
html;
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
<div>
|
||||||
|
my-component-with-subcomponent
|
||||||
|
<f-subcomponent />
|
||||||
|
</div>
|
||||||
@ -1 +1 @@
|
|||||||
value
|
my-component
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
return fn (): string => <<<'html'
|
||||||
|
my-functional-component
|
||||||
|
html;
|
||||||
@ -0,0 +1 @@
|
|||||||
|
subcomponent
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<f-my-class-component-with-scripts />
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<f-my-class-component-with-styles />
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<f-my-class-component />
|
||||||
@ -1,3 +1 @@
|
|||||||
<body>
|
|
||||||
<f-my-component />
|
<f-my-component />
|
||||||
</body>
|
|
||||||
|
|||||||
@ -1,3 +1 @@
|
|||||||
<body>
|
|
||||||
<?php $this->render('components/my-component') ?>
|
<?php $this->render('components/my-component') ?>
|
||||||
</body>
|
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
<f-my-component-with-subcomponent />
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<f-my-functional-component />
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<ul>
|
||||||
|
<?php for ($i = 1; $i <= 2; ++$i) : ?>
|
||||||
|
<li>
|
||||||
|
<f-my-component />
|
||||||
|
</li>
|
||||||
|
<?php endfor ?>
|
||||||
|
</ul>
|
||||||
Loading…
Reference in new issue