Class: Polaris::PlaceholderComponent
- Defined in:
- app/components/polaris/placeholder_component.rb
Constant Summary
Constants included from ViewHelper
ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(height: "auto", width: "auto", label: nil, show_border: false) ⇒ PlaceholderComponent
constructor
A new instance of PlaceholderComponent.
Methods included from ViewHelper
#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source
Methods included from StylesListHelper
Methods included from OptionHelper
#append_option, #prepend_option
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #fetch_or_fallback_nested
Methods included from ClassNameHelper
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 |