Class: Primer::BlankslateComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/blankslate_component.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

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(title: "", title_tag: :h3, icon: "", icon_size: :medium, image_src: "", image_alt: " ", description: "", button_text: "", button_url: "", button_classes: "btn-primary my-3", link_text: "", link_url: "", narrow: false, large: false, spacious: false, **system_arguments) ⇒ BlankslateComponent

Returns a new instance of BlankslateComponent.

Parameters:

  • title (String) (defaults to: "")

    Text that appears in a larger bold font.

  • title_tag (Symbol) (defaults to: :h3)

    HTML tag to use for title.

  • icon (Symbol) (defaults to: "")

    Octicon icon to use at top of component.

  • icon_size (Symbol) (defaults to: :medium)

    <%= one_of(Primer::Beta::Octicon::SIZE_MAPPINGS, sort: false) %>

  • image_src (String) (defaults to: "")

    Image to display.

  • image_alt (String) (defaults to: " ")

    Alt text for image.

  • description (String) (defaults to: "")

    Text that appears below the title. Typically a whole sentence.

  • button_text (String) (defaults to: "")

    The text of the button.

  • button_url (String) (defaults to: "")

    The URL where the user will be taken after clicking the button.

  • button_classes (String) (defaults to: "btn-primary my-3")

    Classes to apply to action button

  • link_text (String) (defaults to: "")

    The text of the link.

  • link_url (String) (defaults to: "")

    The URL where the user will be taken after clicking the link.

  • narrow (Boolean) (defaults to: false)

    Adds a maximum width.

  • large (Boolean) (defaults to: false)

    Increases the font size.

  • spacious (Boolean) (defaults to: false)

    Adds extra padding.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'app/components/primer/blankslate_component.rb', line 35

def initialize(
  title: "",
  title_tag: :h3,
  icon: "",
  icon_size: :medium,
  image_src: "",
  image_alt: " ",
  description: "",
  button_text: "",
  button_url: "",
  button_classes: "btn-primary my-3",
  link_text: "",
  link_url: "",

  # variations
  narrow: false,
  large: false,
  spacious: false,

  **system_arguments
)
  @system_arguments = system_arguments
  @system_arguments[:tag] = :div
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "blankslate",
    "blankslate-narrow": narrow,
    "blankslate-large": large,
    "blankslate-spacious": spacious
  )

  @title_tag = title_tag
  @icon = icon
  @icon_size = icon_size
  @image_src = image_src
  @image_alt = image_alt
  @title = title
  @description = description
  @button_text = button_text
  @button_url = button_url
  @button_classes = button_classes
  @link_text = link_text
  @link_url = link_url
end