-
Notifications
You must be signed in to change notification settings - Fork 2
f7_bar_link
This renders an individual link component of a navbar/toolbar.
f7_bar_link title, options, &block
f7_bar_link options, &block
As well as all the usual HTML options, you have these extra, helper specific options:
-
:title- Optional, used if the options are the first parameter. -
:href- Optional, if omitted, a#is assumed (i.e. for javascript events). -
:icon- Optional, the class of the icon. -
:badge- Optional, text/hash for a badge. Hash values:-
:text- Value to display in the badge. -
:class- Optional, additional class for badge styling.
-
:title is only rendered in a toolbar or tabbar with labels.
If f7_bar_link is rendered inside a navbar/toolbar, it is decorated with the link class. If inside a tabbar, then it is decorated with a tab-link class.
The quickest way to output a text link is to specify it's url on the bar item, and it's done.
<%= f7_bar_link 'Profile', :href => '/profile' %><a href="/profile" class="link">Profile</a>Assuming the link is in a 'tab bar with labels'
<%= f7_bar_link 'Me', :href => '/profile', :icon => :profile %><a href="/profile" class="link">
<i class="icon profile"></i>
<span>Me</span>
</a>If you don't want any text, just leave out the title altogether, or set it to an empty string or nil. It will look a bit weird if inside a tab bar with labels'.
<%= f7_bar_link :href => '/menu', :icon => :bars %><a href="/menu" class="link icon-only">
<i class="icon icon-bars"></i>
</a>If you specify a non-hash value, it renders the value in a red badge.
<%= f7_bar_link 'Mail', ':href => '/messages', :icon => :mail, :badge => 5 %> <a href="/messages" class="link">
<i class="icon mail">
<span class="badge badge-red">5</span>
</i>
<span class="tabbar-label">Mail</span>
</a> If you need a bit more control, you can specify the badge as a hash.
<%= f7_bar_link 'Mail', ':href => '/messages', :icon => :mail, :badge => { :text => 5, :class => red } %> <a href="/messages" class="link">
<i class="icon mail">
<span class="badge red">5</span>
</i>
<span class="tabbar-label">Mail</span>
</a>