Skip to content

Commit 7ba3f32

Browse files
committed
Fixing the aspect-ratio plugin and moving the helper function into the util folder
1 parent 8becd01 commit 7ba3f32

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import React, { useState } from "react";
22
import Image from "next/image";
3-
4-
// helper function used in the Image component
5-
function cn(...classes) {
6-
return classes.filter(Boolean).join(" ");
7-
}
3+
import {booleanFilter} from '../util/booleanFilter';
84

95
export default function DislpayRC({
106
name,
@@ -23,7 +19,7 @@ export default function DislpayRC({
2319
src={!src ? "https://bit.ly/placeholder-img" : src}
2420
layout="fill"
2521
objectFit="cover"
26-
className={cn(
22+
className={booleanFilter(
2723
"duration-700 ease-in-out group-hover:opacity-75",
2824
loading
2925
? "scale-110 blur-2xl grayscale"

tailwind.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ module.exports = {
1111
},
1212
},
1313
},
14+
corePlugins: {
15+
aspectRatio: false,
16+
},
1417
plugins: [require('@tailwindcss/aspect-ratio'),],
1518
}

util/booleanFilter.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// A function to filter tailwindcss utilities depending on the value of a boolean property
2+
3+
export const booleanFilter = (...classes) => {
4+
return classes.filter(Boolean).join(" ");
5+
}

0 commit comments

Comments
 (0)