forked from ontoportal/ontoportal_web_ui
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Add see more items component (#910)
* add list items component to hide container items if more than max items * use list item component in concept details component for synonyms and others * fix show edge case where max items is equal to the items total length * remove an cyclic include raising an exception
- Loading branch information
1 parent
39208bd
commit 2d48fa4
Showing
7 changed files
with
41 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
class ListItemsShowMoreComponent < ViewComponent::Base | ||
renders_many :containers | ||
|
||
def initialize(max_items: 10) | ||
super | ||
@max_items = max_items - 1 | ||
end | ||
|
||
end |
14 changes: 14 additions & 0 deletions
14
app/components/list_items_show_more_component/list_items_show_more_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
%div{data: {controller: 'reveal-component'}} | ||
- containers[..@max_items].each do |item| | ||
= item | ||
|
||
- if (@max_items + 1) < containers.size | ||
- Array(containers[@max_items+1..]).each do |item| | ||
%span{'data-reveal-component-target': "item", class: 'd-none'} | ||
= item | ||
%div{'data-reveal-component-target': "showButton", 'data-action': "click->reveal-component#show" } | ||
%span.btn-link | ||
See more | ||
%div.d-none{'data-reveal-component-target': "hideButton", 'data-action': "click->reveal-component#hide" } | ||
%span.btn-link | ||
See less |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters