Module: Plutonium::UI::PageWidth

Defined in:
lib/plutonium/ui/page_width.rb

Overview

The width vocabulary for detail-style pages — the show page, resource forms and wizard steps.

These pages are read and filled top-to-bottom in a single column. Inputs and values stretch to their container, so at full content width on a wide screen you get ~1200px-long lines and text boxes: past a comfortable measure, and a long eye-travel between a label and the value beside it. Index and table pages are deliberately NOT covered — a table wants every pixel it can get.

The tokens deliberately mirror Modal::Base::VALID_SIZES so the framework has one width language rather than two.

Constant Summary collapse

SIZES =

Token => the max-width utility it resolves to. :full is the opt-out: no constraint at all, the historical behaviour.

{
  sm: "max-w-2xl",
  md: "max-w-4xl",
  lg: "max-w-6xl",
  xl: "max-w-7xl",
  full: nil
}.freeze
VALID_SIZES =
SIZES.keys.freeze

Class Method Summary collapse

Class Method Details

.classes_for(size) ⇒ String?

The classes for a token: a max-width plus the centring that makes it read as a column rather than a left-hugging block. :full contributes nothing, so an unconstrained page keeps exactly the markup it had before this vocabulary existed.

Parameters:

  • size (Symbol)

Returns:

  • (String, nil)


37
38
39
40
41
42
# File 'lib/plutonium/ui/page_width.rb', line 37

def self.classes_for(size)
  max_width = SIZES.fetch(size) { raise_unknown(size) }
  return nil if max_width.nil?

  "#{max_width} mx-auto"
end

.validate!(size) ⇒ Object

Raises on an unknown token rather than silently falling back, matching modal and show_in. A typo'd width is a bug, not a default.



46
47
48
49
# File 'lib/plutonium/ui/page_width.rb', line 46

def self.validate!(size)
  return size if VALID_SIZES.include?(size)
  raise_unknown(size)
end