class UiBibz::Ui::Core::Notifications::Badge
Create a badge
This element is an extend of UiBibz::Ui::Core::Component
.
Attributes¶ ↑
-
content
- Content of element -
options
- Options of element -
html_options
- Html Options of element
Options¶ ↑
You can add HTML attributes using the html_options
. You can pass arguments in options attribute:
-
status
- status of element with symbol value: (:primary
,:secondary
,:success
,:danger
,:warning
,:info
,:light
,:dark
) -
glyph
- [String | Hash] Add glyph with name or hash options-
name
- [String] -
url
- [String] Transform span to link
-
-
type
- [Symbol] (:pill
,:square
)
Signatures¶ ↑
UiBibz::Ui::Core::Notifications::Badge.new(content, options = nil, html_options = nil) UiBibz::Ui::Core::Notifications::Badge.new(options = nil, html_options = nil) do content end
Examples¶ ↑
UiBibz::Ui::Core::Notifications::Badge.new(content, status: :success, type: :pill).render UiBibz::Ui::Core::Notifications::Badge.new() do #content end.render
Helper¶ ↑
ui_badge(content, options = {}, html_options = {}) ui_badge(options = {}, html_options = {}) do content end
Public Instance Methods
pre_render()
click to toggle source
Render html tag
# File lib/ui_bibz/ui/core/notifications/badge.rb, line 54 def pre_render content_tag options[:url].nil? ? :span : :a, glyph_and_content_html, html_options end
Private Instance Methods
component_html_classes()
click to toggle source
# File lib/ui_bibz/ui/core/notifications/badge.rb, line 64 def component_html_classes ['badge', type] end
component_html_options()
click to toggle source
Calls superclass method
UiBibz::Ui::Core::Component#component_html_options
# File lib/ui_bibz/ui/core/notifications/badge.rb, line 60 def component_html_options super.merge(options[:url].nil? ? {} : { href: options[:url] }) end
status()
click to toggle source
# File lib/ui_bibz/ui/core/notifications/badge.rb, line 68 def status "bg-#{@options[:status] || :default}" end
type()
click to toggle source
# File lib/ui_bibz/ui/core/notifications/badge.rb, line 72 def type 'rounded-pill' if @options[:type] == :pill end