Skip to content

Commit

Permalink
Feat(Lib): Implement Cloudinary Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikram-Maulana committed Apr 26, 2023
1 parent 7ab8a19 commit 10ea23a
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"eslint-config-next": "13.3.1",
"lucide-react": "^0.176.0",
"next": "13.3.1",
"next-cloudinary": "^4.4.0",
"postcss": "8.4.23",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
39 changes: 39 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions src/components/cloudop-image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use client";

import { CloudOpImageProps } from "@/types";
import { CldImage } from "next-cloudinary";

export default function CloudOpImage({
className,
width,
height,
src,
alt,
style,
priority,
}: CloudOpImageProps) {
return (
<CldImage
className={className}
width={width}
height={height}
src={src}
alt={alt}
format="webp"
quality={75}
style={style}
priority={priority}
/>
);
}
9 changes: 3 additions & 6 deletions src/components/design-card.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import { DesignCardProps } from "@/types";
import Image from "next/image";
import Link from "next/link";
import CloudOpImage from "./cloudop-image";

export default function DesignCard({ item }: DesignCardProps) {
return (
<div className="w-full">
<Link href={item.dribbble_url} target="_blank" rel="noopener noreferrer">
<Image
<CloudOpImage
className="mr-0 transition-all rounded-lg brightness-100 hover:brightness-75"
src={item.image_url}
width={800}
height={600}
alt={item.name}
style={{
height: "auto",
}}
priority
priotity={true}
/>
</Link>
</div>
Expand Down
2 changes: 0 additions & 2 deletions src/components/image-scroll.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use client";

import { ImageScrollProps } from "@/types";
import Link from "next/link";

Expand Down
10 changes: 10 additions & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,13 @@ export interface ButtonAccentProps {
styleNormal?: React.CSSProperties;
styleHover?: React.CSSProperties;
}

export interface CloudOpImageProps {
className?: string;
width: number;
height: number;
src: string;
alt: string;
style?: React.CSSProperties;
priority?: boolean;
}

0 comments on commit 10ea23a

Please sign in to comment.