Skip to content

Commit e7c84e8

Browse files
committed
fix: drag handle button UI
1 parent ad9be51 commit e7c84e8

3 files changed

Lines changed: 27 additions & 19 deletions

File tree

packages/editor/src/core/extensions/table/plugins/drag-handles/column/drag-handle.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ export function createColumnDragHandle(config: ColumnDragHandleConfig): {
5353
// Create button
5454
const button = document.createElement("button");
5555
button.type = "button";
56-
button.className =
57-
"py-1 bg-layer-1 border border-strong-1 rounded-sm outline-none transition-all duration-200 hover:bg-layer-1-hover";
56+
button.className = "default-state";
5857

5958
// Create icon (Ellipsis lucide icon as SVG)
6059
const icon = createSvgElement(DRAG_HANDLE_ICONS.ellipsis, "size-4 text-primary");
@@ -89,9 +88,8 @@ export function createColumnDragHandle(config: ColumnDragHandleConfig): {
8988

9089
isDropdownOpen = false;
9190

92-
// Reset button to closed state
93-
button.className =
94-
"px-1 bg-layer-1 border border-strong-1 rounded-sm outline-none transition-all duration-200 hover:bg-layer-1-hover";
91+
// Reset button to default state
92+
button.className = "default-state";
9593

9694
// Remove dropdown and backdrop
9795
if (dropdownElement) {
@@ -126,15 +124,16 @@ export function createColumnDragHandle(config: ColumnDragHandleConfig): {
126124
isDropdownOpen = true;
127125

128126
// Update button to open state
129-
button.className =
130-
"px-1 bg-layer-1 border border-strong-1 rounded-sm outline-none transition-all duration-200 opacity-100 bg-accent-primary border-accent-strong";
127+
button.className = "open-state";
131128

132129
// Add active dropdown extension
133130
editor.commands.addActiveDropbarExtension(CORE_EXTENSIONS.TABLE);
134131

135132
// Create backdrop
136133
backdropElement = document.createElement("div");
137-
backdropElement.style.cssText = "position: fixed; inset: 0; z-index: 99;";
134+
backdropElement.style.position = "fixed";
135+
backdropElement.style.inset = "0";
136+
backdropElement.style.zIndex = "99";
138137
backdropClickHandler = closeDropdown;
139138
backdropElement.addEventListener("click", backdropClickHandler);
140139
document.body.appendChild(backdropElement);
@@ -143,7 +142,8 @@ export function createColumnDragHandle(config: ColumnDragHandleConfig): {
143142
dropdownElement = document.createElement("div");
144143
dropdownElement.className =
145144
"max-h-[90vh] w-[12rem] overflow-y-auto rounded-md border-[0.5px] border-strong bg-surface-1 px-2 py-2.5 shadow-raised-200";
146-
dropdownElement.style.cssText = "position: fixed; z-index: 100;";
145+
dropdownElement.style.position = "fixed";
146+
dropdownElement.style.zIndex = "100";
147147

148148
// Create and append dropdown content
149149
const content = createDropdownContent(getDropdownOptions());

packages/editor/src/core/extensions/table/plugins/drag-handles/row/drag-handle.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ export function createRowDragHandle(config: RowDragHandleConfig): {
5353
// Create button
5454
const button = document.createElement("button");
5555
button.type = "button";
56-
button.className =
57-
"py-1 bg-layer-1 border border-strong-1 rounded-sm outline-none transition-all duration-200 hover:bg-layer-1-hover";
56+
button.className = "default-state";
5857

5958
// Create icon (Ellipsis lucide icon as SVG)
6059
const icon = createSvgElement(DRAG_HANDLE_ICONS.ellipsis, "size-4 text-primary");
@@ -89,9 +88,8 @@ export function createRowDragHandle(config: RowDragHandleConfig): {
8988

9089
isDropdownOpen = false;
9190

92-
// Reset button to closed state
93-
button.className =
94-
"py-1 bg-layer-1 border border-strong-1 rounded-sm outline-none transition-all duration-200 hover:bg-layer-1-hover";
91+
// Reset button to default state
92+
button.className = "default-state";
9593

9694
// Remove dropdown and backdrop
9795
if (dropdownElement) {
@@ -126,15 +124,16 @@ export function createRowDragHandle(config: RowDragHandleConfig): {
126124
isDropdownOpen = true;
127125

128126
// Update button to open state
129-
button.className =
130-
"py-1 bg-layer-1 border border-strong-1 rounded-sm outline-none transition-all duration-200 opacity-100 bg-accent-primary border-accent-strong";
127+
button.className = "open-state";
131128

132129
// Add active dropdown extension
133130
editor.commands.addActiveDropbarExtension(CORE_EXTENSIONS.TABLE);
134131

135132
// Create backdrop
136133
backdropElement = document.createElement("div");
137-
backdropElement.style.cssText = "position: fixed; inset: 0; z-index: 99;";
134+
backdropElement.style.position = "fixed";
135+
backdropElement.style.inset = "0";
136+
backdropElement.style.zIndex = "99";
138137
backdropClickHandler = closeDropdown;
139138
backdropElement.addEventListener("click", backdropClickHandler);
140139
document.body.appendChild(backdropElement);
@@ -143,7 +142,8 @@ export function createRowDragHandle(config: RowDragHandleConfig): {
143142
dropdownElement = document.createElement("div");
144143
dropdownElement.className =
145144
"max-h-[90vh] w-[12rem] overflow-y-auto rounded-md border-[0.5px] border-strong bg-surface-1 px-2 py-2.5 shadow-raised-200";
146-
dropdownElement.style.cssText = "position: fixed; z-index: 100;";
145+
dropdownElement.style.position = "fixed";
146+
dropdownElement.style.zIndex = "100";
147147

148148
// Create and append dropdown content
149149
const content = createDropdownContent(getDropdownOptions());

packages/editor/src/styles/table.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@
5757
.table-col-handle-container,
5858
.table-row-handle-container {
5959
& > button {
60-
opacity: 0;
60+
@apply py-1 opacity-0 rounded-sm outline-none;
61+
62+
&.default-state {
63+
@apply bg-layer-1 hover:bg-layer-1-hover border border-strong-1;
64+
}
65+
66+
&.open-state {
67+
@apply opacity-100! bg-accent-primary border-accent-strong;
68+
}
6169
}
6270
}
6371

0 commit comments

Comments
 (0)