ViewportBackground.tsx 993 B

123456789101112131415161718192021222324252627282930
  1. 'use client';
  2. import { useSceneSelector } from '@/lib/contexts/scene-context';
  3. import { useSlideBackgroundStyle } from '@/lib/hooks/use-slide-background-style';
  4. import type { SlideContent } from '@/lib/types/stage';
  5. import type { SlideBackground } from '@/lib/types/slides';
  6. /**
  7. * Viewport background component using Scene Context
  8. * Renders the slide background from current scene data
  9. */
  10. export function ViewportBackground() {
  11. // Subscribe only to background for performance
  12. const background = useSceneSelector<SlideContent, SlideBackground | undefined>(
  13. (content) => content.canvas.background,
  14. );
  15. const { backgroundStyle: bgStyle } = useSlideBackgroundStyle(background);
  16. const backgroundStyle: React.CSSProperties = {
  17. ...bgStyle,
  18. width: '100%',
  19. height: '100%',
  20. backgroundPosition: 'center',
  21. position: 'absolute',
  22. pointerEvents: 'none', // Don't block mouse events
  23. };
  24. return <div className="viewport-background" style={backgroundStyle} />;
  25. }