2024-04-15 12:04:17 -04:00
|
|
|
import styles from './ModelingPane.module.css'
|
2024-04-15 21:40:45 -04:00
|
|
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
2024-07-02 17:16:27 +10:00
|
|
|
import { useModelingContext } from 'hooks/useModelingContext'
|
2024-07-17 01:17:53 -04:00
|
|
|
import { ActionButton } from 'components/ActionButton'
|
|
|
|
import Tooltip from 'components/Tooltip'
|
2024-07-24 22:02:16 -04:00
|
|
|
import { CustomIconName } from 'components/CustomIcon'
|
|
|
|
import { IconDefinition } from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import { ActionIcon } from 'components/ActionIcon'
|
2024-04-15 12:04:17 -04:00
|
|
|
|
|
|
|
export interface ModelingPaneProps
|
|
|
|
extends React.PropsWithChildren,
|
|
|
|
React.HTMLAttributes<HTMLDivElement> {
|
2024-07-24 22:02:16 -04:00
|
|
|
icon?: CustomIconName | IconDefinition
|
2024-04-15 12:04:17 -04:00
|
|
|
title: string
|
|
|
|
Menu?: React.ReactNode | React.FC
|
|
|
|
detailsTestId?: string
|
2024-07-17 01:17:53 -04:00
|
|
|
onClose: () => void
|
2024-04-15 12:04:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export const ModelingPaneHeader = ({
|
2024-07-24 22:02:16 -04:00
|
|
|
icon,
|
2024-04-15 12:04:17 -04:00
|
|
|
title,
|
|
|
|
Menu,
|
2024-07-17 01:17:53 -04:00
|
|
|
onClose,
|
2024-07-24 22:02:16 -04:00
|
|
|
}: Pick<ModelingPaneProps, 'icon' | 'title' | 'Menu' | 'onClose'>) => {
|
2024-04-15 12:04:17 -04:00
|
|
|
return (
|
|
|
|
<div className={styles.header}>
|
2024-07-24 22:02:16 -04:00
|
|
|
<div className="flex gap-2 items-center flex-1">
|
|
|
|
{icon && (
|
|
|
|
<ActionIcon
|
|
|
|
icon={icon}
|
|
|
|
className="p-1"
|
|
|
|
size="sm"
|
|
|
|
iconClassName="!text-chalkboard-80 dark:!text-chalkboard-30"
|
|
|
|
bgClassName="!bg-transparent"
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
<span>{title}</span>
|
|
|
|
</div>
|
2024-04-15 12:04:17 -04:00
|
|
|
{Menu instanceof Function ? <Menu /> : Menu}
|
2024-07-17 01:17:53 -04:00
|
|
|
<ActionButton
|
|
|
|
Element="button"
|
|
|
|
iconStart={{
|
|
|
|
icon: 'close',
|
|
|
|
iconClassName: '!text-current',
|
|
|
|
bgClassName: 'bg-transparent dark:bg-transparent',
|
|
|
|
}}
|
|
|
|
className="!p-0 !bg-transparent hover:text-primary border-transparent dark:!border-transparent hover:!border-primary dark:hover:!border-chalkboard-70 !outline-none"
|
|
|
|
onClick={onClose}
|
|
|
|
>
|
|
|
|
<Tooltip position="bottom-right" delay={750}>
|
|
|
|
Close
|
|
|
|
</Tooltip>
|
|
|
|
</ActionButton>
|
2024-04-15 12:04:17 -04:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ModelingPane = ({
|
|
|
|
title,
|
2024-07-24 22:02:16 -04:00
|
|
|
icon,
|
2024-04-26 13:20:03 -04:00
|
|
|
id,
|
2024-04-15 12:04:17 -04:00
|
|
|
children,
|
|
|
|
className,
|
|
|
|
Menu,
|
|
|
|
detailsTestId,
|
2024-07-17 01:17:53 -04:00
|
|
|
onClose,
|
2024-04-15 12:04:17 -04:00
|
|
|
...props
|
|
|
|
}: ModelingPaneProps) => {
|
2024-04-15 21:40:45 -04:00
|
|
|
const { settings } = useSettingsAuthContext()
|
|
|
|
const onboardingStatus = settings.context.app.onboardingStatus
|
2024-07-02 17:16:27 +10:00
|
|
|
const { context } = useModelingContext()
|
2024-04-15 21:40:45 -04:00
|
|
|
const pointerEventsCssClass =
|
2024-07-02 17:16:27 +10:00
|
|
|
context.store?.buttonDownInStream || onboardingStatus.current === 'camera'
|
2024-04-15 21:40:45 -04:00
|
|
|
? 'pointer-events-none '
|
|
|
|
: 'pointer-events-auto '
|
2024-04-15 12:04:17 -04:00
|
|
|
return (
|
|
|
|
<section
|
|
|
|
{...props}
|
|
|
|
data-testid={detailsTestId}
|
2024-04-26 13:20:03 -04:00
|
|
|
id={id}
|
2024-04-15 12:04:17 -04:00
|
|
|
className={
|
2024-07-24 22:02:16 -04:00
|
|
|
'focus-within:border-primary dark:focus-within:border-chalkboard-50 ' +
|
2024-06-18 12:42:47 -04:00
|
|
|
pointerEventsCssClass +
|
|
|
|
styles.panel +
|
|
|
|
' group ' +
|
|
|
|
(className || '')
|
2024-04-15 12:04:17 -04:00
|
|
|
}
|
|
|
|
>
|
2024-07-24 22:02:16 -04:00
|
|
|
<ModelingPaneHeader
|
|
|
|
icon={icon}
|
|
|
|
title={title}
|
|
|
|
Menu={Menu}
|
|
|
|
onClose={onClose}
|
|
|
|
/>
|
2024-04-15 12:04:17 -04:00
|
|
|
<div className="relative w-full">{children}</div>
|
|
|
|
</section>
|
|
|
|
)
|
|
|
|
}
|