|
1 | 1 | import type { IconDefinition } from '@fortawesome/free-solid-svg-icons'
|
2 | 2 | import { Resizable } from 're-resizable'
|
3 |
| -import type { MouseEventHandler } from 'react' |
| 3 | +import type { HTMLProps, MouseEventHandler } from 'react' |
4 | 4 | import { useCallback, useContext, useEffect, useMemo } from 'react'
|
5 | 5 | import { useHotkeys } from 'react-hotkeys-hook'
|
6 | 6 |
|
7 | 7 | import { useAppState } from '@src/AppState'
|
8 | 8 | import { ActionIcon } from '@src/components/ActionIcon'
|
9 |
| -import type { CustomIconName } from '@src/components/CustomIcon' |
| 9 | +import { CustomIcon, type CustomIconName } from '@src/components/CustomIcon' |
10 | 10 | import { MachineManagerContext } from '@src/components/MachineManagerProvider'
|
11 | 11 | import { ModelingPane } from '@src/components/ModelingSidebar/ModelingPane'
|
12 | 12 | import type {
|
@@ -218,33 +218,39 @@ export function ModelingSidebar() {
|
218 | 218 |
|
219 | 219 | return (
|
220 | 220 | <Resizable
|
221 |
| - className={`group flex-1 flex flex-col z-10 my-2 pr-1 ${pointerEventsCssClass}`} |
| 221 | + className={`group z-10 flex flex-col ${pointerEventsCssClass} ${context.store?.openPanes.length ? undefined : '!w-auto'}`} |
222 | 222 | defaultSize={{
|
223 |
| - width: '550px', |
| 223 | + width: context.store?.openPanes.length ? '550px' : undefined, |
224 | 224 | height: 'auto',
|
225 | 225 | }}
|
226 |
| - minWidth={200} |
| 226 | + minWidth={context.store?.openPanes.length ? 200 : undefined} |
227 | 227 | maxWidth={window.innerWidth - 10}
|
228 | 228 | handleWrapperClass="sidebar-resize-handles"
|
229 |
| - handleClasses={{ |
230 |
| - right: |
231 |
| - (context.store?.openPanes.length === 0 ? 'hidden ' : 'block ') + |
232 |
| - 'translate-x-1/2 hover:bg-chalkboard-10 hover:dark:bg-chalkboard-110 bg-transparent transition-colors duration-75 transition-ease-out delay-100 ', |
233 |
| - left: 'hidden', |
234 |
| - top: 'hidden', |
235 |
| - topLeft: 'hidden', |
236 |
| - topRight: 'hidden', |
237 |
| - bottom: 'hidden', |
238 |
| - bottomLeft: 'hidden', |
239 |
| - bottomRight: 'hidden', |
| 229 | + enable={{ |
| 230 | + right: true, |
| 231 | + top: false, |
| 232 | + bottom: false, |
| 233 | + left: false, |
| 234 | + topRight: false, |
| 235 | + bottomRight: false, |
| 236 | + bottomLeft: false, |
| 237 | + topLeft: false, |
| 238 | + }} |
| 239 | + handleComponent={{ |
| 240 | + right: ( |
| 241 | + <ResizeHandle |
| 242 | + className={ |
| 243 | + context.store?.openPanes.length === 0 ? 'hidden ' : 'block ' |
| 244 | + } |
| 245 | + /> |
| 246 | + ), |
240 | 247 | }}
|
241 | 248 | >
|
242 |
| - <div id="app-sidebar" className="flex flex-row h-full"> |
| 249 | + <div id="app-sidebar" className="flex flex-row flex-1"> |
243 | 250 | <ul
|
244 | 251 | className={
|
245 |
| - (context.store?.openPanes.length === 0 ? 'rounded-r ' : '') + |
246 |
| - 'relative z-[2] pointer-events-auto p-0 col-start-1 col-span-1 h-fit w-fit flex flex-col ' + |
247 |
| - 'bg-chalkboard-10 border border-solid border-chalkboard-30 dark:bg-chalkboard-90 dark:border-chalkboard-80 group-focus-within:border-primary dark:group-focus-within:border-chalkboard-50 shadow-sm ' |
| 252 | + 'relative pointer-events-auto p-0 col-start-1 col-span-1 flex flex-col ' + |
| 253 | + 'bg-chalkboard-10 border-r border-chalkboard-30 dark:bg-chalkboard-90 dark:border-chalkboard-80 ' |
248 | 254 | }
|
249 | 255 | >
|
250 | 256 | <ul
|
@@ -294,7 +300,7 @@ export function ModelingSidebar() {
|
294 | 300 | <ul
|
295 | 301 | id="pane-section"
|
296 | 302 | className={
|
297 |
| - 'ml-[-1px] col-start-2 col-span-1 flex flex-col items-stretch gap-2 ' + |
| 303 | + 'ml-[-1px] col-start-2 col-span-1 flex flex-col items-stretch border-x border-chalkboard-30 dark:border-chalkboard-80 ' + |
298 | 304 | (context.store?.openPanes.length >= 1 ? `w-full` : `hidden`)
|
299 | 305 | }
|
300 | 306 | >
|
@@ -360,7 +366,7 @@ function ModelingPaneButton({
|
360 | 366 | data-onboarding-id={`${paneConfig.id}-pane-button`}
|
361 | 367 | >
|
362 | 368 | <button
|
363 |
| - className="group pointer-events-auto flex items-center justify-center border-transparent dark:border-transparent disabled:!border-transparent p-0 m-0 rounded-sm !outline-0 focus-visible:border-primary" |
| 369 | + className="group pointer-events-auto flex items-center justify-center border-transparent dark:border-transparent disabled:!border-transparent p-0 m-0 rounded-sm !outline-0" |
364 | 370 | onClick={onClick}
|
365 | 371 | name={paneConfig.sidebarName}
|
366 | 372 | data-testid={paneConfig.id + SIDEBAR_BUTTON_SUFFIX}
|
@@ -430,3 +436,20 @@ function ModelingPaneButton({
|
430 | 436 | </div>
|
431 | 437 | )
|
432 | 438 | }
|
| 439 | + |
| 440 | +function ResizeHandle(props: HTMLProps<HTMLDivElement>) { |
| 441 | + return ( |
| 442 | + <div |
| 443 | + {...props} |
| 444 | + className={'group/grip absolute inset-0 ' + props.className} |
| 445 | + > |
| 446 | + <div |
| 447 | + className={ |
| 448 | + 'hidden group-hover/grip:block py-1 absolute top-1/2 -translate-y-1/2 left-1/2 -translate-x-1/2 rounded-sm w-fit group-hover/grip:bg-chalkboard-30 group-hover/grip:dark:bg-chalkboard-70 bg-transparent transition-colors border border-transparent group-hover/grip:border-chalkboard-40 dark:group-hover/grip:border-chalkboard-90 duration-75 transition-ease-out delay-100' |
| 449 | + } |
| 450 | + > |
| 451 | + <CustomIcon className="w-5 -mx-0.5 rotate-90" name="sixDots" /> |
| 452 | + </div> |
| 453 | + </div> |
| 454 | + ) |
| 455 | +} |
0 commit comments