Class: Plutonium::UI::Block

Inherits:
Component::Base show all
Defined in:
lib/plutonium/ui/block.rb

Overview

A plain card surface to wrap arbitrary content in.

This is THE card primitive — it renders pu-card rather than hand-rolling a surface. It used to paint its own background, radius and --pu-shadow-md inline, which left it subtly out of step with every pu-card on the page: no border, and a heavier shadow. Anything wrapping a pu-card in a Block then stacked two cards and got a doubled shadow, while anything wrapping bare content got a borderless one — which is why the show page's details and its metadata rail used to sit on visibly different surfaces.

It carries no outer margin: spacing between cards belongs to whatever stacks them (a space-y-* container), not to the card itself, so a single Block can't decide the rhythm of a list it doesn't know it's in. Extra classes may be merged in (Block(class: "overflow-hidden")) so a caller can adjust the card without re-declaring what a card is.

Instance Method Summary collapse

Methods included from Component::Behaviour

#around_template

Methods included from Component::Tokens

#classes, #tokens

Methods included from Component::Kit

#BuildActionButton, #BuildActionsDropdown, #BuildAvatar, #BuildBlock, #BuildBreadcrumbs, #BuildBulkActionsToolbar, #BuildColorModeSelector, #BuildDynaFrameContent, #BuildDynaFrameHost, #BuildEmptyCard, #BuildFrameNavigatorPanel, #BuildModalCentered, #BuildModalSlideover, #BuildPageHeader, #BuildPanel, #BuildRowActionsDropdown, #BuildSkeletonTable, #BuildTabList, #BuildTableFilterPills, #BuildTableInfo, #BuildTablePagination, #BuildTableScopesBar, #BuildTableScopesPills, #BuildTableSearchBar, #BuildTableToolbar, #BuildTableViewSwitcher, #method_missing, #respond_to_missing?

Constructor Details

#initialize(**options) ⇒ Block

Returns a new instance of Block.



20
21
22
# File 'lib/plutonium/ui/block.rb', line 20

def initialize(**options)
  @class = options[:class]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit

Instance Method Details

#view_templateObject

Raises:

  • (ArgumentError)


24
25
26
27
28
29
30
# File 'lib/plutonium/ui/block.rb', line 24

def view_template(&)
  raise ArgumentError, "Block requires a content block" unless block_given?

  div class: tokens("relative pu-card", @class) do
    yield
  end
end