MCPcopy Create free account
hub / github.com/dailydotdev/apps / LazyVideoComponent

Function LazyVideoComponent

packages/shared/src/components/LazyImage.tsx:87–135  ·  view source on GitHub ↗
(
  {
    videoSrc,
    poster,
    eager,
    className,
    ratio,
    background,
    children,
    absolute = false,
    fit = 'cover',
    ...props
  }: LazyVideoProps,
  ref?: Ref<HTMLImageElement>,
)

Source from the content-addressed store, hash-verified

85};
86
87const LazyVideoComponent = (
88 {
89 videoSrc,
90 poster,
91 eager,
92 className,
93 ratio,
94 background,
95 children,
96 absolute = false,
97 fit = 'cover',
98 ...props
99 }: LazyVideoProps,
100 ref?: Ref<HTMLImageElement>,
101): ReactElement => {
102 const src = videoSrc;
103
104 return (
105 <figure
106 {...props}
107 className={classNames(
108 className,
109 absolute ? 'absolute' : 'relative',
110 'overflow-hidden',
111 )}
112 style={{ background, ...props?.style }}
113 ref={ref}
114 >
115 {ratio && <div style={{ paddingTop: ratio, zIndex: -1 }} />}
116 <video
117 className={classNames(
118 'absolute inset-0 m-auto block h-full w-full',
119 fit === 'cover' ? 'object-cover' : 'object-contain',
120 )}
121 key={src}
122 preload={eager ? 'auto' : 'metadata'}
123 poster={poster}
124 src={src}
125 muted
126 autoPlay
127 loop
128 playsInline
129 disablePictureInPicture
130 controls={false}
131 />
132 {children}
133 </figure>
134 );
135};
136
137export const LazyVideo = forwardRef(LazyVideoComponent);
138

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected