Skip to content

Commit fd7ee75

Browse files
committed
(docs) improve the style when dragging jcubic#438
1 parent 52f3af5 commit fd7ee75

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

docs/src/components/ScreenShotBox/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const example_code = `(define re #/<h1>([^>]+)<\\/h1>/)
2222
(loop (- i 1))))
2323
`;
2424

25-
const WIDTH_MIN = 50;
25+
const WIDTH_MIN = 200;
2626

2727
export default function ScreenShotBox(): JSX.Element {
2828
const dragging = useRef<boolean>(false);
@@ -48,10 +48,12 @@ export default function ScreenShotBox(): JSX.Element {
4848
width = WIDTH_MIN + 1;
4949
}
5050
boxRef.current.style.setProperty('--width', `${width}px`);
51+
document.body.classList.add('dragging');
5152
}
5253
}
5354
function mouseUp() {
5455
dragging.current = false;
56+
document.body.classList.remove('dragging');
5557
}
5658
document.addEventListener('mousemove', mouseMove);
5759
document.addEventListener('mouseup', mouseUp);

docs/src/components/ScreenShotBox/style.css

+10-2
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@
4545
.resizable {
4646
display: flex;
4747
}
48+
49+
4850
.resizable .resizer {
4951
width: 5px;
5052
cursor: ew-resize;
5153
border-radius: 0 var(--radius) var(--radius) 0;
5254
}
53-
.resizable .resizer:hover {
55+
body.dragging:has(.resizable) * {
56+
cursor: ew-resize;
57+
}
58+
.resizable .resizer:hover, body.dragging .resizable .resizer {
5459
background: #bd6b18;
5560
}
5661
.position, .cm-shadow-box, .wrapper {
@@ -69,9 +74,12 @@
6974
z-index: 100;
7075
overflow: hidden;
7176
}
72-
.cm-dialog:has(+.resizer:hover) {
77+
.cm-dialog:has(+.resizer:hover), body.dragging .cm-dialog {
7378
border-radius: var(--radius) 0 0 var(--radius);
7479
}
80+
.cm-dialog:has(+.resizer:hover) *, body.dragging .cm-dialog * {
81+
user-select: none;
82+
}
7583
.cm-dialog header {
7684
padding: 10px;
7785
}

0 commit comments

Comments
 (0)