From a8b0c6e311afbca93380870173cfa3543ace33a8 Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Mon, 20 Sep 2021 18:45:20 -0500 Subject: [PATCH 01/10] Page title --- src/UIKit.php | 5 +++ src/UIKit/Elements/Simple/PageTitle.php | 44 +++++++++++++++++++++++++ tests/UIKit/SimpleTest.php | 33 +++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100755 src/UIKit/Elements/Simple/PageTitle.php diff --git a/src/UIKit.php b/src/UIKit.php index 41c279d..696bcee 100755 --- a/src/UIKit.php +++ b/src/UIKit.php @@ -15,6 +15,11 @@ static public function webView($title, ...$content) return new UIKit\Elements\Pages\WebView($title, ...$content); } + static public function pageTitle($titleParts, $separater = " | ") + { + return new UIKit\Elements\Simple\PageTitle($titleParts, $separater); + } + static public function webHead() { return new UIKit\Elements\Compound\WebHead(); diff --git a/src/UIKit/Elements/Simple/PageTitle.php b/src/UIKit/Elements/Simple/PageTitle.php new file mode 100755 index 0000000..f533644 --- /dev/null +++ b/src/UIKit/Elements/Simple/PageTitle.php @@ -0,0 +1,44 @@ +main = $titleParts; + + $this->separater = $separater; + } + + public function unfold(): string + { + if (count($this->main) === 0) { + return ""; + } + + if ($this->reversed) { + $this->main = array_reverse($this->main); + } + + $string = implode($this->separater, $this->main); + + return Html::title($string)->attr(...$this->attributes)->unfold(); + } + + public function reversed(): PageTitle + { + $this->reversed = true; + return $this; + } +} diff --git a/tests/UIKit/SimpleTest.php b/tests/UIKit/SimpleTest.php index ce3603e..b07110a 100755 --- a/tests/UIKit/SimpleTest.php +++ b/tests/UIKit/SimpleTest.php @@ -28,6 +28,39 @@ public function uikit_falls_back_to_html() ); } + /** + * @test + */ + public function page_title() + { + AssertEquals::applyWith( + 'Hello, World!', + "string", + 0.91, // 0.71, // 0.6, + 4 + )->unfoldUsing( + UIKit::pageTitle(["Hello, World!"]) + ); + + AssertEquals::applyWith( + 'How are you? | Hello, World!', + "string", + 0.91, // 0.71, // 0.6, + 3 + )->unfoldUsing( + UIKit::pageTitle(["How are you?", "Hello, World!"]) + ); + + AssertEquals::applyWith( + 'How are you? : Hello, World!', + "string", + 0.91, // 0.71, // 0.6, + 3 + )->unfoldUsing( + UIKit::pageTitle(["Hello, World!", "How are you?"], " : ")->reversed() + ); + } + /** * @test */ From 6a81cedbe1903b5715d34ac2dd589d33d45a43f5 Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Mon, 20 Sep 2021 18:50:14 -0500 Subject: [PATCH 02/10] update tests --- tests/Html/HtmlElementTest.php | 4 ++-- tests/UIKit/CompoundTest.php | 2 +- tests/UIKit/SimpleTest.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Html/HtmlElementTest.php b/tests/Html/HtmlElementTest.php index 9432de8..4cab1e7 100644 --- a/tests/Html/HtmlElementTest.php +++ b/tests/Html/HtmlElementTest.php @@ -26,7 +26,7 @@ public function test_ordering_lightweight() AssertEquals::applyWith( '', "string", - 10.03, // 9.89, // 9.69, // 8.42, // 8.34, // 7.8, // 7.38, // updated shoop 8.11 // 7.82 // 7.6 // 6.85 + 10.52, // 10.03, // 9.89, // 9.69, // 8.42, // 8.34, // 7.8, // 7.38, // updated shoop 8.11 // 7.82 // 7.6 // 6.85 559 )->unfoldUsing( Html::p('Hello') @@ -148,7 +148,7 @@ public function nested_elements_with_string() AssertEquals::applyWith( 'Hello', "string", - 4.04, // 3.99, // 3.93, // 3.9, // 3.75, // 3.32, // 1.76, // 1.6, // 1.56, // 1.21, // 1.13, // 0.97, // 0.87, // 2.37 + 4.5, // 4.04, // 3.99, // 3.93, // 3.9, // 3.75, // 3.32, // 1.76, // 1.6, // 1.56, // 1.21, // 1.13, // 0.97, // 0.87, // 2.37 1 )->unfoldUsing( Html::a('Hello')->attr('class some-class', 'href http://example.com') diff --git a/tests/UIKit/CompoundTest.php b/tests/UIKit/CompoundTest.php index 5e63b97..6ce739e 100755 --- a/tests/UIKit/CompoundTest.php +++ b/tests/UIKit/CompoundTest.php @@ -63,7 +63,7 @@ public function web_head() AssertEquals::applyWith( '', "string", - 14.08, // 13.84, // 13.31, // 10.88, // 6.17, // 5.86, // 5.14, // 4.95, // 4.47, // 3.73, + 14.24, // 14.08, // 13.84, // 13.31, // 10.88, // 6.17, // 5.86, // 5.14, // 4.95, // 4.47, // 3.73, 4 // 3 )->unfoldUsing( UIKit::webHead() diff --git a/tests/UIKit/SimpleTest.php b/tests/UIKit/SimpleTest.php index b07110a..a5db54d 100755 --- a/tests/UIKit/SimpleTest.php +++ b/tests/UIKit/SimpleTest.php @@ -36,7 +36,7 @@ public function page_title() AssertEquals::applyWith( 'Hello, World!', "string", - 0.91, // 0.71, // 0.6, + 2.31, // 0.91, // 0.71, // 0.6, 4 )->unfoldUsing( UIKit::pageTitle(["Hello, World!"]) @@ -136,7 +136,7 @@ public function simple_lists() AssertEquals::applyWith( '
hello
good-bye
hello
good-bye
good-bye
', "string", - 12.37, // 12.16, // 11.53, // 10.71, // 5.25, // 4.59, // 4.49, + 12.48, // 12.37, // 12.16, // 11.53, // 10.71, // 5.25, // 4.59, // 4.49, 1 )->unfoldUsing( UIKit::listWith( From 5b6d1cea7da58ad038032ab6f63b1860de97815d Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Mon, 20 Sep 2021 18:53:02 -0500 Subject: [PATCH 03/10] tests --- tests/Html/HtmlElementTest.php | 2 +- tests/UIKit/CompoundTest.php | 2 +- tests/UIKit/PageTest.php | 2 +- tests/UIKit/SimpleTest.php | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Html/HtmlElementTest.php b/tests/Html/HtmlElementTest.php index 4cab1e7..bbcefe2 100644 --- a/tests/Html/HtmlElementTest.php +++ b/tests/Html/HtmlElementTest.php @@ -148,7 +148,7 @@ public function nested_elements_with_string() AssertEquals::applyWith( 'Hello', "string", - 4.5, // 4.04, // 3.99, // 3.93, // 3.9, // 3.75, // 3.32, // 1.76, // 1.6, // 1.56, // 1.21, // 1.13, // 0.97, // 0.87, // 2.37 + 4.87, // 4.5, // 4.04, // 3.99, // 3.93, // 3.9, // 3.75, // 3.32, // 1.76, // 1.6, // 1.56, // 1.21, // 1.13, // 0.97, // 0.87, // 2.37 1 )->unfoldUsing( Html::a('Hello')->attr('class some-class', 'href http://example.com') diff --git a/tests/UIKit/CompoundTest.php b/tests/UIKit/CompoundTest.php index 6ce739e..6eec9a1 100755 --- a/tests/UIKit/CompoundTest.php +++ b/tests/UIKit/CompoundTest.php @@ -63,7 +63,7 @@ public function web_head() AssertEquals::applyWith( '', "string", - 14.24, // 14.08, // 13.84, // 13.31, // 10.88, // 6.17, // 5.86, // 5.14, // 4.95, // 4.47, // 3.73, + 14.36, // 14.24, // 14.08, // 13.84, // 13.31, // 10.88, // 6.17, // 5.86, // 5.14, // 4.95, // 4.47, // 3.73, 4 // 3 )->unfoldUsing( UIKit::webHead() diff --git a/tests/UIKit/PageTest.php b/tests/UIKit/PageTest.php index 2540285..5af9945 100755 --- a/tests/UIKit/PageTest.php +++ b/tests/UIKit/PageTest.php @@ -21,7 +21,7 @@ public function web_view() AssertEquals::applyWith( 'UIKit

Hello, World!

', "string", - 18.66, // 17.82, // 17.28, // 13.74, // 10.21 // 9.69 // 9.46 + 26.99, // 18.66, // 17.82, // 17.28, // 13.74, // 10.21 // 9.69 // 9.46 596 )->unfoldUsing( UIKit::webView( diff --git a/tests/UIKit/SimpleTest.php b/tests/UIKit/SimpleTest.php index a5db54d..50143b1 100755 --- a/tests/UIKit/SimpleTest.php +++ b/tests/UIKit/SimpleTest.php @@ -36,7 +36,7 @@ public function page_title() AssertEquals::applyWith( 'Hello, World!', "string", - 2.31, // 0.91, // 0.71, // 0.6, + 3.31, // 2.31, // 0.91, // 0.71, // 0.6, 4 )->unfoldUsing( UIKit::pageTitle(["Hello, World!"]) @@ -124,7 +124,7 @@ public function simple_lists() AssertEquals::applyWith( '
hello
good-bye
', "string", - 6.44, // 3.52, // 3.2, + 8.69, // 6.44, // 3.52, // 3.2, 1 )->unfoldUsing( UIKit::listWith( @@ -157,7 +157,7 @@ public function images() AssertEquals::applyWith( 'Alt text', "string", - 4.4, // 3.94, // 3.31, // 2.37, // 2.3, // 2.03, + 5.2, // 4.4, // 3.94, // 3.31, // 2.37, // 2.3, // 2.03, 3 )->unfoldUsing( UIKit::image("Alt text", "https://path.to/image.jpg") From ea4794e843990bcd38d1fcfee51e9dce46dbb55f Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Mon, 20 Sep 2021 18:53:58 -0500 Subject: [PATCH 04/10] Update SimpleTest.php --- tests/UIKit/SimpleTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UIKit/SimpleTest.php b/tests/UIKit/SimpleTest.php index 50143b1..7f94532 100755 --- a/tests/UIKit/SimpleTest.php +++ b/tests/UIKit/SimpleTest.php @@ -37,7 +37,7 @@ public function page_title() 'Hello, World!', "string", 3.31, // 2.31, // 0.91, // 0.71, // 0.6, - 4 + 5 // 4 )->unfoldUsing( UIKit::pageTitle(["Hello, World!"]) ); From 8778e56718577cdaed8c9e14b1a0a22e55423440 Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Mon, 20 Sep 2021 18:57:40 -0500 Subject: [PATCH 05/10] Update SimpleTest.php --- tests/UIKit/SimpleTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UIKit/SimpleTest.php b/tests/UIKit/SimpleTest.php index 7f94532..d8bb143 100755 --- a/tests/UIKit/SimpleTest.php +++ b/tests/UIKit/SimpleTest.php @@ -45,7 +45,7 @@ public function page_title() AssertEquals::applyWith( 'How are you? | Hello, World!', "string", - 0.91, // 0.71, // 0.6, + 1.66, // 0.91, // 0.71, // 0.6, 3 )->unfoldUsing( UIKit::pageTitle(["How are you?", "Hello, World!"]) From 91e55fb42e53bfbc1c97ec4455f576f5bf172e07 Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Mon, 20 Sep 2021 18:58:34 -0500 Subject: [PATCH 06/10] Update SimpleTest.php --- tests/UIKit/SimpleTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UIKit/SimpleTest.php b/tests/UIKit/SimpleTest.php index d8bb143..9a4d16b 100755 --- a/tests/UIKit/SimpleTest.php +++ b/tests/UIKit/SimpleTest.php @@ -45,7 +45,7 @@ public function page_title() AssertEquals::applyWith( 'How are you? | Hello, World!', "string", - 1.66, // 0.91, // 0.71, // 0.6, + 1.94, // 1.66, // 0.91, // 0.71, // 0.6, 3 )->unfoldUsing( UIKit::pageTitle(["How are you?", "Hello, World!"]) From f83b9cbb8128b5424c989e6d97f8adcf95610be4 Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Mon, 20 Sep 2021 19:01:34 -0500 Subject: [PATCH 07/10] Update SimpleTest.php --- tests/UIKit/SimpleTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UIKit/SimpleTest.php b/tests/UIKit/SimpleTest.php index 9a4d16b..4765027 100755 --- a/tests/UIKit/SimpleTest.php +++ b/tests/UIKit/SimpleTest.php @@ -45,7 +45,7 @@ public function page_title() AssertEquals::applyWith( 'How are you? | Hello, World!', "string", - 1.94, // 1.66, // 0.91, // 0.71, // 0.6, + 2.13, // 1.94, // 1.66, // 0.91, // 0.71, // 0.6, 3 )->unfoldUsing( UIKit::pageTitle(["How are you?", "Hello, World!"]) From bf19f7449279e5115e88b5cba34940978a1de13a Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Mon, 20 Sep 2021 19:05:57 -0500 Subject: [PATCH 08/10] tests --- tests/Element/ElementTest.php | 2 +- tests/UIKit/SimpleTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Element/ElementTest.php b/tests/Element/ElementTest.php index 6c22690..2f315c7 100644 --- a/tests/Element/ElementTest.php +++ b/tests/Element/ElementTest.php @@ -88,7 +88,7 @@ public function self_contained_element() AssertEquals::applyWith( '', "string", - 1.33, // 1.25, // 1.23, // 1.21, // 1.03, // 0.32, // 0.3, // 0.27, // 0.21, // 0.2, + 1.38, // 1.33, // 1.25, // 1.23, // 1.21, // 1.03, // 0.32, // 0.3, // 0.27, // 0.21, // 0.2, 1 )->unfoldUsing( new Element("a", ["href /path"], false) diff --git a/tests/UIKit/SimpleTest.php b/tests/UIKit/SimpleTest.php index 4765027..5b6f65e 100755 --- a/tests/UIKit/SimpleTest.php +++ b/tests/UIKit/SimpleTest.php @@ -54,7 +54,7 @@ public function page_title() AssertEquals::applyWith( 'How are you? : Hello, World!', "string", - 0.91, // 0.71, // 0.6, + 1.82, // 0.91, // 0.71, // 0.6, 3 )->unfoldUsing( UIKit::pageTitle(["Hello, World!", "How are you?"], " : ")->reversed() From 5e500dc444cf5f49ebcbea2df236b3ba5b7af152 Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Mon, 20 Sep 2021 19:08:03 -0500 Subject: [PATCH 09/10] Update SimpleTest.php --- tests/UIKit/SimpleTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UIKit/SimpleTest.php b/tests/UIKit/SimpleTest.php index 5b6f65e..8636337 100755 --- a/tests/UIKit/SimpleTest.php +++ b/tests/UIKit/SimpleTest.php @@ -101,7 +101,7 @@ public function simple_lists() '
  • hello
  • good-bye
', "string", 11.32, // 6.34, // 4.93, // 4.69, // 3.8, - 72 // 8 + 73 // 72 // 8 )->unfoldUsing( UIKit::listWith( "hello", From 24c736e30e9dcc53bb16100ff29f0e929f5a29a9 Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Mon, 20 Sep 2021 19:09:40 -0500 Subject: [PATCH 10/10] Update SimpleTest.php --- tests/UIKit/SimpleTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UIKit/SimpleTest.php b/tests/UIKit/SimpleTest.php index 8636337..61ecae0 100755 --- a/tests/UIKit/SimpleTest.php +++ b/tests/UIKit/SimpleTest.php @@ -54,7 +54,7 @@ public function page_title() AssertEquals::applyWith( 'How are you? : Hello, World!', "string", - 1.82, // 0.91, // 0.71, // 0.6, + 1.95, // 1.82, // 0.91, // 0.71, // 0.6, 3 )->unfoldUsing( UIKit::pageTitle(["Hello, World!", "How are you?"], " : ")->reversed()