Skip to content

Commit

Permalink
performance optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
begmuhommet committed Oct 16, 2024
1 parent 51e6f8c commit f95805a
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 22 deletions.
Binary file added src/assets/hero-mobile.webp
Binary file not shown.
11 changes: 8 additions & 3 deletions src/components/HeroButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ const HeroButtons: FC<TProps> = (props) => {
className={cn('flex items-center justify-center gap-4 w-full', className)}
>
<a
href="https://portal.trial.low-ops.com/"
href="https://hub.cinaq.com/low-ops-trial"
target="_blank"
rel="noopener noreferrer"
>
<Button variant="secondary" size="lg" onClick={onClick}>
<Button
variant="secondary"
size="lg"
onClick={onClick}
aria-label="Show demo"
>
<LinkExternal02 width={18} height={18} className="mr-2" />
Demo
</Button>
</a>
<a href="#contact-us">
<Button size="lg" onClick={onClick}>
<Button size="lg" onClick={onClick} aria-label="Contact us">
Contact us
</Button>
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SectionTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const SectionTitle: FC<TProps> = (props) => {

return (
<div className="prose md:prose-md">
{!!title && <h2 className="text-center text-blue-500">{title}</h2>}
{!!title && <h2 className="text-center text-blue-700">{title}</h2>}
<p className="text-center text-3xl md:text-4xl font-semibold leading-[32px] md:leading-[44px]">
{description}
</p>
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/AppLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Image from 'next/image';
const AppLogo = () => {
return (
<a href="#hero">
<Image src={logo} alt="lowops-logo" width={110} height={32} />
<Image src={logo} alt="lowops-logo" width={110} />
</a>
);
};
Expand Down
8 changes: 7 additions & 1 deletion src/components/header/MobileHeaderNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const MobileHeaderNav = () => {
variant="ghost"
size="icon"
className="flex md:hidden"
aria-label="Open menu"
>
<Menu01 width={28} height={28} />
</Button>
Expand All @@ -54,7 +55,12 @@ const MobileHeaderNav = () => {
<div>
<div className="flex items-center justify-between p-4">
<AppLogo />
<Button variant="ghost" size="icon" onClick={handleToggle}>
<Button
variant="ghost"
size="icon"
onClick={handleToggle}
aria-label="Close menu"
>
<XClose />
</Button>
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/components/ui/carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ const CarouselDots = React.forwardRef<
>
{items.map((_, i) => (
<Button
title="Carousel dots"
aria-label="Carousel dots"
aria-label="Testimonials switch"
key={i}
className={cn(
'w-[10px] h-[10px] rounded-full block shadow-none p-0',
Expand Down
17 changes: 17 additions & 0 deletions src/hooks/useMediaQuery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useEffect, useState } from 'react';

export function useMediaQuery(query: string): boolean {
const [matches, setMatches] = useState(false);

useEffect(() => {
const media = window.matchMedia(query);
if (media.matches !== matches) {
setMatches(media.matches);
}
const listener = () => setMatches(media.matches);
media.addEventListener('change', listener);
return () => media.removeEventListener('change', listener);
}, [matches, query]);

return matches;
}
2 changes: 1 addition & 1 deletion src/sections/faq/FaqSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const FaqSection: React.FC = () => {
Can’t find the answer you’re looking for?
</p>
<a href="#contact-us">
<Button className="w-fit" size="default">
<Button className="w-fit" size="default" aria-label="Contact us">
Contact us
</Button>
</a>
Expand Down
4 changes: 3 additions & 1 deletion src/sections/form/FormSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ const FormSection: React.FC = () => {
/>
</div>

<Button type="submit">Send message</Button>
<Button type="submit" aria-label="Send message">
Send message
</Button>
</form>
</div>
</section>
Expand Down
34 changes: 34 additions & 0 deletions src/sections/hero/HeroImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use client';

import heroMobileImage from '@/assets/hero-mobile.webp';
import heroImage from '@/assets/hero.webp';
import { useMediaQuery } from '@/hooks/useMediaQuery';
import Image from 'next/image';

const HeroImage = () => {
const isDesktop = useMediaQuery('(min-width: 768px)');

return isDesktop ? (
<Image
src={heroImage}
alt="lowops-portal-screen"
quality={80}
width={1400}
height={788}
priority
className="w-full mx-auto hidden md:block"
/>
) : (
<Image
src={heroMobileImage}
alt="lowops-portal-screen"
quality={80}
width={800}
height={450}
priority
className="w-full mx-auto block md:hidden"
/>
);
};

export default HeroImage;
13 changes: 3 additions & 10 deletions src/sections/hero/HeroSection.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import heroImage from '@/assets/hero.webp';
import HeroButtons from '@/components/HeroButtons';
import { cn } from '@/lib/utils';
import Image from 'next/image';
import { FC } from 'react';
import HeroImage from './HeroImage';

const HeroSection: FC = () => {
return (
Expand All @@ -27,14 +26,8 @@ const HeroSection: FC = () => {

<HeroButtons className="mb-10 md:mb-20" />
</div>
<Image
src={heroImage}
alt="lowops-portal-screen"
quality={100}
objectFit="cover"
priority
className="max-w-[1400px] w-full mx-auto"
/>

<HeroImage />
</section>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/sections/testimonials/TestimonialsCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const TestimonialsCarousel = () => {
<User01 width={28} height={28} className="text-gray-500" />
</AvatarFallback>
</Avatar>
<h4>{testimonial.author}</h4>
<h5 className="text-sm font-light">{testimonial.company}</h5>
<p className="font-semibold m-0 text-base">{testimonial.author}</p>
<p className="text-sm font-light m-0">{testimonial.company}</p>
</div>
</div>
</CarouselItem>
Expand Down

0 comments on commit f95805a

Please sign in to comment.