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

ElggMenuItem should support icon option (Trac #3547) #3547

Closed
elgg-gitbot opened this issue Feb 16, 2013 · 12 comments
Closed

ElggMenuItem should support icon option (Trac #3547) #3547

elgg-gitbot opened this issue Feb 16, 2013 · 12 comments

Comments

@elgg-gitbot
Copy link

Original ticket http://trac.elgg.org/ticket/3547 on 41439598-10-31 by ewinslow, assigned to unknown.

Elgg version: 1.8 Beta

elgg_view('output/url', array(
    'icon' => 'push-pin',
    'text' => 'blah...',
    'href' => '/some/where',
));

produces something like:

<a href="mysite.com/some/where">
    <span class="elgg-icon elgg-icon-push-pin"></span>
    <span class="elgg-text">blah...</span>
</a>

Main motivation is more power when theming. E.g. could be helpful for menus if you just want to add/remove/modify the icon, not necessarily the whole text. Also allows more control over vertical-align issues when the text of the url as wrapped in a separate span, as opposed to <span class="elgg-icon ..."></span>blah...

Not totally sure whether we should make 'icon' "magically" recognize the icon names, or whether we should just expect arbitrary html. I lean towards recognizing icon names.

@elgg-gitbot
Copy link
Author

cash wrote on 41447769-01-27

Just for everyone's reference, current solution is to pass all the icon/text as the text parameter. This ticket is mostly about encouraging a particular mark-up. This feels extremely low on the priority list or maybe I'm just not seeing the advantages to it.

@elgg-gitbot
Copy link
Author

ewinslow wrote on 41449768-03-10

I have run into minor theming issues without that extra span (there's a reason jquery-ui does it this way, too).

Another application that I have run into is customizing the icons of menu items. Would be nice to just do $item->setIcon('speech-bubble'), or to remove all icons you could do $item->setIcon(FALSE);. That way I don't even have to look up what language string is being used.

@elgg-gitbot
Copy link
Author

cash wrote on 41489621-05-16

Note to self: any solution would need to support RTL languages where the icon would appear to the right of the text.

@elgg-gitbot
Copy link
Author

ewinslow wrote on 41500501-01-25

This does not need to go into 1.8, but it seems like we will want it at some point?

BTW, this could also be useful for input buttons. I've seen something like the following markup, for example:

<label class="elgg-button">
    <span class="elgg-icon elgg-icon-lock"></span>
    <input type="button" class="elgg-text" />
</label>

That allows you to stick icons "in" input buttons even though the value attribute can't accept html.

@elgg-gitbot
Copy link
Author

ewinslow wrote on 42365365-02-08

Menu items are the main place this issue comes up. Maybe we should just add this to the ElggMenuItem class?

@elgg-gitbot
Copy link
Author

Milestone changed to Elgg 1.9.0 by ewinslow on 42365365-02-08

@elgg-gitbot
Copy link
Author

Title changed from output/url should support icon option to ElggMenuItem should support icon option by ewinslow on 42365365-02-08

@elgg-gitbot
Copy link
Author

ewinslow wrote on 42555253-11-30

Another approach:

<a href="..." data-icon="push-pin">Text</a>

CSS is then used to style anything with data-icon using the :before pseudo selector. I'm partial to this one because it's a lot cleaner in the API:

elgg_view('output/url', array(
  'text' => 'Text',
  'encode_text' => true,
  'data-icon' => 'push-pin',
));

// vs.

elgg_view('output/url', array(
  'text' => elgg_view_icon('push-pin') . htmlspecialchars('Text')
));

It also means we don't have to explicitly add more logic to our views, since it's all taken care of by css.

@elgg-gitbot
Copy link
Author

ewinslow wrote on 42555355-02-05

As a bonus, the attribute-selector method works on all browsers all the way down to ie7!

http://css-tricks.com/attribute-selectors/

@elgg-gitbot
Copy link
Author

Milestone changed to Elgg 1.10.0 by cash on 43101260-12-21

@ewinslow ewinslow removed this from the Elgg 1.10.0 milestone Jun 13, 2014
@jdalsem jdalsem modified the milestone: Revamp Menus Dec 5, 2014
@ewinslow
Copy link
Contributor

ewinslow commented Feb 9, 2015

We definitely don't care about ie7 anymore, but this still seems like it would be a sensible improvement.

@jdalsem
Copy link
Member

jdalsem commented Oct 17, 2016

Fixed by #10451

@jdalsem jdalsem closed this as completed Oct 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants