@primer/react
Version:
An implementation of GitHub's Primer Design System using React
21 lines (20 loc) • 1.45 kB
JavaScript
//#region src/PageLayout/paneUtils.ts
const DATA_DRAGGING_ATTR = "data-dragging";
/** Apply visual feedback and performance optimizations during drag */
function setDraggingStyles({ handle, pane, contentWrapper }) {
handle === null || handle === void 0 || handle.style.setProperty("--draggable-handle--bg-color", "var(--bgColor-accent-emphasis)");
handle === null || handle === void 0 || handle.style.setProperty("--draggable-handle--drag-opacity", "1");
handle === null || handle === void 0 || handle.style.setProperty("--draggable-handle--transition", "none");
pane === null || pane === void 0 || pane.setAttribute(DATA_DRAGGING_ATTR, "true");
contentWrapper === null || contentWrapper === void 0 || contentWrapper.setAttribute(DATA_DRAGGING_ATTR, "true");
}
/** Remove drag styles and restore normal state */
function removeDraggingStyles({ handle, pane, contentWrapper }) {
handle === null || handle === void 0 || handle.style.removeProperty("--draggable-handle--bg-color");
handle === null || handle === void 0 || handle.style.removeProperty("--draggable-handle--drag-opacity");
handle === null || handle === void 0 || handle.style.removeProperty("--draggable-handle--transition");
pane === null || pane === void 0 || pane.removeAttribute(DATA_DRAGGING_ATTR);
contentWrapper === null || contentWrapper === void 0 || contentWrapper.removeAttribute(DATA_DRAGGING_ATTR);
}
//#endregion
export { removeDraggingStyles, setDraggingStyles };