Skip to content
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

fix: add drag styles for improved UX #7644

Merged
merged 6 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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