Class: Polaris::ModalComponent
- Inherits:
-
Component
- Object
- Component
- Polaris::ModalComponent
- Defined in:
- app/components/polaris/modal_component.rb
Instance Method Summary collapse
- #close_button_arguments ⇒ Object
- #dialog_arguments ⇒ Object
-
#initialize(title:, open: false, sectioned: true, scrollable: true, large: false, small: false, limit_height: false, dialog_arguments: {}, **system_arguments) ⇒ ModalComponent
constructor
A new instance of ModalComponent.
- #modal_classes ⇒ Object
- #render_footer? ⇒ Boolean
- #system_arguments ⇒ Object
Constructor Details
#initialize(title:, open: false, sectioned: true, scrollable: true, large: false, small: false, limit_height: false, dialog_arguments: {}, **system_arguments) ⇒ ModalComponent
Returns a new instance of ModalComponent.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/components/polaris/modal_component.rb', line 17 def initialize( title:, open: false, sectioned: true, scrollable: true, large: false, small: false, limit_height: false, dialog_arguments: {}, **system_arguments ) @title = title @open = open @sectioned = sectioned @scrollable = scrollable @large = large @small = small @limit_height = limit_height @dialog_arguments = dialog_arguments @system_arguments = system_arguments @close_button_arguments = { tag: "button", type: "button", classes: "Polaris-Modal-CloseButton", aria: {label: "Close"} } end |
Instance Method Details
#close_button_arguments ⇒ Object
75 76 77 78 79 |
# File 'app/components/polaris/modal_component.rb', line 75 def @close_button_arguments.deep_merge({ data: {action: "polaris-modal#close"} }) end |
#dialog_arguments ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/components/polaris/modal_component.rb', line 61 def dialog_arguments @dialog_arguments.tap do |opts| opts[:tag] = "div" opts[:role] = "dialog" opts[:aria] ||= {} opts[:aria][:modal] = "true" opts[:tabindex] = "-1" opts[:classes] = class_names( @dialog_arguments[:classes], "Polaris-Modal-Dialog" ) end end |
#modal_classes ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'app/components/polaris/modal_component.rb', line 81 def modal_classes class_names( "Polaris-Modal-Dialog__Modal", "Polaris-Modal-Dialog--sizeLarge": @large, "Polaris-Modal-Dialog--sizeSmall": @small, "Polaris-Modal-Dialog--limitHeight": @limit_height ) end |
#render_footer? ⇒ Boolean
90 91 92 |
# File 'app/components/polaris/modal_component.rb', line 90 def primary_action.present? || secondary_actions.any? end |
#system_arguments ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/components/polaris/modal_component.rb', line 45 def system_arguments @system_arguments.tap do |opts| opts[:tag] = "div" opts[:data] ||= {} prepend_option(opts[:data], :controller, "polaris-modal") opts[:data][:polaris_modal_open_value] = @open opts[:data][:polaris_modal_hidden_class] = "Polaris--hidden" opts[:data][:polaris_modal_backdrop_class] = "Polaris-Backdrop" opts[:classes] = class_names( @system_arguments[:classes], "Polaris-Modal-Dialog__Container", "Polaris--hidden" ) end end |