class UiBibz::Ui::Core::Windows::Modal
Create an modal
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:
-
size
(:xl:,
:lg+,:md
,:sm
) -
fullscreen
- Boolean -
backdrop
- Symbol (:static
) -
scrollable
- Boolean -
position
- Symbol (:centered
)
Signatures¶ ↑
UiBibz::Ui::Core::Modal.new(options = nil, html_options = nil) do |m| m.header content, options, html_options, &block m.body content, options, html_options, &block m.footer content, options, html_options, &block end
Examples¶ ↑
UiBibz::Ui::Core::Modal.new({glyph: { name: 'eye', size: 3}, { class: 'test' }) do |m| m.header 'Title' m.body 'Content' m.footer do button_link 'Ok', '#', class: :success end end.render
Helper¶ ↑
modal(options = {}, html_options = {}) do |m| m.header do 'Title' end m.body do 'Content' end m.footer do 'Footer' end end
Public Instance Methods
body(content = nil, options = nil, html_options = nil, &block)
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 84 def body(content = nil, options = nil, html_options = nil, &block) @body = UiBibz::Ui::Core::Windows::Components::ModalBody.new(content, options, html_options, &block) end
header(content = nil, options = nil, html_options = nil, &block)
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 76 def header(content = nil, options = nil, html_options = nil, &block) @header = UiBibz::Ui::Core::Windows::Components::ModalHeader.new(content, options, html_options, &block) end
pre_render()
click to toggle source
Render html tag
# File lib/ui_bibz/ui/core/windows/modal.rb, line 64 def pre_render content_tag :div, modal_html_options do content_tag :div, class: modal_dialog_classes do content_tag :div, class: 'modal-content' do concat @header&.render concat @body&.render concat @footer&.render end end end end
Private Instance Methods
backdrop()
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 146 def backdrop return unless @options[:backdrop] add_html_data 'bs-backdrop', value: @options[:backdrop] add_html_data 'bs-keyboard', value: 'false' end
component_html_classes()
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 94 def component_html_classes 'modal' end
component_html_data()
click to toggle source
Calls superclass method
UiBibz::Ui::Core::Component#component_html_data
# File lib/ui_bibz/ui/core/windows/modal.rb, line 137 def component_html_data super backdrop end
down()
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 124 def down 'down' if @options[:size] && @options[:fullscreen] end
effect()
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 120 def effect @options[:effect] unless @options[:effect].nil? end
fullscreen()
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 116 def fullscreen 'fullscreen' if @options[:fullscreen] end
fullscreen_size()
click to toggle source
:xl, :lg, :sm or :xs
# File lib/ui_bibz/ui/core/windows/modal.rb, line 108 def fullscreen_size [modal, fullscreen, @options[:size], down].compact.join('-') end
labelled_by()
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 142 def labelled_by sanitize_text(@header&.content || 'Modal') end
modal()
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 128 def modal 'modal' if @options[:size] || @options[:fullscreen] end
modal_dialog_classes()
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 90 def modal_dialog_classes UiBibz::Utils::Screwdriver.join_classes('modal-dialog', fullscreen_size, size, position, scrollable) end
modal_html_options()
click to toggle source
Update html_options only during pre-render
# File lib/ui_bibz/ui/core/windows/modal.rb, line 133 def modal_html_options html_options.merge({ tabindex: '-1', aria: { labelledby: labelled_by, hidden: 'true' } }) end
position()
click to toggle source
centered
# File lib/ui_bibz/ui/core/windows/modal.rb, line 103 def position "modal-dialog-#{@options[:position]}" if @options[:position] end
scrollable()
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 98 def scrollable 'modal-dialog-scrollable' if @options[:scrollable] end
size()
click to toggle source
# File lib/ui_bibz/ui/core/windows/modal.rb, line 112 def size [modal, @options[:size]].compact.join('-') if @options[:size] end