-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from deanblackborough/jumbotron
Jumbotron
- Loading branch information
Showing
4 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
require __DIR__ . '/../src/ViewHelper.php'; | ||
require __DIR__ . '/../src/Jumbotron.php'; | ||
|
||
# Plan | ||
$jumbotron = ViewHelper::jumbotron('Heading', '<p>Content</p>'); | ||
echo $jumbotron->fluid()->setBgStyle('primary'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
|
||
use DBlackborough\Zf3ViewHelpers\Bootstrap4Jumbotron; | ||
|
||
/** | ||
* Generate a Bootstrap 4 Jumbotron component | ||
* | ||
* @package DBlackborough\Bootstrap4Helpers | ||
* @author Dean Blackborough <dean@g3d-development.com> | ||
* @copyright Dean Blackborough | ||
* @license https://github.com/deanblackborough/bootstrap-4-helpers/blob/master/LICENSE | ||
*/ | ||
class Jumbotron | ||
{ | ||
/** | ||
* @var Bootstrap4Jumbotron | ||
*/ | ||
private $helper; | ||
|
||
public function __construct() | ||
{ | ||
$this->helper = new Bootstrap4Jumbotron(); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Opening call for view helper, the minimum parameters required to create component | ||
* | ||
* @param string $heading | ||
* @param string $content | ||
* | ||
* @return Jumbotron | ||
*/ | ||
public function helper(string $heading, string $content) : Jumbotron | ||
{ | ||
$this->helper->__invoke($heading, $content); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Add the fluid class to make Jumbotron full width and without rounded corners | ||
* | ||
* @return Jumbotron | ||
*/ | ||
public function fluid() : Jumbotron | ||
{ | ||
$this->helper->fluid(); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set the background colour for the component, needs to be one of the following, primary, secondary, success, | ||
* danger, warning, info, light, dark or white, if an incorrect style is passed in we don't apply the class. | ||
* | ||
* @param string $color | ||
* | ||
* @return Jumbotron | ||
*/ | ||
public function setBgStyle($color) : Jumbotron | ||
{ | ||
$this->helper->setBgStyle($color); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set the display level class for a heading title, display-[1-4] | ||
* | ||
* @param integer $level [1-4] | ||
* | ||
* @return Jumbotron | ||
*/ | ||
public function setHeadingDisplayLevel(int $level) : Jumbotron | ||
{ | ||
$this->helper->setHeadingDisplayLevel($level); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set an optional sub heading, added to the end of the heading inside small tags | ||
* | ||
* @param string $sub_heading | ||
* | ||
* @return Jumbotron | ||
*/ | ||
public function setSubHeading(string $sub_heading) : Jumbotron | ||
{ | ||
$this->helper->setSubHeading($sub_heading); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set the text color for the component, need to be one of the following, primary, secondary, success, danger, | ||
* warning, info, light or dark, if an incorrect style is passed in we don't apply the class. | ||
* | ||
* @param string $color | ||
* | ||
* @return Jumbotron | ||
*/ | ||
public function setTextStyle($color) : Jumbotron | ||
{ | ||
$this->helper->setTextStyle($color); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Return the generated HTML | ||
* | ||
* @return string | ||
*/ | ||
protected function render() : string | ||
{ | ||
return $this->helper; | ||
} | ||
|
||
|
||
/** | ||
* Override __toString() so we can echo the view object directly | ||
* | ||
* @return string | ||
*/ | ||
public function __toString() : string | ||
{ | ||
return $this->render(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
/** | ||
* Factory for the Bootstrap 4 view helpers | ||
* | ||
* @package DBlackborough\Bootstrap4Helpers | ||
* @author Dean Blackborough <dean@g3d-development.com> | ||
* @copyright Dean Blackborough | ||
* @license https://github.com/deanblackborough/bootstrap-4-helpers/blob/master/LICENSE | ||
*/ | ||
class ViewHelper | ||
{ | ||
/** | ||
* Instantiate and return the Bootstrap 4 Jumbotron view helper | ||
* | ||
* @param string $heading | ||
* @param string $content | ||
* | ||
* @return Jumbotron | ||
*/ | ||
public static function jumbotron(string $heading, string $content) : Jumbotron | ||
{ | ||
$helper = new Jumbotron(); | ||
return $helper->helper($heading, $content); | ||
} | ||
} |