Skip to content

Commit

Permalink
Merge pull request #1 from deanblackborough/jumbotron
Browse files Browse the repository at this point in the history
Jumbotron
  • Loading branch information
deanblackborough committed Nov 13, 2017
2 parents 1b127e5 + 3435736 commit 1cdad51
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 0 deletions.
File renamed without changes.
9 changes: 9 additions & 0 deletions examples/Jumbotron.php
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');
132 changes: 132 additions & 0 deletions src/Jumbotron.php
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();
}
}
26 changes: 26 additions & 0 deletions src/ViewHelper.php
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);
}
}

0 comments on commit 1cdad51

Please sign in to comment.