Class: Plutonium::UI::Modal::Base

Inherits:
Component::Base show all
Includes:
Phlex::Slotable
Defined in:
lib/plutonium/ui/modal/base.rb

Direct Known Subclasses

Centered, Slideover

Constant Summary collapse

VALID_SIZES =

Sizes that all modal subclasses must implement entries for in their SIZE_CLASSES table. :auto is content-driven (w-fit with a viewport cap and a sensible floor) and is the only way to avoid clipping forms whose natural width exceeds the default. Sizes intentionally mirror Tailwind's max-w-* scale so a definition that says size: :xl reads predictably.

[:sm, :md, :lg, :xl, :auto, :full].freeze

Class Method Summary collapse

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(title: nil, description: nil, size: :md, open_full_url: nil) ⇒ Base

Returns a new instance of Base.



27
28
29
30
31
32
33
34
35
36
# File 'lib/plutonium/ui/modal/base.rb', line 27

def initialize(title: nil, description: nil, size: :md, open_full_url: nil)
  @title = title
  @description = description
  @size = size
  # When set, the header shows an "open full page" affordance that opens
  # this URL in a new tab as a standalone page (no modal frame). The show
  # modal uses it so a user can pop the record out to its full page.
  @open_full_url = open_full_url
  validate_size!
end

Dynamic Method Handling

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

Class Method Details

.class_for_mode(mode) ⇒ Object

Resolves the concrete modal class for a definition's modal_mode symbol. Unknown / false modes fall back to Slideover so call sites can stay branchless.



23
24
25
# File 'lib/plutonium/ui/modal/base.rb', line 23

def self.class_for_mode(mode)
  (mode == :centered) ? Plutonium::UI::Modal::Centered : Plutonium::UI::Modal::Slideover
end

Instance Method Details

#view_template(&block) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/plutonium/ui/modal/base.rb', line 38

def view_template(&block)
  dialog(**dialog_attributes) do
    div(class: inner_classes) do
      render_header
      render_body(&block)
      render_footer if footer_slot?
    end
  end
end