From 3db8ad4074f72aaf1bbd27b35741f5f13316ddca Mon Sep 17 00:00:00 2001
From: Michael Novotny
Date: Mon, 24 Jul 2023 14:26:07 -0500
Subject: [PATCH] Adds dynamic product label font size (#1099)
---
app/product/[handle]/page.tsx | 3 +--
app/search/[collection]/page.tsx | 2 +-
app/search/page.tsx | 2 +-
components/carousel.tsx | 3 +--
components/grid/three-items.tsx | 4 ++--
components/grid/tile.tsx | 21 +++++++++-----------
components/label.tsx | 25 ++++++------------------
components/layout/product-grid-items.tsx | 3 +--
components/price.tsx | 3 ++-
package.json | 1 +
pnpm-lock.yaml | 11 +++++++++++
tailwind.config.js | 2 +-
12 files changed, 37 insertions(+), 43 deletions(-)
diff --git a/app/product/[handle]/page.tsx b/app/product/[handle]/page.tsx
index f23c0cc4c..828973071 100644
--- a/app/product/[handle]/page.tsx
+++ b/app/product/[handle]/page.tsx
@@ -125,8 +125,7 @@ async function RelatedProducts({ id }: { id: string }) {
>
{`No products found in this collection`}
) : (
-
+
)}
diff --git a/app/search/page.tsx b/app/search/page.tsx
index 354a2022f..5f4b60c01 100644
--- a/app/search/page.tsx
+++ b/app/search/page.tsx
@@ -32,7 +32,7 @@ export default async function SearchPage({
) : null}
{products.length > 0 ? (
-
+
) : null}
diff --git a/components/carousel.tsx b/components/carousel.tsx
index 408e24e4f..d67ba5deb 100644
--- a/components/carousel.tsx
+++ b/components/carousel.tsx
@@ -19,8 +19,7 @@ export async function Carousel() {
>
) {
return (
@@ -24,7 +22,7 @@ export function GridTileImage({
className={clsx(
'flex h-full w-full items-center justify-center overflow-hidden rounded-lg border bg-white hover:border-blue-600 dark:bg-black',
{
- relative: labels,
+ relative: label,
'border-2 border-blue-600': active,
'border-neutral-200 dark:border-neutral-800': !active
}
@@ -39,13 +37,12 @@ export function GridTileImage({
{...props}
/>
) : null}
- {labels ? (
+ {label ? (
) : null}
diff --git a/components/label.tsx b/components/label.tsx
index 8aa7a6fca..791609521 100644
--- a/components/label.tsx
+++ b/components/label.tsx
@@ -5,38 +5,25 @@ const Label = ({
title,
amount,
currencyCode,
- position,
- size
+ position = 'bottom'
}: {
title: string;
amount: string;
currencyCode: string;
position?: 'bottom' | 'center';
- size?: 'large' | 'small';
}) => {
return (
-
-
+
+
{title}
diff --git a/components/layout/product-grid-items.tsx b/components/layout/product-grid-items.tsx
index 364d4e5df..d9060adbb 100644
--- a/components/layout/product-grid-items.tsx
+++ b/components/layout/product-grid-items.tsx
@@ -11,8 +11,7 @@ export default function ProductGridItems({ products }: { products: Product[] })
{` ${currencyCode}`}
);
diff --git a/package.json b/package.json
index 45dc860b7..492f6a0af 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
"react-dom": "18.2.0"
},
"devDependencies": {
+ "@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/typography": "^0.5.9",
"@types/node": "20.4.2",
"@types/react": "18.2.15",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 85b7f34f4..b64cb5dbe 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -21,6 +21,9 @@ dependencies:
version: 18.2.0(react@18.2.0)
devDependencies:
+ '@tailwindcss/container-queries':
+ specifier: ^0.1.1
+ version: 0.1.1(tailwindcss@3.3.3)
'@tailwindcss/typography':
specifier: ^0.5.9
version: 0.5.9(tailwindcss@3.3.3)
@@ -355,6 +358,14 @@ packages:
tslib: 2.6.0
dev: false
+ /@tailwindcss/container-queries@0.1.1(tailwindcss@3.3.3):
+ resolution: {integrity: sha512-p18dswChx6WnTSaJCSGx6lTmrGzNNvm2FtXmiO6AuA1V4U5REyoqwmT6kgAsIMdjo07QdAfYXHJ4hnMtfHzWgA==}
+ peerDependencies:
+ tailwindcss: '>=3.2.0'
+ dependencies:
+ tailwindcss: 3.3.3
+ dev: true
+
/@tailwindcss/typography@0.5.9(tailwindcss@3.3.3):
resolution: {integrity: sha512-t8Sg3DyynFysV9f4JDOVISGsjazNb48AeIYQwcL+Bsq5uf4RYL75C1giZ43KISjeDGBaTN3Kxh7Xj/vRSMJUUg==}
peerDependencies:
diff --git a/tailwind.config.js b/tailwind.config.js
index 9d2e7a638..0f10cf955 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -1,5 +1,4 @@
const plugin = require('tailwindcss/plugin');
-const colors = require('tailwindcss/colors');
/** @type {import('tailwindcss').Config} */
module.exports = {
@@ -35,6 +34,7 @@ module.exports = {
hoverOnlyWhenSupported: true
},
plugins: [
+ require('@tailwindcss/container-queries'),
require('@tailwindcss/typography'),
plugin(({ matchUtilities, theme }) => {
matchUtilities(