Skip to content

Commit 85749e3

Browse files
JacobDiazCruzCarl Cruz
and
Carl Cruz
authored
Fixed list view distorted thumbnail (#1581)
* Update: thumbnail styling on insights table * Added: filter insight files that exists in media * Fixed: media list thumbnail view * Fixed: table border Co-authored-by: Carl Cruz <[email protected]>
1 parent 94a3e08 commit 85749e3

File tree

3 files changed

+68
-27
lines changed

3 files changed

+68
-27
lines changed

src/apps/media/src/app/components/InsightsTable.tsx

+36-15
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ interface Props {
3939

4040
export const InsightsTable: FC<Props> = ({ files, loading }) => {
4141
const history = useHistory();
42+
4243
const columns = [
4344
{
4445
field: "filename",
@@ -54,22 +55,36 @@ export const InsightsTable: FC<Props> = ({ files, loading }) => {
5455

5556
return (
5657
<Box sx={{ display: "flex" }}>
57-
<CardMedia
58-
component="img"
59-
onError={handleImageError}
60-
data-src={params.row.thumbnail || params.row.FullPath}
61-
image={
62-
isImageError
63-
? fileBroken
64-
: params.row.thumbnail || params.row.FullPath
65-
}
66-
loading="lazy"
58+
<Box
6759
sx={{
68-
objectFit: "fill",
69-
width: "52px",
7060
height: "52px",
61+
width: "52px",
62+
overflow: "hidden",
63+
backgroundColor: "grey.100",
64+
position: "relative",
65+
backgroundSize: `25px 25px`,
66+
backgroundPosition: `0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px`,
67+
boxSizing: "border-box",
7168
}}
72-
/>
69+
>
70+
<CardMedia
71+
component="img"
72+
onError={handleImageError}
73+
data-src={`${params.row.FullPath}?width=52&height=52`}
74+
image={
75+
isImageError
76+
? fileBroken
77+
: `${params.row.FullPath}?width=52&height=52`
78+
}
79+
loading="lazy"
80+
sx={{
81+
objectFit: "contain",
82+
overflow: "hidden",
83+
height: "100%",
84+
verticalAlign: "bottom",
85+
}}
86+
/>
87+
</Box>
7388
<Box sx={{ display: "flex", alignItems: "center", ml: 3 }}>
7489
<Typography variant="body2">
7590
{params.row.filename || params.row.FileName.slice(1)}
@@ -162,10 +177,16 @@ export const InsightsTable: FC<Props> = ({ files, loading }) => {
162177
];
163178

164179
return (
165-
<Box sx={{ height: "calc(100vh - 242px)" }}>
180+
<Box component="main" sx={{ height: "100%", width: "100%" }}>
166181
{files && (
167182
<DataGridPro
168-
sx={{ border: "none" }}
183+
sx={{
184+
backgroundColor: "common.white",
185+
".MuiDataGrid-row": {
186+
cursor: "pointer",
187+
},
188+
border: "none",
189+
}}
169190
columns={columns}
170191
rows={files}
171192
rowHeight={52}

src/apps/media/src/app/components/MediaList.tsx

+30-10
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,32 @@ export const MediaList: FC<Props> = ({ files }) => {
6060

6161
return (
6262
<Box sx={{ display: "flex" }}>
63-
<CardMedia
64-
component="img"
65-
onError={handleImageError}
66-
data-src={params.row.thumbnail}
67-
image={isImageError ? fileBroken : params.row.thumbnail}
68-
loading="lazy"
63+
<Box
6964
sx={{
70-
objectFit: "fill",
71-
width: "52px",
7265
height: "52px",
66+
width: "52px",
67+
overflow: "hidden",
68+
backgroundColor: "grey.100",
69+
position: "relative",
70+
backgroundSize: `25px 25px`,
71+
backgroundPosition: `0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px`,
72+
boxSizing: "border-box",
7373
}}
74-
/>
74+
>
75+
<CardMedia
76+
component="img"
77+
onError={handleImageError}
78+
data-src={params.row.thumbnail}
79+
image={isImageError ? fileBroken : params.row.thumbnail}
80+
loading="lazy"
81+
sx={{
82+
objectFit: "contain",
83+
overflow: "hidden",
84+
height: "100%",
85+
verticalAlign: "bottom",
86+
}}
87+
/>
88+
</Box>
7589
<Box sx={{ display: "flex", alignItems: "center", ml: 3 }}>
7690
<Typography variant="body2">{params.row.filename}</Typography>
7791
</Box>
@@ -159,7 +173,13 @@ export const MediaList: FC<Props> = ({ files }) => {
159173
<Box component="main" sx={{ height: "100%", width: "100%" }}>
160174
{files && (
161175
<DataGridPro
162-
sx={{ border: "none" }}
176+
sx={{
177+
backgroundColor: "common.white",
178+
".MuiDataGrid-row": {
179+
cursor: "pointer",
180+
},
181+
border: "none",
182+
}}
163183
columns={columns}
164184
rows={files}
165185
rowHeight={52}

src/apps/media/src/app/views/InsightsMedia.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ export const InsightsMedia: FC = () => {
143143
{}),
144144
})),
145145
"id"
146+
).filter((file: any) =>
147+
files?.find((f) => f.url === file.FullPath?.split("?")?.[0])
146148
)}
147149
loading={isFilesFetching || usageFetching || isBinsFetching}
148150
/>
149151
</Box>
150152
);
151153
};
152-
153-
//url.split("?")[0]

0 commit comments

Comments
 (0)