Class: LightningUiKit::ScrollAreaComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/lightning_ui_kit/scroll_area_component.rb

Constant Summary collapse

ORIENTATIONS =
%i[vertical horizontal both].freeze

Instance Method Summary collapse

Constructor Details

#initialize(orientation: :vertical, **options) ⇒ ScrollAreaComponent

Returns a new instance of ScrollAreaComponent.



4
5
6
7
# File 'app/components/lightning_ui_kit/scroll_area_component.rb', line 4

def initialize(orientation: :vertical, **options)
  @orientation = ORIENTATIONS.include?(orientation) ? orientation : :vertical
  @options = options
end

Instance Method Details

#classesObject



9
10
11
12
13
14
15
16
17
# File 'app/components/lightning_ui_kit/scroll_area_component.rb', line 9

def classes
  scrollbar = "lui:[scrollbar-width:thin] " \
    "lui:[&::-webkit-scrollbar]:h-2 lui:[&::-webkit-scrollbar]:w-2 " \
    "lui:[&::-webkit-scrollbar-track]:bg-transparent " \
    "lui:[&::-webkit-scrollbar-thumb]:rounded-full lui:[&::-webkit-scrollbar-thumb]:bg-border-hover " \
    "lui:[&::-webkit-scrollbar-thumb:hover]:bg-foreground-faint"

  merge_classes(["lui:relative", overflow_classes, scrollbar, @options[:class]].compact.join(" "))
end

#dataObject



19
20
21
# File 'app/components/lightning_ui_kit/scroll_area_component.rb', line 19

def data
  @options[:data] || {}
end