Class: Primer::Beta::Blankslate

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/beta/blankslate.rb

Overview

Use ‘Blankslate` when there is a lack of content within a page or section. Use as placeholder to tell users why something isn’t there.

Constant Summary collapse

VISUAL_OPTIONS =
%i[icon spinner image].freeze

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Constants included from AttributesHelper

AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Method Summary collapse

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Methods included from AttributesHelper

#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Constructor Details

#initialize(narrow: false, spacious: false, border: false, **system_arguments) ⇒ Blankslate

Returns a new instance of Blankslate.

Parameters:

  • narrow (Boolean) (defaults to: false)

    Adds a maximum width of ‘485px` to the Blankslate.

  • spacious (Boolean) (defaults to: false)

    Increases the padding from ‘32px` to `80px 40px`.

  • border (Boolean) (defaults to: false)

    Adds a border around the Blankslate.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



106
107
108
109
110
111
112
113
114
115
116
# File 'app/components/primer/beta/blankslate.rb', line 106

def initialize(narrow: false, spacious: false, border: false, **system_arguments)
  @border = border
  @system_arguments = deny_tag_argument(**system_arguments)
  @system_arguments[:tag] = :div
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "blankslate",
    "blankslate-narrow": narrow,
    "blankslate-spacious": spacious
  )
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'app/components/primer/beta/blankslate.rb', line 118

def render?
  heading.present?
end

#wrapperObject



122
123
124
125
126
127
128
129
130
131
# File 'app/components/primer/beta/blankslate.rb', line 122

def wrapper
  unless @border
    yield
    return # returning `yield` caused a double render
  end

  (:div, class: "Box") do
    yield if block_given?
  end
end