Skip to content

Commit 748338a

Browse files
committed
fix(core): use tailwind aspect-ratio plugin
1 parent 1df2fa0 commit 748338a

15 files changed

Lines changed: 37 additions & 46 deletions

File tree

.changeset/icy-cars-camp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@bigcommerce/catalyst-core": patch
3+
---
4+
5+
Updates our usage of aspect-ratio to use the tailwind plugin in order to support older browsers.

core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
"eslint": "^8.57.1",
9393
"eslint-config-next": "15.2.3",
9494
"postcss": "^8.5.4",
95-
"postcss-aspect-ratio-polyfill": "^2.0.0",
9695
"postcss-preset-env": "^10.2.1",
9796
"prettier": "^3.5.3",
9897
"prettier-plugin-tailwindcss": "^0.6.12",

core/postcss.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ module.exports = {
1414
'gap-properties': true,
1515
},
1616
},
17-
'postcss-aspect-ratio-polyfill': {},
1817
},
1918
};

core/tailwind.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,16 @@ const config = {
228228
},
229229
},
230230
},
231+
corePlugins: {
232+
aspectRatio: false,
233+
},
231234
plugins: [
232235
// @ts-ignore
233236
require('tailwindcss-radix')(),
234237
require('tailwindcss-animate'),
235238
require('@tailwindcss/container-queries'),
236239
require('@tailwindcss/typography'),
240+
require('@tailwindcss/aspect-ratio'),
237241
],
238242
};
239243

core/vibes/soul/form/card-radio-group/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const CardRadioGroup = React.forwardRef<
9393
value={option.value}
9494
>
9595
{option.image && (
96-
<div className="relative aspect-square h-full">
96+
<div className="aspect-w-1 aspect-h-1 relative h-full">
9797
<Image
9898
alt={option.image.alt}
9999
className="bg-background object-fill"

core/vibes/soul/primitives/blog-post-card/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function BlogPostCard({ blogPost, className }: Props) {
3232
)}
3333
href={href}
3434
>
35-
<div className="relative mb-4 aspect-[4/3] w-full overflow-hidden rounded-2xl bg-contrast-100">
35+
<div className="relative mb-4 aspect-w-4 aspect-h-3 w-full overflow-hidden rounded-2xl bg-contrast-100">
3636
{image?.src != null && image.src !== '' ? (
3737
<Image
3838
alt={image.alt}
@@ -71,7 +71,7 @@ export function BlogPostCardSkeleton({ className }: { className?: string }) {
7171
return (
7272
<div className={clsx('flex max-w-md animate-pulse flex-col gap-2 rounded-xl', className)}>
7373
{/* Image */}
74-
<div className="aspect-[4/3] overflow-hidden rounded-xl bg-contrast-100" />
74+
<div className="aspect-w-4 aspect-h-3 overflow-hidden rounded-xl bg-contrast-100" />
7575

7676
{/* Title */}
7777
<div className="h-4 w-24 rounded-lg bg-contrast-100" />

core/vibes/soul/primitives/compare-drawer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export function CompareDrawer({
163163
className="group relative flex max-w-56 items-center overflow-hidden whitespace-nowrap rounded-xl border border-[var(--compare-drawer-link-border,hsl(var(--contrast-100)))] bg-[var(--compare-drawer-card-background,hsl(var(--background)))] font-semibold ring-[var(--compare-drawer-card-focus,hsl(var(--primary)))] transition-all duration-150 hover:bg-[var(--compare-drawer-card-background-hover,hsl(var(--contrast-100)))] focus:outline-none focus:ring-2"
164164
href={item.href}
165165
>
166-
<div className="relative aspect-square w-12 shrink-0 bg-[var(--compare-drawer-card-image-background,hsl(var(--contrast-100)))]">
166+
<div className="relative aspect-w-1 aspect-h-1 w-12 shrink-0 bg-[var(--compare-drawer-card-image-background,hsl(var(--contrast-100)))]">
167167
{item.image?.src != null ? (
168168
<Image
169169
alt={item.image.alt}

core/vibes/soul/primitives/product-card/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ export function ProductCard({
7474
className={clsx(
7575
'relative overflow-hidden rounded-xl @md:rounded-2xl',
7676
{
77-
'5:6': 'aspect-[5/6]',
78-
'3:4': 'aspect-[3/4]',
79-
'1:1': 'aspect-square',
77+
'5:6': 'aspect-w-5 aspect-h-6',
78+
'3:4': 'aspect-w-3 aspect-h-4',
79+
'1:1': 'aspect-w-1 aspect-h-1',
8080
}[aspectRatio],
8181
{
8282
light: 'bg-[var(--product-card-light-background,hsl(var(--contrast-100)))]',
@@ -193,9 +193,9 @@ export function ProductCardSkeleton({
193193
className={clsx(
194194
'rounded-xl @md:rounded-2xl',
195195
{
196-
'5:6': 'aspect-[5/6]',
197-
'3:4': 'aspect-[3/4]',
198-
'1:1': 'aspect-square',
196+
'5:6': 'aspect-w-5 aspect-h-6',
197+
'3:4': 'aspect-w-3 aspect-h-4',
198+
'1:1': 'aspect-w-1 aspect-h-1',
199199
}[aspectRatio],
200200
)}
201201
/>

core/vibes/soul/sections/blog-post-content/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function BlogPostContent({
8181
{image?.src != null && image.src !== '' && (
8282
<Image
8383
alt={image.alt}
84-
className="mb-8 aspect-video w-full rounded-2xl bg-contrast-100 object-cover @2xl:mb-12 @4xl:mb-16"
84+
className="mb-8 aspect-w-1 aspect-h-9 w-full rounded-2xl bg-contrast-100 object-cover @2xl:mb-12 @4xl:mb-16"
8585
height={780}
8686
src={image.src}
8787
width={1280}
@@ -129,7 +129,7 @@ function BlogPostTagsSkeleton() {
129129

130130
function BlogPostImageSkeleton() {
131131
return (
132-
<div className="mb-8 aspect-video w-full animate-pulse rounded-2xl bg-contrast-100 object-cover @2xl:mb-12 @4xl:mb-16">
132+
<div className="mb-8 aspect-w-1 aspect-h-9 w-full animate-pulse rounded-2xl bg-contrast-100 object-cover @2xl:mb-12 @4xl:mb-16">
133133
<div className="h-full w-full" />
134134
</div>
135135
);

core/vibes/soul/sections/cart/client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export function CartClient<LineItem extends CartLineItem>({
290290
className="flex flex-col items-start gap-x-5 gap-y-4 @container @sm:flex-row"
291291
key={lineItem.id}
292292
>
293-
<div className="relative aspect-square w-full max-w-24 overflow-hidden rounded-xl bg-[var(--cart-image-background,hsl(var(--contrast-100)))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--cart-focus,hsl(var(--primary)))] focus-visible:ring-offset-4">
293+
<div className="relative aspect-w-1 aspect-h-1 w-full max-w-24 overflow-hidden rounded-xl bg-[var(--cart-image-background,hsl(var(--contrast-100)))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--cart-focus,hsl(var(--primary)))] focus-visible:ring-offset-4">
294294
<Image
295295
alt={lineItem.image.alt}
296296
className="object-cover"

0 commit comments

Comments
 (0)