Class: ScrimComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/scrim_component.rb

Constant Summary collapse

ACTIONS =
%w[
  click->scrim#dismiss
  keyup@window->scrim#escape
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: "scrim", z_index: 40) ⇒ ScrimComponent

Returns a new instance of ScrimComponent.



11
12
13
14
15
16
# File 'app/components/scrim_component.rb', line 11

def initialize(id: "scrim", z_index: 40)
  super

  @id      = id
  @z_index = z_index
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'app/components/scrim_component.rb', line 4

def id
  @id
end

#z_indexObject (readonly)

Returns the value of attribute z_index.



4
5
6
# File 'app/components/scrim_component.rb', line 4

def z_index
  @z_index
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
# File 'app/components/scrim_component.rb', line 18

def call
  tag.div(id:,
          class: "scrim",
          data:  {
            controller:          "scrim",
            scrim_z_index_value: z_index,
            turbo_permanent:     "",
            action:              ACTIONS.join(" "),
          })
end

#inspectObject



29
30
31
# File 'app/components/scrim_component.rb', line 29

def inspect
  "#<#{self.class.name} id: #{id.inspect}>"
end