Skip to content
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

Added support for the glypicons in the widgets #31

Closed
wants to merge 4 commits into from

Conversation

klimov-paul
Copy link
Member

Fix for yiisoft/yii2#5207
Added support for the glypicons in the widgets

@klimov-paul
Copy link
Member Author

Added ability to specify icon as HTML.

@klimov-paul klimov-paul mentioned this pull request Apr 21, 2015
@klimov-paul
Copy link
Member Author

This one is more end-user friendly then #32, but affects widget internal label composition logic.

@samdark
Copy link
Member

samdark commented Apr 21, 2015

What if I want icons after labels?

@klimov-paul
Copy link
Member Author

Yes, this is one of the problems.
The best way whould be allowing to specify label as an array, which can contain 'icon', 'encode' and 'template' options. But this will be inconsistent with existing encodeLabel and encodeLabels properties.

@klimov-paul
Copy link
Member Author

For example:

echo Button::widget([
    'label' => ['ok-sign', 'Approve'],
]);
// or
echo Button::widget([
    'label' => [
        'icon' => 'ok-sign',
        'label' => '<b>Approve</b>',
        'encode' => false,
    ],
]);

@klimov-paul
Copy link
Member Author

It whould be nice to hear @crisu83 opinion on this matter.

@crisu83
Copy link

crisu83 commented Apr 21, 2015

Lately I've become more and more convinced that while this kind of logic is kind of nice to have, a more simple and better solution would be to have the user to add the icon in the label itself (through an icon helper of course). An example of this approach would be:

'label' => yii\bootstrap\Html::icon('ok-sign') . ' <b>Approve</b>',
'encode' => false,

@Borales
Copy link
Contributor

Borales commented Apr 21, 2015

@klimov-paul I'm on the side of @crisu83
Additionally to this, left position of the icon is hard-coded.
I think @crisu83's solution is more convenient

@klimov-paul
Copy link
Member Author

Then what about #32 ? Is that what you whant?

@Borales
Copy link
Contributor

Borales commented Apr 21, 2015

@klimov-paul #32 - what if I would like to use other set of icons (e.g. font-awesome or ionicons)? This way - I will be forced to extend the base Icon class and hard-code another css-class, right?
Maybe, we could "choose" between different sets with the second parameter?

Like

yii\bootstrap\Html::icon('ok-sign') // by default = glyphicon
yii\bootstrap\Html::icon('ok-sign', ['class' => 'fa fa-']) // for font-awesome
// or even just
yii\bootstrap\Html::icon('ok-sign', ['class' => 'fa']) // almost all icon sets work like "setname setname-"

This is just a suggestion.

@klimov-paul
Copy link
Member Author

You ARE able to do so. See the unit tests.

@Borales
Copy link
Contributor

Borales commented Apr 21, 2015

@klimov-paul sorry, didn't noticed that case.

@samdark
Copy link
Member

samdark commented Apr 21, 2015

I'm for #32.

@klimov-paul
Copy link
Member Author

Closed in favour #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants