Class: NitroKit::ResponsiveValue
- Inherits:
-
Object
- Object
- NitroKit::ResponsiveValue
- Defined in:
- app/components/nitro_kit/responsive_value.rb
Constant Summary collapse
- BREAKPOINTS =
{ "sm" => "40rem", "md" => "48rem", "lg" => "64rem", "xl" => "80rem", "2xl" => "96rem" }.freeze
Instance Method Summary collapse
-
#initialize(property:, value:, allowed:) ⇒ ResponsiveValue
constructor
A new instance of ResponsiveValue.
- #to_s ⇒ Object
Constructor Details
#initialize(property:, value:, allowed:) ⇒ ResponsiveValue
Returns a new instance of ResponsiveValue.
13 14 15 16 17 18 |
# File 'app/components/nitro_kit/responsive_value.rb', line 13 def initialize(property:, value:, allowed:) @property = property @allowed = allowed.map { |candidate| normalize(candidate) }.freeze @values = parse(value).freeze freeze end |
Instance Method Details
#to_s ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/components/nitro_kit/responsive_value.rb', line 20 def to_s [ nil, *BREAKPOINTS.keys ].filter_map do |breakpoint| value = @values[breakpoint] next unless value breakpoint ? "#{breakpoint}:#{value}" : value end.join(" ") end |