Skip to content

Commit

Permalink
Merge pull request #41 from w3l/dev
Browse files Browse the repository at this point in the history
:->
  • Loading branch information
w3l committed Feb 5, 2016
2 parents 057a6c6 + 1399830 commit 74479fe
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ php:
- hhvm
- nightly

script: phpunit Tests.php
script: phpunit Tests.php
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Generated API documentation is found [here](http://holt45.pw/docs)
* rainbowText()
* kbdSymbol()
* kbdShortcut()
* cssOneLineText()
* Math
* generatePaginationRange()
* Misc
Expand Down Expand Up @@ -146,6 +147,8 @@ echo holt45::kbdSymbol("enter"); // ⏎

echo holt45::kbdShortcut(array("Ctrl", "Alt", "Delete"), "auto"); // <kbd class="holt45-kbd"><span class="holt45-kbd__symbol">&#10034;</span>Ctrl</kbd> + <kbd class="holt45-kbd"><span class="holt45-kbd__symbol">&#9095;</span>Alt</kbd> + <kbd class="holt45-kbd"><span class="holt45-kbd__symbol">&#9003;</span>Delete</kbd>

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)

Expand Down
2 changes: 2 additions & 0 deletions Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public function allTests()

echo self::kbdShortcut(array("Ctrl", "Alt", "Delete"), "auto"); // <kbd class="holt45-kbd"><span class="holt45-kbd__symbol">&#10034;</span>Ctrl</kbd> + <kbd class="holt45-kbd"><span class="holt45-kbd__symbol">&#9095;</span>Alt</kbd> + <kbd class="holt45-kbd"><span class="holt45-kbd__symbol">&#9003;</span>Delete</kbd>

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];
Expand Down
2 changes: 1 addition & 1 deletion holt45.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
32 changes: 32 additions & 0 deletions holt45/Strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,36 @@ 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 '<style scoped>@media (max-width: '.$cssBreakpointPx.'px) { '.$cssSelector.' { font-size: '.$cssNewFontSizePx.'px; font-size: '.$cssNewFontSizeVw.'vw; } }</style>';
}
return null;
}
}

0 comments on commit 74479fe

Please sign in to comment.