Skip to content

Commit

Permalink
fix: add drag styles for improved UX (#7644)
Browse files Browse the repository at this point in the history
  • Loading branch information
driskull authored Sep 1, 2023
1 parent b8bc11c commit afbb764
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/calcite-components/src/assets/styles/_sortable.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@mixin sortable-helper-classes() {
.calcite-sortable--chosen,
.calcite-sortable--ghost,
.calcite-sortable--drag {
@apply border border-dashed;
border-color: var(--calcite-ui-brand);
}
}
2 changes: 2 additions & 0 deletions packages/calcite-components/src/assets/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@
@include animation-reduced-motion();

@include animation-helper-classes();

@include sortable-helper-classes();
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@import "host";
@import "spacing";
@import "floating-ui";
@import "sortable";

@mixin slotted($selector, $tag, $scope: "") {
#{$scope} slot[name="#{$selector}"]::slotted(#{$tag}),
Expand Down
7 changes: 7 additions & 0 deletions packages/calcite-components/src/utils/sortableComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ export interface DragDetail {
dragEl: HTMLElement;
}

export const CSS = {
ghostClass: "calcite-sortable--ghost",
chosenClass: "calcite-sortable--chosen",
dragClass: "calcite-sortable--drag",
};

/**
* Defines interface for components with sorting functionality.
*/
Expand Down Expand Up @@ -81,6 +87,7 @@ export function connectSortableComponent(component: SortableComponent): void {

component.sortable = Sortable.create(component.el, {
dataIdAttr,
...CSS,
...(!!draggable && { draggable }),
...(!!group && {
group: {
Expand Down

0 comments on commit afbb764

Please sign in to comment.