panel-layer.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import clsx from 'clsx';
  6. import { useGlobalCSS } from '../../hooks/use-global-css';
  7. import { PanelArea } from './panel';
  8. import { globalCSS } from './css';
  9. export type PanelLayerProps = React.PropsWithChildren<{
  10. /** 模式:悬浮|挤压 */
  11. mode?: 'floating' | 'docked';
  12. className?: string;
  13. style?: React.CSSProperties;
  14. }>;
  15. export const PanelLayer: React.FC<PanelLayerProps> = ({
  16. mode = 'floating',
  17. className,
  18. style,
  19. children,
  20. }) => {
  21. useGlobalCSS({
  22. cssText: globalCSS,
  23. id: 'flow-panel-layer-css',
  24. });
  25. return (
  26. <div
  27. className={clsx(
  28. 'gedit-flow-panel-layer-wrap',
  29. mode === 'docked' && 'gedit-flow-panel-layer-wrap-docked',
  30. mode === 'floating' && 'gedit-flow-panel-layer-wrap-floating',
  31. className
  32. )}
  33. style={style}
  34. >
  35. <div className="gedit-flow-panel-left-area">
  36. <div className="gedit-flow-panel-main-area">{children}</div>
  37. <div className="gedit-flow-panel-bottom-area">
  38. <PanelArea area={mode === 'docked' ? 'docked-bottom' : 'bottom'} />
  39. </div>
  40. </div>
  41. <div className="gedit-flow-panel-right-area">
  42. <PanelArea area={mode === 'docked' ? 'docked-right' : 'right'} />
  43. </div>
  44. </div>
  45. );
  46. };