From b22ec87b97f1312c6a1e91e465ef3063bc744f2f Mon Sep 17 00:00:00 2001 From: w3l Date: Mon, 1 Feb 2016 21:42:48 +0100 Subject: [PATCH 1/5] :-> --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index fae5370..f2c607b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,3 +8,8 @@ php: - nightly script: phpunit Tests.php + +before_install: + - pip install --user codecov +after_success: + - codecov \ No newline at end of file From 853dc26c8f7eab3e99bbf7a006d2d04106937d1d Mon Sep 17 00:00:00 2001 From: w3l Date: Tue, 2 Feb 2016 14:38:03 +0100 Subject: [PATCH 2/5] bash --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f2c607b..f49e1f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,5 @@ php: script: phpunit Tests.php -before_install: - - pip install --user codecov after_success: - - codecov \ No newline at end of file + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From 8a793cf7b9fe2e8e457a00ab5e7d8967c09c2834 Mon Sep 17 00:00:00 2001 From: w3l Date: Fri, 5 Feb 2016 02:57:55 +0100 Subject: [PATCH 3/5] cssOneLineText() --- .travis.yml | 5 +---- README.md | 3 +++ Tests.php | 2 ++ holt45.php | 2 +- holt45/Strings.php | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f49e1f7..91aecb6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,4 @@ php: - hhvm - nightly -script: phpunit Tests.php - -after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file +script: phpunit Tests.php \ No newline at end of file diff --git a/README.md b/README.md index 1b71030..eff2fa4 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ Generated API documentation is found [here](http://holt45.pw/docs) * rainbowText() * kbdSymbol() * kbdShortcut() + * cssOneLineText() * Math * generatePaginationRange() * Misc @@ -146,6 +147,8 @@ echo holt45::kbdSymbol("enter"); // ⏎ echo holt45::kbdShortcut(array("Ctrl", "Alt", "Delete"), "auto"); // Ctrl + Alt + Delete +echo holt45::cssOneLineText("hallo world!", "h1", 80, 320); + /* Math */ print_r(holt45::generatePaginationRange(106, 15, 7)); // Array([0] => 1, [1] => 13, [2] => 14, [3] => 15, [4] => 16, [5] => 17, [6] => 106) diff --git a/Tests.php b/Tests.php index fb7d481..558bb6f 100644 --- a/Tests.php +++ b/Tests.php @@ -86,6 +86,8 @@ public function allTests() echo self::kbdShortcut(array("Ctrl", "Alt", "Delete"), "auto"); // Ctrl + Alt + Delete + echo self::cssOneLineText("hallo world!", "h1", 80, 320); + /* Math */ $arr = self::generatePaginationRange(106, 15, 7); // Array([0] => 1, [1] => 13, [2] => 14, [3] => 15, [4] => 16, [5] => 17, [6] => 106) echo $arr[0]; diff --git a/holt45.php b/holt45.php index 322179a..7ece0ee 100644 --- a/holt45.php +++ b/holt45.php @@ -6,7 +6,7 @@ * @link http://holt45.pw/ Webpage * @link http://holt45.pw/docs/ Documentation of holt45 * @copyright Unlicense - * @version 0.4.6 + * @version 0.4.9 */ require_once dirname(__FILE__) . '/holt45/Get.php'; diff --git a/holt45/Strings.php b/holt45/Strings.php index 060684d..dc0aac9 100644 --- a/holt45/Strings.php +++ b/holt45/Strings.php @@ -249,4 +249,37 @@ public static function kbdShortcut( return implode($inputJoinGlue, $returnArray); } + + /** + * Attempting to keep CSS on one line with scoped style. + * + * NOTICE: This is a rough estimate, font type, design, etc affects the results. + * + * @param string $text + * @param string $cssSelector + * @param int $fontSizePx + * @param int $minPageWidthPx + * @return null|string Scoped style + */ + public static function cssOneLineText($text, $cssSelector = "h1", $fontSizePx = 36, $minPageWidthPx = 320) { + + $countText = strlen($text)+1; + + $fontWidth = ($fontSizePx / 2); + + if($minPageWidthPx < $countText) { + $minPageWidthPx = $countText; + } + if(($countText * $fontWidth) > $minPageWidthPx) { + + $cssNewFontSizePx = round(($minPageWidthPx / $countText) * 2, 2); + $cssNewFontSizeVw = round((100/$countText) * 2, 2); + + $cssBreakpointPx = round($countText * $fontWidth); + + return ''; + } + + return null; + } } From eeadf4a73952f9bed7bcb4302f63b3fec73945e7 Mon Sep 17 00:00:00 2001 From: w3l Date: Fri, 5 Feb 2016 03:05:17 +0100 Subject: [PATCH 4/5] cssOneLineText() code style --- holt45/Strings.php | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/holt45/Strings.php b/holt45/Strings.php index dc0aac9..e8d67fb 100644 --- a/holt45/Strings.php +++ b/holt45/Strings.php @@ -261,25 +261,24 @@ public static function kbdShortcut( * @param int $minPageWidthPx * @return null|string Scoped style */ - public static function cssOneLineText($text, $cssSelector = "h1", $fontSizePx = 36, $minPageWidthPx = 320) { - - $countText = strlen($text)+1; - - $fontWidth = ($fontSizePx / 2); - - if($minPageWidthPx < $countText) { - $minPageWidthPx = $countText; - } - if(($countText * $fontWidth) > $minPageWidthPx) { - - $cssNewFontSizePx = round(($minPageWidthPx / $countText) * 2, 2); - $cssNewFontSizeVw = round((100/$countText) * 2, 2); - - $cssBreakpointPx = round($countText * $fontWidth); - - return ''; - } - - return null; - } + public static function cssOneLineText($text, $cssSelector = "h1", $fontSizePx = 36, $minPageWidthPx = 320) + { + $countText = strlen($text)+1; + + $fontWidth = ($fontSizePx / 2); + + if ($minPageWidthPx < $countText) { + $minPageWidthPx = $countText; + } + if (($countText * $fontWidth) > $minPageWidthPx) { + + $cssNewFontSizePx = round(($minPageWidthPx / $countText) * 2, 2); + $cssNewFontSizeVw = round((100/$countText) * 2, 2); + + $cssBreakpointPx = round($countText * $fontWidth); + + return ''; + } + return null; + } } From 1399830de275b0b2c9aee8eba1773719dfcda58d Mon Sep 17 00:00:00 2001 From: w3l Date: Fri, 5 Feb 2016 03:07:13 +0100 Subject: [PATCH 5/5] cssOneLineText() code style minor --- Tests.php | 4 ++-- holt45/Strings.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests.php b/Tests.php index 558bb6f..1f245ce 100644 --- a/Tests.php +++ b/Tests.php @@ -86,8 +86,8 @@ public function allTests() echo self::kbdShortcut(array("Ctrl", "Alt", "Delete"), "auto"); // Ctrl + Alt + Delete - echo self::cssOneLineText("hallo world!", "h1", 80, 320); - + echo self::cssOneLineText("hallo world!", "h1", 80, 320); + /* Math */ $arr = self::generatePaginationRange(106, 15, 7); // Array([0] => 1, [1] => 13, [2] => 14, [3] => 15, [4] => 16, [5] => 17, [6] => 106) echo $arr[0]; diff --git a/holt45/Strings.php b/holt45/Strings.php index e8d67fb..9cb4ca6 100644 --- a/holt45/Strings.php +++ b/holt45/Strings.php @@ -249,7 +249,7 @@ public static function kbdShortcut( return implode($inputJoinGlue, $returnArray); } - + /** * Attempting to keep CSS on one line with scoped style. *