Skip to content

Commit

Permalink
Merge branch 'release/0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
romaninsh committed Feb 10, 2017
2 parents 96b63f6 + 0298047 commit 4d71465
Show file tree
Hide file tree
Showing 58 changed files with 1,288 additions and 302 deletions.
1 change: 1 addition & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ engines:
enabled: true
exclude_fingerprints:
- 908ad3f93985ff14c44615cee6966c72 # View have a lot of public methods. Deal with it.
- 81ca5382dedb709060ec70ffea74e157 # allow exit in a call-back inside app constructor
checks:
Naming/ShortVariable:
enabled: false # because of on() and js() and $ui
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4

* Implemented Layouts (Admin / Centered) #33
* Created nicer demos

## 0.3

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
"require": {
"php": ">=5.6.0",
"atk4/data": "^1.1.8",
"atk4/core": "^1.1.9",
"facebook/webdriver": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"facebook/webdriver": "^1.1",
"phpunit/phpunit-selenium": ">=1.2",
"fzaninotto/faker": "*",
"atk4/core": "~1.1.8",
"atk4/core": "^1.1.9",
"semantic/ui": "*",
"codeclimate/php-test-reporter": "*"
},
Expand Down
106 changes: 47 additions & 59 deletions demos/button.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Demonstrates how to use layouts.
*/
require '../vendor/autoload.php';
require 'init.php';
use \atk4\ui\Button;
use \atk4\ui\Buttons;
use \atk4\ui\H2;
Expand All @@ -11,76 +11,64 @@
use \atk4\ui\Template;
use \atk4\ui\View;

try {
$layout = new \atk4\ui\Layout\App(['defaultTemplate'=>'./templates/layout2.html']);
$layout->add(new H2('Basic Button'));
$layout->add(new Button())->set('Click me');

$layout->add(new H2('Basic Button'));
$layout->add(new Button())->set('Click me');
$layout->add(new H2('Properties'));

$layout->add(new H2('Properties'));
$b1 = new Button();
$b2 = new Button();
$b3 = new Button();

$b1 = new Button();
$b2 = new Button();
$b3 = new Button();
$b1->set(['Load', 'primary']);
$b2->set(['Load', 'labeled', 'icon'=>'pause']);
$b3->set(['Next', 'right labeled', 'icon'=>'right arrow']);
$layout->add($b1);
$layout->add($b2);
$layout->add($b3);

$b1->set(['Load', 'primary']);
$b2->set(['Load', 'labeled', 'icon'=>'pause']);
$b3->set(['Next', 'right labeled', 'icon'=>'right arrow']);
$layout->add($b1);
$layout->add($b2);
$layout->add($b3);
$button = new Button();
$button->set('Click me');
$button->set(['primary' => true]);
$button->set(['icon'=>'check']);
$button->set(['size big'=>true]);

$button = new Button();
$button->set('Click me');
$button->set(['primary' => true]);
$button->set(['icon'=>'check']);
$button->set(['size big'=>true]);
$layout->add(new H2('Big Button'));

$layout->add(new H2('Big Button'));
$layout->add($button);

$layout->add($button);
$layout->add(new H2('Button Intent'));

$layout->add(new H2('Button Intent'));
$b_yes = new Button(['Yes', 'positive basic']);
$b_no = new Button(['No', 'negative basic']);
$layout->add($b_yes);
$layout->add($b_no);

$b_yes = new Button(['Yes', 'positive basic']);
$b_no = new Button(['No', 'negative basic']);
$layout->add($b_yes);
$layout->add($b_no);
$layout->add(new H2('Combining Buttons'));
$bar = new Buttons('vertical'); // NOTE: class called Buttons, not Button
$bar->add(new Button(['Play', 'icon'=>'play']));
$bar->add(new Button(['Pause', 'icon'=>'pause']));
$bar->add(new Button(['Shuffle', 'icon'=>'shuffle']));

$layout->add(new H2('Combining Buttons'));
$bar = new Buttons('vertical'); // NOTE: class called Buttons, not Button
$bar->add(new Button(['Play', 'icon'=>'play']));
$bar->add(new Button(['Pause', 'icon'=>'pause']));
$bar->add(new Button(['Shuffle', 'icon'=>'shuffle']));
$layout->add($bar);

$layout->add($bar);
$layout->add(new H2('Icon Bar'));
$bar = new Buttons('blue big');
$bar->add(new Button(['icon'=>'file']));
$bar->add(new Button(['icon'=>['save', 'yellow']]));
$bar->add(new Button(['icon'=>'upload', 'disabled'=>true]));
$layout->add($bar);

$layout->add(new H2('Icon Bar'));
$bar = new Buttons('blue big');
$bar->add(new Button(['icon'=>'file']));
$bar->add(new Button(['icon'=>['save', 'yellow']]));
$bar->add(new Button(['icon'=>'upload', 'disabled'=>true]));
$layout->add($bar);
$layout->add(new H2('Forks'));
$forks = new Button(['labeled'=> true]); // Button, not Buttons!
$forks->add(new Button(['Forks', 'blue']))->add(new Icon('fork'));
$forks->add(new Label(['1,048', 'basic blue left pointing']));
$layout->add($forks);

$layout->add(new H2('Forks'));
$forks = new Button(['labeled'=> true]); // Button, not Buttons!
$forks->add(new Button(['Forks', 'blue']))->add(new Icon('fork'));
$forks->add(new Label(['1,048', 'basic blue left pointing']));
$layout->add($forks);
$layout->add(new H2('Custom Template'));
$view = new View(['template'=>new Template('Hello, {$tag1}, my name is {$tag2}')]);

$layout->add(new H2('Custom Template'));
$view = new View(['template'=>new Template('Hello, {$tag1}, my name is {$tag2}')]);
$view->add(new Button('World'), 'tag1');
$view->add(new Button(['Agile UI', 'blue']), 'tag2');

$view->add(new Button('World'), 'tag1');
$view->add(new Button(['Agile UI', 'blue']), 'tag2');

$layout->add($view);

echo $layout->render();
} catch (\atk4\core\Exception $e) {
var_dump($e->getMessage());

var_dump($e->getParams());
var_dump($e->getTrace());
throw $e;
}
$layout->add($view);
36 changes: 13 additions & 23 deletions demos/button2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,30 @@
/**
* Demonstrates how to use interractive buttons.
*/
require '../vendor/autoload.php';
include 'init.php';

use \atk4\ui\Button;
use \atk4\ui\Buttons;
use \atk4\ui\H2;

try {
$layout = new \atk4\ui\Layout\App(['defaultTemplate'=>'./templates/layout2.html']);

$layout->js(true, new \atk4\ui\jsExpression('$.fn.api.settings.successTest = function(response) {
$layout->js(true, new \atk4\ui\jsExpression('$.fn.api.settings.successTest = function(response) {
if(response && response.eval) {
var result = function(){ eval(response.eval); }.call(this.obj);
}
return false;
}'));

$layout->add(new H2('Basic Button'));

$b = $layout->add(new Button(['id'=>'b1']))->set('Hidden Button');
$b->js(true)->hide();

$b = $layout->add(new Button(['id'=>'b2']))->set('Hide on click Button');
$b->js('click')->hide();
$layout->add(new H2('Basic Button'));

$layout->add(new H2('Callbacks'));
$b = $layout->add(new Button(['id'=>'b1']))->set('Hidden Button');
$b->js(true)->hide();

$b = $layout->add(new Button(['id'=>'b3']))->set('Callback Test');
$b->on('click', function ($b) {
return $b->text(rand(1, 20));
});
$b = $layout->add(new Button(['id'=>'b2']))->set('Hide on click Button');
$b->js('click')->hide();

echo $layout->render();
} catch (\atk4\core\Exception $e) {
var_dump($e->getMessage());
$layout->add(new H2('Callbacks'));

var_dump($e->getParams());
throw $e;
}
$b = $layout->add(new Button(['id'=>'b3']))->set('Callback Test');
$b->on('click', function ($b) {
return $b->text(rand(1, 20));
});
34 changes: 34 additions & 0 deletions demos/demo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<html>
<head>
<!-- Standard Meta-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<!-- Site Properties-->
<title>Agile UI - Button Test</title>
<link rel="stylesheet" type="text/css" href="http://semantic-ui.com/dist/semantic.css">
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
<script src="http://semantic-ui.com/dist/semantic.js"></script>
</head>
<body>

<?php

require '../vendor/autoload.php';

$button = new \atk4\ui\Button('hello');
$button->init();
echo $button->render();

exit;

$app = new \atk4\ui\App('Hello');

$layout = new \atk4\ui\Layout\Centered();

$layout->add(new \atk4\ui\Button(['PHP7 Rocks', 'icon'=>'book', 'blue']));

$app->setLayout($layout);
$app->run();

//\atk4\ui\Layout\Centered();
6 changes: 6 additions & 0 deletions demos/error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

include 'init.php';

// Next line produces exception, which Agile UI will catch and display nicely.
$layout->add(new \atk4\ui\View(['foo'=>'bar']));
Loading

0 comments on commit 4d71465

Please sign in to comment.