Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ class Nav extends Widget
* Defaults to `null` which means `<b class="caret"></b>` will be used. To disable the caret, set this property to be an empty string.
*/
public $dropDownCaret;
/**
* @var string the CSS class that will be assigned to the menu element.
* Defaults to 'nav'.
*/
public $menuCssClass = 'nav';
/**
* @var string the CSS class that will be assigned to each item element.
* Defaults to null, meaning no CSS class will be assigned.
*/
public $itemCssClass = null;


/**
Expand All @@ -116,7 +126,7 @@ public function init()
if ($this->dropDownCaret === null) {
$this->dropDownCaret = Html::tag('b', '', ['class' => 'caret']);
}
Html::addCssClass($this->options, 'nav');
Html::addCssClass($this->options, $this->menuCssClass);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such construction does not seem right: we have a $options, which allows specification of the 'class' and $menuCssClass for the specification of the class.
It seems either Html::addCssClass() usage should be abandonded or menuCssClass not introduced.

}

/**
Expand Down Expand Up @@ -189,6 +199,10 @@ public function renderItem($item)
if ($this->activateItems && $active) {
Html::addCssClass($options, 'active');
}

if ($this->itemCssClass !== null) {
Html::addCssClass($options, $this->itemCssClass);
}

return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options);
}
Expand Down