-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List: Sortable list interactions update #1541
Changes from 13 commits
7bd6207
7e3d76f
b15e6b3
415e4f5
e9c76d7
86c23e8
6b6f0ff
27237c5
9cc8253
c98ad63
608e608
f2f43db
d677c8a
14c6be0
62c7bf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,41 +55,76 @@ sample_products = [ | |
|
||
<h3 class="<%= SageClassnames::TYPE::HEADING_6 %>">Default configuration</h3> | ||
<%= md(" | ||
SageList is implemented most simply by passing the desired contents for the items through the `SageList` `items` property. | ||
This assumes that the contents of the list are already formatted as desired. | ||
`SageList` is implemented most simply by passing the desired contents for the items through the `SageList` `items` property. | ||
This assumes that the contents of the list are already formatted as desired or you're outputting simple content values. | ||
", use_sage_type: true) %> | ||
|
||
<%= sage_component SageList, { | ||
items: sample_products.map { | item | { | ||
content: "Item #{item[:name]}", | ||
id: "example-default-item-#{item[:id]}", | ||
more_actions: { items: dropdown_items(item[:id]) }, | ||
} | ||
}, | ||
} %> | ||
|
||
<h3 class="<%= SageClassnames::TYPE::HEADING_6 %>">Sortable configuration</h3> | ||
<%= md(" | ||
Sortable lists can be created with `SageList` by adding `sortable: true` and a `sortable_resource`. | ||
You can also pass a `sortable_update_url` for sorting callbacks to items | ||
that will be called after the user finishes sorting an item. | ||
", use_sage_type: true) %> | ||
|
||
<%= sage_component SageList, { | ||
sortable: true, | ||
sortable_resource: "sample_products", | ||
items: sample_products.map { | item | { | ||
content: %( | ||
<h4>Item #{item[:name]}</h4> | ||
<p>Item #{item[:id]} specs</p> | ||
).html_safe, | ||
id: item[:id], | ||
content: "Item #{item[:name]}", | ||
id: "example-sortable-item-#{item[:id]}", | ||
more_actions: { items: dropdown_items(item[:id]) }, | ||
sortable: true, | ||
sortable_update_url: "#sortable-update-url?item=#{item[:id]}", | ||
} | ||
} | ||
}, | ||
} %> | ||
|
||
<h3 class="<%= SageClassnames::TYPE::HEADING_6 %>">Fully draggable row</h3> | ||
<%= md(" | ||
By default only the drag handle is active for dragging/sorting a row. | ||
However, `draggable_anywhere` can be set to `true` in order to allow the whole row to be draggable instead. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe you need to change |
||
", use_sage_type: true) %> | ||
|
||
<%= sage_component SageList, { | ||
sortable: true, | ||
sortable_resource: "sample_products_2", | ||
items: sample_products.map { | item | { | ||
content: "Item #{item[:name]}", | ||
id: "example-fully-draggable-item-#{item[:id]}", | ||
more_actions: { items: dropdown_items(item[:id]) }, | ||
sortable_update_url: "#sortable-update-url?item=#{item[:id]}", | ||
}}, | ||
drag_handle_type: "row", | ||
} %> | ||
|
||
<h3 class="<%= SageClassnames::TYPE::HEADING_6 %>">Compositional approach</h3> | ||
<%= md(" | ||
If you need more native content formatting you can instead opt to render items using a nested loop and the SageListItem component. | ||
If you need more native content formatting you can instead opt to render items using a nested loop and the `SageListItem` component. | ||
Note that this example also implements the [Reveal utility class](#{pages_helpers_path(:reveal)}). | ||
", use_sage_type: true) %> | ||
|
||
<%= sage_component SageList, { sortable_resource: "sample_products_2" } do %> | ||
<%= sage_component SageList, { | ||
sortable: true, | ||
sortable_resource: "sample_products_3", | ||
drag_handle_type: "row", | ||
} do %> | ||
<% sample_products.each do | item | %> | ||
<%= sage_component SageListItem, { | ||
id: item[:id], | ||
id: "example-default-item-#{item[:id]}", | ||
more_actions: { items: dropdown_items(item[:id]) }, | ||
sortable: true, | ||
sortable_update_url: "#sortable-update-url?item={item[:id]}", | ||
css_classes: SageClassnames::REVEAL_CONTAINER, | ||
} do %> | ||
<%= sage_component SageCardRow, { grid_template: "ete" } do %> | ||
<img src="//source.unsplash.com/random/240x160?v=<%= item[:id] %>" width="100" alt="" /> | ||
<img src="https://source.unsplash.com/random/240x160?v=<%= item[:id] %>" width="64" alt="" /> | ||
<%= sage_component SageCardBlock, {} do %> | ||
<h4><%= item[:name] %></h4> | ||
<p>Item <%= item[:id] %> specs</p> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
<% | ||
tag = component.tag.present? ? component.tag : "ul" | ||
drag_handle_type = component.tag.present? ? component.tag : "default" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may have been an oversight or a misunderstanding from me. Is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh wow good catch. I'll touch this up for sure! |
||
%> | ||
<<%= tag %> | ||
class=" | ||
sage-list | ||
<%= component.generated_css_classes %> | ||
<%= "sage-list--hide-first-border" if component.hide_first_border %> | ||
<%= "sage-list--sortable" if component.sortable %> | ||
<%= "sage-list--draggable-by-row" if component.drag_handle_type == "row" %> | ||
" | ||
<%= "data-js-list-sortable=#{component.sortable_resource}" if component.sortable_resource.present? %> | ||
<%= component.generated_html_attributes.html_safe %> | ||
|
@@ -15,6 +17,5 @@ tag = component.tag.present? ? component.tag : "ul" | |
<%= sage_component SageListItem, item_configs %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= component.content %> | ||
</<%= tag %>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sortable examples, thoughts on adding
tag: "ol"
to drive home the ordinal values?I suppose we could also be more heavy-handed and change the default to an
ol
when settingsortable: true
in the component, but that's beyond the scope of this work.