-
-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for setting the CSS class for the menu and its items #15
Conversation
There is a |
I already did and it kind of does, with the exception that you cannot configure the menu item CSS class. Instead you need to manually set it for each item which is undesirable (IMHO). I'm not sure I understand why the I think this same functionality should be available in the |
Yeah, I asked the same question myself too. I think this should be refactored in 2.1 |
Agreed, I think that's the best solution. However, I still think we should support setting the menu and item class classes as I proposed in this PR. |
sure, set for milestone 2.0.4 |
Also as the author of the Yii-Bootstrap and Yiistrap extensions I've also spend quite a lot time thinking about whether we should support setting CSS classes through variables or if it's overkill for a framework to provide that support. While it might seem convenient it makes the code a bit more complex and adds some potentially unnecessary logic to the widgets. I guess you just need to decide whether you want it or not. |
You should also fix the build, it seems that it runs |
@crisu83, cna you please get pull from upstream and add a changelog line? |
@@ -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); |
There was a problem hiding this comment.
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.
Resolved by #52 |
Currently it isn't possible to configure the menu CSS class nor the item CSS class, which mean that this widget cannot be used for creating other menus, such as list groups, which is a shame.
I added two new properties to the widget;
menuCssClass
anditemCssClass
, which allows us to use this widget for other bootstrap menus than those containing thenav
CSS class.I would also suggest considering to rename the
Nav
class toMenu
in the future.