Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

dependencies + performance + archives #70

Merged
merged 1 commit into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
],
"require": {
"php": "~7.0|^8.0",
"8fold/php-shoop-shelf": "~0.7",
"8fold/php-shoop-shelf": "~0.8",
"8fold/php-html-spec": "~0.0.3",
"8fold/commonmark-abbreviations": "~1.0.3",
"8fold/commonmark-accordions": "~1.0",
"nesbot/carbon": "~2.36"
"8fold/commonmark-abbreviations": "~1.2",
"8fold/commonmark-accordions": "~1.0.4",
"nesbot/carbon": "~2.5"
},
"require-dev": {
"phpunit/phpunit": "~9.1"
Expand Down
439 changes: 217 additions & 222 deletions composer.lock

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions markup-zzArchive/UIKit/test/zzArchive/FormControlsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Eightfold\Markup\Tests\UIKit;

use Eightfold\Markup\Tests\TestCase;
use Eightfold\Foldable\Tests\TestEqualsPerformance as AssertEquals;

use Carbon\Carbon;

use Eightfold\Markup\UIKit;
use Eightfold\Markup\UIKit\FormControls\InputText;

class FormControlsTest extends TestCase
{
protected $maxMilliseconds = 5.5;

public function testFlowsToHtml()
{
$expected = '<input type="text" placeholder="hello">';
$actual = UIKit::input()->attr("type text", "placeholder hello");
$this->assertEqualsWithPerformance($expected, $actual->unfold(), 11.25);
}

// public function testFileInputBase()
// {
// $expected = '<div><label for="some_file">Label</label><input id="some_file" type="file" name="some_file" required></div>';
// $result = UIKit::fileInput('Label', 'some_file')->unfold();
// $this->assertEqualsWithPerformance($expected, $result);
// }

// public function testHiddenInputBase()
// {
// $expected = '<input type="hidden" name="input_name" value="input_value">';
// $result = UIKit::hiddenInput('input_name', 'input_value')->unfold();
// $this->assertEqualsWithPerformance($expected, $result);
// }

// public function testStripeElementsBase()
// {
// $expected = "<div><label for=\"this_form-label\">Input label</label><span id=\"this_form-errors\"></span><div id=\"this_form-element\"></div><ef-button>Button label</ef-button><script type=\"text/javascript\">const stripeForthis_form = Stripe('MY_API_KEY'); const elementsForthis_form = stripeForthis_form.elements(); const this_formStyle={base:{color:'#32325d',lineHeight:'24px',fontFamily:'\"Helvetica Neue\", Helvetica, sans-serif',fontSmoothing: 'antialiased',fontSize:'16px','::placeholder':{color:'#aab7c4'}},invalid:{color:'#fa755a',iconColor:'#fa755a'}}; const cardforthis_form = elementsForthis_form.create('card', {style: this_formStyle}); cardforthis_form.mount('#this_form-element');cardforthis_form.addEventListener('change', function(event) {var displayError = document.getElementById('card-errors');if (event.error) {displayError.textContent = event.error.message;} else {displayError.textContent = '';}});const this_formTokenHandler = function(token) {const form = document.getElementById('this_form');const hiddenInput = document.createElement('input');hiddenInput.setAttribute('type', 'hidden');hiddenInput.setAttribute('name', 'stripeToken');hiddenInput.setAttribute('value', token.id);form.appendChild(hiddenInput);form.submit();};</script></div>";
// $result = UIKit::stripeElements(
// 'this_form'
// , 'MY_API_KEY'
// , 'Input label'
// , 'Button label')->unfold();
// $this->assertEqualsWithPerformance($expected, $result);
// }
}
40 changes: 40 additions & 0 deletions markup-zzArchive/UIKit/zzArchive/Compound/ActionContainer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Eightfold\Markup\UIKit\Elements\Compound;

use Eightfold\Html\Elements\HtmlElement;

use Eightfold\HtmlComponent\Component;
use Eightfold\UIKit\UIKit;
use Eightfold\Html\Html;
use Eightfold\Html\Elements\Grouping\Div;

class ActionContainer extends HtmlElement
{
private $method = '';
private $action = '';

private $left = null;
private $right = null;

public function __construct(string $methodAction, Div $left, Div $right)
{
list($method, $action) = parent::splitFirstSpace($methodAction);

$this->method = $method;
$this->action = $action;

$this->left = $left;
$this->right = $right;
}

public function compile(): string
{
$attr = array_merge(['method '. $this->method, 'action '. $this->action], $this->getAttr());
return Html::form(
$this->left
, $this->right
)->is('ef-action-container')
->compile(...$attr);
}
}
70 changes: 70 additions & 0 deletions markup-zzArchive/UIKit/zzArchive/Compound/Alert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace Eightfold\Markup\UIKit\Elements\Compound;

use Eightfold\HtmlComponent\Component;
use Eightfold\Html\Html;
use Eightfold\UIKit\UIKit;

class Alert
{
private $title = '';
private $body = '';

private $interactive = false;

private $type = 'info';

public function __construct(string $title, string $body)
{
$this->title = Component::text($title);
$this->body = $body;
}

public function unfold(): string
{
$role = 'role alert';
if ($this->interactive) {
$role = 'role alertdialog';
}
// TODO: Allow classing or styling by user
return Html::div(
Html::div(
Html::h3($this->title)->attr('class ef-alert-heading')
, UIKit::markdown($this->body)
)->attr('class ef-alert-body')
)->attr($role, 'class ef-alert ef-alert-'. $this->type .' single-centered')
->compile();
}

public function info()
{
$this->type = 'info';
return $this;
}

public function success()
{
$this->type = 'success';
return $this;
}

public function warning()
{
$this->type = 'warning';
return $this;
}

public function error()
{
$this->type = 'error';
return $this;
}

public function interactive()
{
$this->interactive = true;
return $this;
}
}

62 changes: 62 additions & 0 deletions markup-zzArchive/UIKit/zzArchive/Compound/Head.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Eightfold\Markup\UIKit\Elements\Compound;

use Eightfold\Html\Elements\HtmlElement;

use Eightfold\HtmlComponent\Component;
use Eightfold\Html\Html;

use Eightfold\UIKit\Traits\ExternalStylesAndScripts;

class Head extends HtmlElement
{
use ExternalStylesAndScripts;

private $title = 'Page title';

private $styles = [];
private $scripts = [];

public function __construct(string $title)
{
$this->title = $title;
}

public function compile(string ...$attributes): string
{
$titleAndMeta = [
Html::title(Component::text($this->title))
];

$styles = [];
foreach ($this->styles as $styleUrl) {
$styles[] = Html::link()
->attr(
'href '. $styleUrl
, 'rel stylesheet'
, 'type text/css');
}

$scripts = [];
foreach($this->scripts as $script) {
$scripts[] = Html::script()
->attr('src '. $script);
}


return Html::head(...array_merge($titleAndMeta, $styles, $scripts))->compile();
}

public function styles(string ...$styles)
{
$this->styles = $styles;
return $this;
}

public function scripts(string ...$scripts)
{
$this->scripts = $scripts;
return $this;
}
}
46 changes: 46 additions & 0 deletions markup-zzArchive/UIKit/zzArchive/Compound/Header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Eightfold\Markup\UIKit\Elements\Compound;

use Eightfold\Html\Elements\HtmlElement;

use Eightfold\HtmlComponent\Component;
use Eightfold\HtmlComponent\Interfaces\Compile;
use Eightfold\Html\Html;
use Eightfold\UIKit\UIKit;
use Eightfold\UIKit\Elements\Simple\Link;

use Eightfold\UIKit\Traits\PrimaryAndSecondaryNav;

class Header extends HtmlElement
{
private $buttonLabel = 'show menu';
private $links = [];

public function __construct(string $buttonLabel, Compile ...$links)
{
$this->buttonLabel = $buttonLabel;
$this->links = $links;
}

public function compile(string ...$attributes): string
{
return Html::header(
Html::nav(
Html::button(
Component::text($this->buttonLabel)
)->is('ef-button')->attr('class collapsable')
, $this->linkList($this->links)
)
)->compile();
}

private function linkList(array $links) {
$listItems = [];
foreach ($links as $link) {
$listItems[] = Html::li($link);
}

return Html::ul(...$listItems)->attr('class collapsed');
}
}
40 changes: 40 additions & 0 deletions markup-zzArchive/UIKit/zzArchive/Compound/NavigationSecondary.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Eightfold\Markup\UIKit\Elements\Compound;

use Eightfold\Html\Elements\HtmlElement;

use Eightfold\UIKit\UIKit;
use Eightfold\Html\Html;
use Eightfold\UIKit\Elements\Simple\Link;

class NavigationSecondary extends HtmlElement
{
private $links = [];

public function __construct(Link ...$links)
{
$this->links = $links;
}

public function compile(string ...$attributes): string
{
$list = Html::ul(...$this->processLinks($this->links));

$nav = Html::nav($list)
->is('ef-secondary-nav')
->attr(...$this->getAttr());

return $nav->compile();
}

protected function processLinks(array $linksToProcess)
{
$links = [];
foreach ($linksToProcess as $link) {
list($text, $path) = $link;
$links[] = Html::li(UIKit::link($text, $path));
}
return $links;
}
}
42 changes: 42 additions & 0 deletions markup-zzArchive/UIKit/zzArchive/Compound/NavigationSide.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Eightfold\Markup\UIKit\Elements\Compound;

use Eightfold\Html\Elements\HtmlElement;

use Eightfold\HtmlComponent\Component;
use Eightfold\Html\Html;
use Eightfold\UIKit\UIKit;
use Eightfold\UIKit\Elements\Simple\Link;

class NavigationSide extends HtmlElement
{
private $links = [];

public function __construct(Link ...$links)
{
$this->links = $links;
}

public function compile(string ...$attributes): string
{
$list = Html::ul(...$this->processLinks($this->links))->attr('class collapsed');

$nav = Html::aside(
Html::button(Component::text('user menu'))->attr('class collapsable')
, $list
)->is('ef-side-navigation')
->attr(...$this->getAttr());
return $nav->compile();
}

protected function processLinks(array $linksToProcess)
{
$links = [];
foreach ($linksToProcess as $link) {
$links[] = Html::li($link);
}
return $links;
}
}

Loading