1 | module Midwest |
2 | class GroupComponent < BaseComponent |
3 | option :max, default: nil |
4 | option :size, default: -> { :default } |
5 | option :gap, default: -> { :default } |
6 | |
7 | renders_many :items |
8 | |
9 | def visible_items |
10 | max ? items.first(max) : items |
11 | end
|
12 | |
13 | def overflow_count |
14 | return 0 unless max && items.length > max |
15 | items.length - max |
16 | end
|
17 | end
|
18 | end
|