Class: Polaris::PlaceholderComponent
- Inherits:
-
Component
- Object
- Component
- Polaris::PlaceholderComponent
- Defined in:
- app/components/polaris/placeholder_component.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(height: "auto", width: "auto", label: nil, show_border: false) ⇒ PlaceholderComponent
constructor
A new instance of PlaceholderComponent.
Constructor Details
#initialize(height: "auto", width: "auto", label: nil, show_border: false) ⇒ PlaceholderComponent
Returns a new instance of PlaceholderComponent.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/components/polaris/placeholder_component.rb', line 3 def initialize(height: "auto", width: "auto", label: nil, show_border: false) @label = label border = show_border ? "1px dashed var(--p-color-bg-success-subdued)" : "none" @system_arguments = { tag: :div, style: [ "background-color: var(--p-color-text-info)", "color: #fff", "width: #{width}", "height: #{height}", "display: flex", "align-items: center", "justify-content: center", "border-inline-start: #{border}" ].join(";") } end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/polaris/placeholder_component.rb', line 21 def call if @label.present? render(Polaris::BaseComponent.new(**@system_arguments)) do render(Polaris::InlineComponent.new(align: :center)) do tag.div(style: "color: #fff;") do render(Polaris::TextComponent.new(as: :h2, variant: :bodyMd)) do @label end end end end else render(Polaris::BaseComponent.new(**@system_arguments)) { content } end end |