Skip to content

Commit

Permalink
Add card background and "out of stock" support
Browse files Browse the repository at this point in the history
  • Loading branch information
SheepTester committed Aug 2, 2023
1 parent f33f1c0 commit 0e0106c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/components/store/ItemCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ interface ItemCardProps {
image: string;
title: string;
cost: number;
inStock?: boolean;
}

const ItemCard = ({ image, title, cost }: ItemCardProps) => {
const ItemCard = ({ image, title, cost, inStock = true }: ItemCardProps) => {
return (
<div className={styles.itemCard}>
<Image src={image} alt={title} width={400} height={400} />
<div className={styles.details}>
<p className={styles.title}>{title}</p>
<p>
{numberFormat.format(cost)} <span className={styles.diamond} />
<p className={styles.cost}>
{numberFormat.format(cost)}
<span className={styles.diamond} />
{!inStock && <span className={styles.outOfStock}>Out of stock</span>}
</p>
</div>
</div>
Expand Down
13 changes: 12 additions & 1 deletion src/components/store/ItemCard/style.module.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
@use 'src/styles/vars.scss' as vars;

.itemCard {
background-color: var(--theme-surface-1);
border-radius: 0.625rem;
box-shadow: 0 4px 4px var(--theme-accent-line-1-transparent);
display: flex;
flex-direction: column;
gap: 1rem;
overflow: hidden;
padding-bottom: 1rem;
width: 400px;

.details {
display: flex;
Expand All @@ -22,12 +26,19 @@
font-size: 1rem;

.diamond {
background-color: $light-primary-2;
background-color: var(--theme-primary-2);
border-radius: 2px;
display: inline-block;
height: 0.75em;
margin-left: 0.55rem;
margin-right: 0.7rem;
transform: rotate(45deg);
width: 0.75em;
}

.outOfStock {
color: #{vars.$danger-1};
}
}
}
}
1 change: 1 addition & 0 deletions src/components/store/ItemCard/style.module.scss.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export type Styles = {
details: string;
diamond: string;
itemCard: string;
outOfStock: string;
title: string;
};

Expand Down

0 comments on commit 0e0106c

Please sign in to comment.