Skip to content

Commit

Permalink
perf: use webp images in website
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyend-nam committed Dec 28, 2023
1 parent 33714b8 commit aefb4f4
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 11 deletions.
3 changes: 1 addition & 2 deletions components/Hero/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export const Hero = ({
<div
style={{
backgroundImage:
heroImgUrl ??
'image-set(url("/img/hero-banner.png") 2x, url("/img/hero-banner.webp") 1x)',
heroImgUrl ?? 'image-set(url("/img/hero-banner.webp") 1x)',
}}
className="h-full w-full bg-cover bg-center absolute top-0 -right-24"
/>
Expand Down
2 changes: 1 addition & 1 deletion components/ImageWithFallback/ImageWithFallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ImageWithFallback = (props: ImageWithFallbackProps) => {
<>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
srcSet={`${fallbackImgUrl} 767px, ${src} 768px"`}
srcSet={`${fallbackImgUrl ?? src} 767px, ${src} 768px"`}
sizes="(max-width: 767px) 767px, 768px"
src={src}
alt={alt}
Expand Down
2 changes: 1 addition & 1 deletion components/Logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const Logo = (props: Partial<ImageWithFallbackProps>) => {

return (
<ImageWithFallback
src={src ?? '/img/logo-with-text.png'}
src={src ?? '/img/logo-with-text.webp'}
fallbackImgUrl={fallbackImgUrl ?? '/img/logo-with-text.webp'}
width={130}
height={40}
Expand Down
6 changes: 2 additions & 4 deletions components/pages/home/DesignGuideView/DesignGuide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export const DesignGuide = ({ className }: { className?: string }) => {

<div className="flex flex-col sm:flex-row gap-4 md:gap-8 md:pb-8">
<DesignGuideCardItem
imgUrl="/img/select.png"
fallbackImgUrl="/img/select.webp"
imgUrl="/img/select.webp"
alt="Documentation"
title={
<div className="flex gap-2 items-center">
Expand All @@ -42,8 +41,7 @@ export const DesignGuide = ({ className }: { className?: string }) => {
/>

<DesignGuideCardItem
imgUrl="/img/paperplane.png"
fallbackImgUrl="/img/paperplane.webp"
imgUrl="/img/paperplane.webp"
alt="Support"
title={
<div className="flex gap-2 items-center">
Expand Down
3 changes: 1 addition & 2 deletions components/pages/home/RichComponentsView/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export const ModalShowcase = () => {
<ModalContent className="space-y-2 text-center !p-4">
<div className="mb-8">
<ImageWithFallback
src="/img/macbook.png"
fallbackImgUrl="/img/macbook.webp"
src="/img/macbook.webp"
alt="Macbook"
width={350}
height={200}
Expand Down
1 change: 0 additions & 1 deletion components/pages/home/RoadmapView/Roadmap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export const Roadmap = ({ className }: { className?: string }) => {
{item?.isMajorChange ? (
<ImageWithFallback
src="/img/logo.png"
fallbackImgUrl="/img/logo.png"
className="absolute bottom-[unset] sm:-bottom-[18px] -left-[19px] sm:-left-[19px] box-content border-2 bg-[#E88B88] border-[#E88B88] rounded-full"
height={32}
width={32}
Expand Down
Binary file removed public/img/hero-banner.png
Binary file not shown.
Binary file removed public/img/logo-with-text.png
Binary file not shown.
Binary file removed public/img/macbook.png
Binary file not shown.
Binary file removed public/img/paperplane.png
Binary file not shown.
Binary file removed public/img/select.png
Binary file not shown.

0 comments on commit aefb4f4

Please sign in to comment.