UNPKG

@servicetitan/assist-ui

Version:

ServiceTitan Atlas UI Components

53 lines (52 loc) 1.77 kB
import { jsx as _jsx } from "react/jsx-runtime"; import classNames from 'classnames'; import { motion } from 'framer-motion'; import * as styles from './styles.module.less'; export const ChatWindow = ({ open, position, isDragging, fullscreen = false, children })=>{ const isFullscreenOpen = fullscreen && open; const className = classNames({ [styles.chatWindowExpanded]: isFullscreenOpen, [styles.chatWindow]: !isFullscreenOpen, [styles.open]: !isFullscreenOpen && open, [styles.closed]: !isFullscreenOpen && !open, [styles.positioned]: !isFullscreenOpen && position, [styles.relative]: !isFullscreenOpen && !position }); const getPositionStyles = ()=>{ if (isFullscreenOpen) { return {}; } return position ? { left: position.x, top: position.y } : {}; }; return /*#__PURE__*/ _jsx(motion.div, { layout: !isDragging, initial: { opacity: isFullscreenOpen ? 0 : 1, x: !isFullscreenOpen && !open ? 0 : -25 }, animate: { x: isFullscreenOpen ? 0 : open ? -25 : 0 }, transition: { type: isFullscreenOpen ? 'tween' : 'spring', ease: isFullscreenOpen ? 'easeInOut' : undefined, stiffness: 300, damping: 35, duration: 0.3 }, className: className, style: getPositionStyles(), children: /*#__PURE__*/ _jsx(motion.div, { layout: !isDragging ? 'position' : undefined, style: { width: '100%', height: '100%' }, children: children }) }); }; //# sourceMappingURL=chat-window.js.map