-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDisplayCard.tsx
More file actions
42 lines (39 loc) · 1.15 KB
/
DisplayCard.tsx
File metadata and controls
42 lines (39 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { DISPLAY_ASPECT_RATIO, Display } from '@luna/components/Display';
import { Card, CardFooter } from '@heroui/react';
import React, { memo } from 'react';
interface DisplayCardProps {
username: string;
frame: Uint8Array;
displayWidth: number;
className?: string;
isSkeleton?: boolean;
}
export const DisplayCard = memo(
({
username,
frame,
displayWidth,
className,
isSkeleton,
}: DisplayCardProps) => {
const displayHeight = displayWidth / DISPLAY_ASPECT_RATIO;
return (
<Card className={className}>
{isSkeleton ? (
<div style={{ width: displayWidth, height: displayHeight }} />
) : (
<Display frame={frame} width={displayWidth} />
)}
<CardFooter className="truncate" style={{ width: displayWidth }}>
{username}
</CardFooter>
</Card>
);
},
(prevProps, newProps) =>
prevProps.isSkeleton === newProps.isSkeleton &&
prevProps.className === newProps.className &&
prevProps.displayWidth === newProps.displayWidth &&
prevProps.username === newProps.username &&
prevProps.frame.toString() === newProps.frame.toString()
);