Skip to content

Commit 868a5c2

Browse files
committed
feat: contain
1 parent 62da0cd commit 868a5c2

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

apps/frontend/src/app/(preview)/p/[id]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ export default async function Auth({
146146
{JSON.parse(p?.image || '[]').map((p: any) => (
147147
<div
148148
key={p.name}
149-
className="flex-1 rounded-[10px] overflow-hidden"
149+
className="flex-1 rounded-[10px] max-h-[500px] overflow-hidden"
150150
>
151-
<VideoOrImage src={p.path} autoplay={true} />
151+
<VideoOrImage isContain={true} src={p.path} autoplay={true} />
152152
</div>
153153
))}
154154
</div>

libraries/react-shared-libraries/src/helpers/video.or.image.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
import { FC } from 'react';
2+
import { clsx } from 'clsx';
23

3-
export const VideoOrImage: FC<{ src: string; autoplay: boolean }> = (props) => {
4-
const { src, autoplay } = props;
4+
export const VideoOrImage: FC<{
5+
src: string;
6+
autoplay: boolean;
7+
isContain?: boolean;
8+
}> = (props) => {
9+
const { src, autoplay, isContain } = props;
510
if (src.indexOf('mp4') > -1) {
6-
return <video src={src} autoPlay={autoplay} className="w-full h-full" muted={true} loop={true} />;
11+
return (
12+
<video
13+
src={src}
14+
autoPlay={autoplay}
15+
className="w-full h-full"
16+
muted={true}
17+
loop={true}
18+
/>
19+
);
720
}
821

922
return (
1023
<img
11-
className="w-full h-full object-cover"
24+
className={clsx(
25+
isContain ? 'object-contain' : 'object-cover',
26+
'w-full h-full object-cover'
27+
)}
1228
src={src}
1329
/>
1430
);

0 commit comments

Comments
 (0)