Skip to content

Commit

Permalink
Empty image
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejewsky committed Jan 30, 2025
1 parent 8a6527e commit 0b5edde
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
10 changes: 10 additions & 0 deletions src/collections/components/CollectionProducts/EmptyImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Box, useTheme } from "@saleor/macaw-ui-next";
import React from "react";

export const EmptyImage = () => {
const { theme } = useTheme();

const bgColor = theme === "defaultLight" ? "hsla(210, 15%, 87%, 1)" : "hsla(210, 32%, 25%, 1)";

return <Box __width="31px" __height="31px" __backgroundColor={bgColor} borderRadius={2} />;
};
33 changes: 23 additions & 10 deletions src/collections/components/CollectionProducts/ProductTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ import Drag from "@dashboard/icons/Drag";
import { productUrl } from "@dashboard/products/urls";
import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import { Box, Button, Checkbox, Skeleton, Text, TrashBinIcon } from "@saleor/macaw-ui-next";
import {
Box,
Button,
Checkbox,
Skeleton,
Text,
TrashBinIcon,
useTheme,
} from "@saleor/macaw-ui-next";
import React from "react";

import { EmptyImage } from "./EmptyImage";
import { Product } from "./types";

interface ItemProps {
Expand Down Expand Up @@ -78,15 +87,19 @@ export const ProductTableItem = ({
gap={2}
height="100%"
>
<Box borderColor="default1" borderWidth={1} borderStyle="solid">
<Box
as="img"
src={product?.thumbnail?.url}
alt={product?.name}
__width="31px"
__height="31px"
/>
</Box>
{product?.thumbnail ? (
<Box borderColor="default1" borderWidth={1} borderRadius={2} borderStyle="solid">
<Box
as="img"
src={product?.thumbnail?.url}
alt={product?.name}
__width="31px"
__height="31px"
/>
</Box>
) : (
<EmptyImage />
)}
<Text>{product?.name}</Text>
</Box>
</GridTable.Cell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ export const ProductsTable = ({
</GridTable.Row>
<SortableContext items={items} strategy={verticalListSortingStrategy}>
{renderCollection(items, product => {
const isSelected = product ? isChecked(product.id) : false;

if (!product) {
return null;
}

const isSelected = isChecked(product.id);

return (
<ProductTableItem
key={product.id}
Expand Down

0 comments on commit 0b5edde

Please sign in to comment.