Skip to content

Commit

Permalink
Merge pull request #17 from deanblackborough/v0.64
Browse files Browse the repository at this point in the history
V0.64
  • Loading branch information
deanblackborough authored Oct 10, 2017
2 parents 30f80d1 + bd0546f commit bab8d24
Show file tree
Hide file tree
Showing 6 changed files with 726 additions and 26 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

Full changelog for Zend Framework 3 view helpers library.

## v0.64.0 - Tests and Jumbotron - 2017-10-11

* Added tests for Bootstrap 4 Jumbotron view helper.
* Added setBGStyle() and setTextStyle() to Jumbotron view helper.
* Jumbotron headings default to heading-1 for the H1.
* Added tests for Bootstrap 4 Progress bar view helper.
* Bootstrap 4 progress bar view helper now supports all the bg-* utility classes.

## v0.63.0 - Tests - 2017-10-08

* Removing call to default escape plugins, assumption now is developer will escape their own data.
* Added tests for Bootstrap 4 Badge view helper
* Added tests for Bootstrap 4 Button view helper
* Added tests for Bootstrap 4 Badge view helper.
* Added tests for Bootstrap 4 Button view helper.

## v0.62.1 - Beta 4.0.0 updates/fixes

Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ A collection of Zend Framework 3 view helpers, primarily focused on Bootstrap 3

### Bootstrap 4

* Bootstrap 4 Badge component - [12 Tests]
* Bootstrap 4 Button component - [31 Tests]
* Bootstrap 4 Badge component - [12 tests]
* Bootstrap 4 Button component - [31 tests]
* Bootstrap 4 Card component
* Bootstrap 4 Jumbotron component
* Bootstrap 4 Jumbotron component - [26 tests]
* Bootstrap 4 Navbar component (lite)
* Bootstrap 4 Progress bar component
* Bootstrap 4 Progress bar component - [17 tests]
* Bootstrap 4 Multiple progress bar component

### Bootstrap 3
Expand Down Expand Up @@ -279,3 +279,10 @@ to use in your project.
]
]
```

## Future plans

* Develop view helpers for each of the Bootstrap 4 components.
* Develop view helpers for each of the Bootstrap 3 components.
* Update view helpers to provide more control over assigned content.
* Additional view helpers.
80 changes: 73 additions & 7 deletions src/Bootstrap4Jumbotron.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Bootstrap4Jumbotron extends AbstractHelper
/**
* @var array Supported display levels for heading
*/
private $supported_display_levels = [ 1, 2, 3, 4];
private $supported_display_levels = [ 1, 2, 3, 4 ];

/**
* @var integer|null Set display level
Expand All @@ -45,6 +45,31 @@ class Bootstrap4Jumbotron extends AbstractHelper
*/
private $content;

/**
* @var array Bootstrap styles
*/
private $supported_styles = [
'primary',
'secondary',
'success',
'danger',
'warning',
'info',
'light',
'dark',
'white'
];

/**
* @var string Background style
*/
private $bg_style;

/**
* @var string Text style
*/
private $text_style;

/**
* Entry point for the view helper
*
Expand Down Expand Up @@ -78,7 +103,7 @@ private function reset() : void
}

/**
* Set the display level class for a heading title, display-1-4
* Set the display level class for a heading title, display-[1-4]
*
* @param integer $level [1-4]
*
Expand Down Expand Up @@ -119,6 +144,46 @@ public function subHeading(string $sub_heading) : Bootstrap4Jumbotron
return $this;
}

/**
* Set the background style for the jumbotron, one of the following, primary, secondary, success,
* info, warning, danger, light, dark or white. If an incorrect style is passed in we set the style to
* primary
*
* @param string $style
*
* @return Bootstrap4Jumbotron
*/
public function setBgStyle($style)
{
if (in_array($style, $this->supported_styles) === true) {
$this->bg_style = $style;
} else {
$this->bg_style = 'primary';
}

return $this;
}

/**
* Set the text style for the jumbotron, one of the following, primary, secondary, success,
* info, warning, danger, light, dark. If an incorrect style is passed in we set the style to
* dark
*
* @param string $style
*
* @return Bootstrap4Jumbotron
*/
public function setTextStyle($style)
{
if (in_array($style, $this->supported_styles) === true && $style !== 'white') {
$this->text_style = $style;
} else {
$this->text_style = 'dark';
}

return $this;
}

/**
* Worker method for the view helper, generates the HTML, the method is private so that we
* can echo/print the view helper directly
Expand All @@ -129,13 +194,14 @@ private function render() : string
{
$html = '<div class="jumbotron' .
(($this->fluid === true) ? ' jumbotron-fluid' : null) .
(($this->bg_style !== null) ? ' bg-' . $this->bg_style : null) .
(($this->text_style !== null) ? ' text-' . $this->text_style : null) .
'">' .
(($this->fluid === true) ? '<div class="container">' : null) .
'<h1' .
(($this->display_level !== null) ? ' class="display-' . $this->display_level . '"' : null) .
'>' . $this->view->escapeHtml($this->heading) .
(($this->sub_heading !== null) ? '<small>' .
$this->view->escapeHtml($this->sub_heading) . '</small>' : null) .
'<h1 class="display-' . (($this->display_level !== null) ? $this->display_level : '1') .
'">' . $this->heading .
(($this->sub_heading !== null) ? ' <small>' .
$this->sub_heading . '</small>' : null) .
'</h1>' . $this->content .
(($this->fluid === true) ? '</div>' : null) .
'</div>';
Expand Down
29 changes: 16 additions & 13 deletions src/Bootstrap4ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ class Bootstrap4ProgressBar extends AbstractHelper
* @var array Bootstrap styles
*/
private $supported_styles = [
'primary',
'secondary',
'success',
'info',
'warning',
'danger',
'warning',
'info',
'light',
'dark',
'white'
];

/**
Expand All @@ -72,14 +77,14 @@ public function __invoke(int $value): Bootstrap4ProgressBar
}

/**
* Set the background color for the progress bar, one of the following, success, info,
* warning or danger. If an incorrect style is passed in we don't apply the class.
* Set the background color for the progress bar, 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 Bootstrap4ProgressBar
*/
public function color(string $color): Bootstrap4ProgressBar
public function setBgStyle(string $color): Bootstrap4ProgressBar
{
if (in_array($color, $this->supported_styles) === true) {
$this->color = $color;
Expand Down Expand Up @@ -196,7 +201,7 @@ private function classes() : string
$classes .= ' progress-bar-animated';
}

return $this->view->escapeHtmlAttr($classes);
return $classes;
}

/**
Expand All @@ -209,15 +214,13 @@ private function render() : string
{
$styles = $this->styles();
if (strlen($styles) > 0) {
$styles = 'style="' . $this->view->escapeHtmlAttr(trim($styles)) . '"';
$styles = 'style="' . trim($styles) . '"';
}

return '
<div class="progress">
<div class="progress-bar' . $this->classes() . '" role="progressbar" ' . $styles .
' aria-valuenow="' . $this->value . '" aria-valuemin="0" aria-valuemax="100">' .
(($this->label !== null) ? $this->view->escapeHtml($this->label) : null) . '</div>
</div>';
return '<div class="progress"><div class="progress-bar' . $this->classes() .
'" role="progressbar" ' . $styles . ' aria-valuenow="' . $this->value .
'" aria-valuemin="0" aria-valuemax="100">' .
(($this->label !== null) ? $this->label : null) . '</div></div>';
}

/**
Expand Down
Loading

0 comments on commit bab8d24

Please sign in to comment.