Skip to content

Commit 240a8c8

Browse files
author
Marc TEYSSIER
authored
Merge pull request #10 from nguyenk/addColorShemes
Add Color schemes support
2 parents 8826e0a + eafcfd4 commit 240a8c8

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

src/Mouf/Html/Template/Menus/BootstrapNavBar.php

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,28 @@ class BootstrapNavBar implements HtmlElementInterface
4646
public $titleLink = "";
4747

4848
/**
49-
* If checked, the navbar will be rendered in dark shades instead of bright shades.
49+
* If checked, the navbar will be rendered in dark shades instead of bright shades. This is a shorthand for setting either :
50+
* - navbar-dark bg-dark (TRUE)
51+
* - navbar-light bg-light (FALSE)
5052
*
5153
* @var boolean
5254
*/
5355
public $inverted;
5456

57+
/**
58+
* The mode of the Nav Bar : can be one of 'dark' or 'light'. This mainly will apply nav-bar-$mode class for inner items color.
59+
* @Property
60+
* @var string
61+
*/
62+
private $mode;
63+
64+
/**
65+
* The background of the Nav Bar : can be one of 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark', 'white', 'transparent'.
66+
* @Property
67+
* @var string
68+
*/
69+
private $background;
70+
5571
/**
5672
* Display the menu with the maximum width<br />
5773
* If the parameter fixed is set, this is not used
@@ -80,4 +96,38 @@ public function __construct($children = array())
8096
{
8197
$this->children = $children;
8298
}
99+
100+
/**
101+
* @return string
102+
*/
103+
public function getMode(): string
104+
{
105+
return $this->mode ?? ($this->inverted ? 'dark' : 'light');
106+
}
107+
108+
/**
109+
* @param string $mode
110+
*/
111+
public function setMode(string $mode): void
112+
{
113+
$this->mode = $mode;
114+
}
115+
116+
/**
117+
* @return string
118+
*/
119+
public function getBackground(): string
120+
{
121+
return $this->background ?? ($this->inverted ? 'dark' : 'light');
122+
}
123+
124+
/**
125+
* @param string $background
126+
*/
127+
public function setBackground(string $background): void
128+
{
129+
$this->background = $background;
130+
}
131+
132+
83133
}

src/templates/Mouf/Html/Template/Menus/BootstrapNavBar.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% if not this.allWidth %}
22
<div class="container">
33
{% endif %}
4-
<nav class="navbar navbar-expand-lg {{ this.inverted?'navbar-dark bg-dark':'navbar-light bg-light' }} {% if this.allWidth %}navbar-static-top{% endif %} {{ this.fixed?('fixed-'~this.fixed):'' }}" role="navigation">
4+
<nav class="navbar navbar-expand-lg navbar-{{ this.mode }} bg-{{ this.background }}" {% if this.allWidth %}navbar-static-top{% endif %} {{ this.fixed?('fixed-'~this.fixed):'' }}" role="navigation">
55
{% if this.allWidth %}
66
<div class="container">
77
{% endif %}

0 commit comments

Comments
 (0)