Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEBUG demo
Browse files Browse the repository at this point in the history
mvorisek committed Dec 22, 2022

Verified

This commit was signed with the committer’s verified signature.
torkelrogstad Torkel Rogstad
1 parent 1e41009 commit 4d9d805
Showing 2 changed files with 14 additions and 72 deletions.
84 changes: 13 additions & 71 deletions demos/basic/button.php
Original file line number Diff line number Diff line change
@@ -4,13 +4,8 @@

namespace Atk4\Ui\Demos;

use Atk4\Ui\Button;
use Atk4\Ui\Form;
use Atk4\Ui\Header;
use Atk4\Ui\HtmlTemplate;
use Atk4\Ui\Icon;
use Atk4\Ui\Label;
use Atk4\Ui\Table;
use Atk4\Ui\View;

/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';
@@ -19,69 +14,16 @@

Header::addTo($app, ['Basic Button', 'size' => 2]);

// With Seed
Button::addTo($app, ['Click me'])->link(['index']);

// Without Seeding
$b1 = new Button('Click me (no seed)');
$app->add($b1);
// must be added first
$b1->link(['index']);

Header::addTo($app, ['Properties', 'size' => 2]);
Button::addTo($app, ['Primary button', 'class.primary' => true]);
Button::addTo($app, ['Load', 'class.labeled' => true, 'icon' => 'pause']);
Button::addTo($app, ['Next', 'iconRight' => 'right arrow']);
Button::addTo($app, ['class.circular' => true, 'icon' => 'settings']);

Header::addTo($app, ['Big Button', 'size' => 2]);
Button::addTo($app, ['Click me', 'class.big primary' => true, 'icon' => 'check']);

Header::addTo($app, ['Button Intent', 'size' => 2]);
Button::addTo($app, ['Yes', 'class.positive basic' => true]);
Button::addTo($app, ['No', 'class.negative basic' => true]);

Header::addTo($app, ['Combining Buttons', 'size' => 2]);

$bar = View::addTo($app, ['ui' => 'vertical buttons']);
Button::addTo($bar, ['Play', 'icon' => 'play']);
Button::addTo($bar, ['Pause', 'icon' => 'pause']);
Button::addTo($bar, ['Shuffle', 'icon' => 'shuffle']);

Header::addTo($app, ['Icon Bar', 'size' => 2]);
$bar = View::addTo($app, ['ui' => 'big blue buttons']);
Button::addTo($bar, ['icon' => 'file']);
Button::addTo($bar, ['icon' => 'yellow save']);
Button::addTo($bar, ['icon' => 'upload', 'class.disabled' => true]);

Header::addTo($app, ['Forks Button Component', 'size' => 2]);

// Creating your own button component example

/** @var Button $forkButtonClass */
$forkButtonClass = AnonymousClassNameCache::get_class(fn () => new class(0) /* need 0 argument here for constructor */ extends Button {
public function __construct(int $n)
{
Icon::addTo(Button::addTo($this, ['Forks', 'class.blue' => true]), ['fork']);
Label::addTo($this, [number_format($n), 'class.basic blue left pointing' => true]);

parent::__construct(['class.labeled' => true]);
}
$form = Form::addTo($app);
$recipient = $form->addControl(
'recipient',
[Form\Control\Dropdown::class,
'values' => [],
'isMultiple' => true,
'dropdownOptions' => ['allowAdditions' => true, 'forceSelection' => false],
],
['default' => 'Username <[email protected]>']
);
$form->onSubmit(function () use ($form) {
echo $form->getApp()->getTag('pre', [], print_r($form->model->get(), true));
});

$forkButton = new $forkButtonClass(1234 + random_int(1, 100));
$app->add($forkButton);

Header::addTo($app, ['Custom Template', 'size' => 2]);

$view = View::addTo($app, ['template' => new HtmlTemplate('Hello, {$tag1}, my name is {$tag2}')]);

Button::addTo($view, ['World'], ['tag1']);
Button::addTo($view, ['Agile UI', 'class.blue' => true], ['tag2']);

Header::addTo($app, ['Attaching', 'size' => 2]);

Button::addTo($app, ['Previous', 'class.top attached' => true]);
Table::addTo($app, ['class.attached' => true, 'header' => false])
->setSource(['One', 'Two', 'Three', 'Four']);
Button::addTo($app, ['Next', 'class.bottom attached' => true]);
2 changes: 1 addition & 1 deletion demos/init-app.php
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ public static function get_class(\Closure $createAnonymousClassFx): string
$app->initLayout([!isset($_GET['layout']) ? Layout\Maestro::class : $app->stickyGet('layout')]);

$layout = $app->layout;
if ($layout instanceof Layout\NavigableInterface) {
if (false && $layout instanceof Layout\NavigableInterface) {
$layout->addMenuItem(['Welcome to Agile Toolkit', 'icon' => 'gift'], [$demosUrl . 'index']);

$path = $demosUrl . 'layout/';

0 comments on commit 4d9d805

Please sign in to comment.