-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable reordering of project resources (#668)
* WIP prototype * WIP Prototype * WIP Prototype (edge detection) * WIP index logic * WIP index logic * Save reorder on drop * Cleanup * Rearrange with custom preview * Start of dropdown list * WIP smart configuration * Make drag setup dynamic * Add moveUp/moveDown args to external links * Small readOnly/itemsLength refactor * Add icons to "move" menu * Add dropdown menu functions * Fix `toBottom` action; tweak menu item padding * Improved drag affordances * Improve hover / focus states * Remove comment * Remove unused getter * Remove out-of-scope prettier changes * Cleanup reorder function; add documentation * Add documentation * Remove `id` artifacts * Close dropdown when dragging * Announce movement onDrop * CSS tweaks * Refactor some CSS * Add `TileMedium` test * CSS cleanup * Add `resource-test` * Test icons * Add drag-handle test * Test rearranging docs * Test reordering links * Fix externalLink test * Don't allow lists to drag/drop into each other * Refactor `isHoveringSameParent` * Focuses dragHandle after drop
- Loading branch information
Showing
21 changed files
with
1,198 additions
and
32 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
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
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,67 @@ | ||
<li | ||
{{did-insert this.registerElement}} | ||
data-index={{@index}} | ||
data-closest-edge={{this.closestEdge}} | ||
class="group relative block {{if this.isDragging 'is-dragging opacity-50'}}" | ||
data-test-resource-list-item | ||
...attributes | ||
> | ||
{{! Drop affordance }} | ||
{{#if this.dragHasEntered}} | ||
<div | ||
class="absolute z-10 h-1 w-full rounded-l-full rounded-r-full | ||
{{if this.closestEdge 'bg-color-foreground-action'}} | ||
{{if | ||
(eq this.closestEdge 'top') | ||
'-top-px -translate-y-1/2' | ||
(if (eq this.closestEdge 'bottom') 'bottom-0 translate-y-1/2') | ||
}}" | ||
> | ||
</div> | ||
{{/if}} | ||
|
||
{{yield | ||
(hash | ||
moveToTop=this.moveToTop | ||
moveUp=this.moveUp | ||
moveDown=this.moveDown | ||
moveToBottom=this.moveToBottom | ||
) | ||
}} | ||
|
||
</li> | ||
|
||
{{! | ||
A hidden div rendered only if the list is interactive. | ||
Used to configure the drag-and-drop behavior in a state-reactive way, | ||
refreshing or initializing when the list changes from read only to interactive. | ||
}} | ||
{{#unless @isReadOnly}} | ||
{{#in-element (html-element ".ember-application") insertBefore=null}} | ||
<div | ||
{{did-insert this.configureDragAndDrop}} | ||
class="absolute top-0 left-0" | ||
aria-hidden={{true}} | ||
/> | ||
{{/in-element}} | ||
{{/unless}} | ||
|
||
{{! Drag preview }} | ||
{{#if this.isDragging}} | ||
{{! Target the customNativeDragPreview container }} | ||
{{! This element will be available by the time `html-element` runs }} | ||
{{#in-element (html-element (concat "#" this.id)) insertBefore=null}} | ||
<div | ||
class="grid h-10 max-w-[500px] cursor-grabbing items-center rounded bg-color-page-primary px-3" | ||
> | ||
<div class="truncate font-semibold text-color-foreground-strong"> | ||
{{this.itemTitle}} | ||
{{#if this.docNumber}} | ||
<span class="ml-1 font-regular"> | ||
{{this.docNumber}} | ||
</span> | ||
{{/if}} | ||
</div> | ||
</div> | ||
{{/in-element}} | ||
{{/if}} |
Oops, something went wrong.