Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add moving companies logo, add skeleton loading and removed the theme toggle #273

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/companies/facebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/companies/insta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/companies/microsoft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/companies/tinder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/companies/twitch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default async function RootLayout({
<html lang="en" suppressHydrationWarning={true}>
<body
className={cn(
'font-sans antialiased bg-gradient-light dark:bg-gradient min-h-screen relative flex flex-col',
'font-sans antialiased dark bg-gradient-light dark:bg-gradient min-h-screen relative flex flex-col',
fontSans.variable
)}
>
Expand Down
34 changes: 34 additions & 0 deletions src/components/Companies.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use client';

import { InfiniteMovingCards } from './ui/infinite-moving-cards';

export function Companies() {
return (
<div className="h-[20rem] rounded-md flex flex-col antialiased dark:bg-grid-white/[0.05] items-center justify-center relative overflow-hidden">
<InfiniteMovingCards
items={testimonials}
direction="right"
speed="slow"
/>
</div>
);
}

const testimonials = [
{
id: '1',
image: '/companies/microsoft.png',
},
{
id: '2',
image: '/companies/facebook.png',
},
{
id: '3',
image: '/companies/twitch.png',
},
{
id: '4',
image: '/companies/tinder.png',
},
];
9 changes: 2 additions & 7 deletions src/components/hero-section.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GITHUB_REPO } from '@/lib/constant/app.constant';
import Link from 'next/link';
import Icon from './ui/icon';
import Image from 'next/image';
import { Companies } from './Companies';

const HeroSection = () => {
return (
Expand Down Expand Up @@ -36,12 +36,7 @@ const HeroSection = () => {
</div>
</div>
<div className="flex items-center justify-center my-10 invert dark:invert-0">
<Image
src={'/companies.png'}
alt="companies"
width={900}
height={100}
/>
<Companies />
</div>
</section>
</>
Expand Down
36 changes: 16 additions & 20 deletions src/components/loader.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
interface LoaderParams {
size?: number;
}
import { Skeleton } from './ui/skeleton';

const Loader = ({ size = 8 }: LoaderParams) => {
const Loader = () => {
return (
<>
<svg
aria-hidden="true"
className={`w-${size} h-${size} text-gray-300 animate-spin dark:text-gray-600 fill-white`}
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
<div className="flex w-full flex-col gap-4 my-3">
{Array.from({ length: 5 }).map((_, i) => (
<div
key={i}
className="flex w-full flex-col bg-neutral-900/30 md:flex-row px-6 border-2 rounded-xl py-4 md:items-center gap-3 space-x-4"
>
<Skeleton className=" h-24 w-24 rounded-xl" />
<div className="space-y-2">
<Skeleton className="h-6 lg:w-[250px]" />
<Skeleton className="h-4 w-[200px] lg:w-full" />
</div>
</div>
))}
</div>
</>
);
};
Expand Down
102 changes: 102 additions & 0 deletions src/components/ui/infinite-moving-cards.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
'use client';

import { cn } from '@/lib/utils';
import Image from 'next/image';
import React, { useEffect, useState } from 'react';

export const InfiniteMovingCards = ({
items,
direction = 'left',
speed = 'fast',
pauseOnHover = true,
className,
}: {
items: {
id: string;
image: string;
}[];
direction?: 'left' | 'right';
speed?: 'fast' | 'normal' | 'slow';
pauseOnHover?: boolean;
className?: string;
}) => {
const containerRef = React.useRef<HTMLDivElement>(null);
const scrollerRef = React.useRef<HTMLUListElement>(null);

useEffect(() => {
addAnimation();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const [start, setStart] = useState(false);
function addAnimation() {
if (containerRef.current && scrollerRef.current) {
const scrollerContent = Array.from(scrollerRef.current.children);

scrollerContent.forEach((item) => {
const duplicatedItem = item.cloneNode(true);
if (scrollerRef.current) {
scrollerRef.current.appendChild(duplicatedItem);
}
});

getDirection();
getSpeed();
setStart(true);
}
}
const getDirection = () => {
if (containerRef.current) {
if (direction === 'left') {
containerRef.current.style.setProperty(
'--animation-direction',
'forwards'
);
} else {
containerRef.current.style.setProperty(
'--animation-direction',
'reverse'
);
}
}
};
const getSpeed = () => {
if (containerRef.current) {
if (speed === 'fast') {
containerRef.current.style.setProperty('--animation-duration', '20s');
} else if (speed === 'normal') {
containerRef.current.style.setProperty('--animation-duration', '40s');
} else {
containerRef.current.style.setProperty('--animation-duration', '80s');
}
}
};
return (
<div
ref={containerRef}
className={cn(
'scroller relative z-20 max-w-7xl overflow-hidden [mask-image:linear-gradient(to_right,transparent,white_20%,white_80%,transparent)]',
className
)}
>
<ul
ref={scrollerRef}
className={cn(
' flex min-w-full shrink-0 gap-10 py-4 w-max flex-nowrap',
start && 'animate-scroll ',
pauseOnHover && 'hover:[animation-play-state:paused]'
)}
>
{items.map((item) => (
<li key={item.id}>
<Image
src={item.image}
height={100}
width={250}
alt="companyImages"
/>
</li>
))}
</ul>
</div>
);
};
15 changes: 15 additions & 0 deletions src/components/ui/skeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { cn } from '@/lib/utils';

function Skeleton({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) {
return (
<div
className={cn('animate-pulse rounded-md bg-muted', className)}
{...props}
/>
);
}

export { Skeleton };
49 changes: 0 additions & 49 deletions src/components/ui/theme-toggle.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/layouts/header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client';
import { MobileNav } from '@/layouts/mobile-nav';
import { ModeToggle } from '@/components/ui/theme-toggle';
import APP_PATHS from '@/config/path.config';
import { navbar } from '@/lib/constant/app.constant';
import { useSession } from 'next-auth/react';
Expand Down Expand Up @@ -35,7 +34,6 @@ const Header = () => {
<Link href="/" className="p-2.5 mr-4">
<CompanyLogo />
</Link>

<div className="grow flex justify-end sm:justify-between items-center gap-3">
<nav className="py-1 rounded-full max-sm:hidden">
<ul className="flex items-center gap-4 text-sm lg:gap-6">
Expand All @@ -59,7 +57,6 @@ const Header = () => {
{session.status !== 'loading' && session.data?.user && (
<ProfileMenu />
)}
<ModeToggle />
</div>
<div className="sm:hidden flex justify-center">
<MobileNav />
Expand Down
22 changes: 22 additions & 0 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { Config } from 'tailwindcss';
const { fontFamily } = require('tailwindcss/defaultTheme');
const {
default: flattenColorPalette,
} = require('tailwindcss/lib/util/flattenColorPalette');

const config = {
darkMode: ['class'],
Expand Down Expand Up @@ -78,14 +81,33 @@ const config = {
from: { height: 'var(--radix-accordion-content-height)' },
to: { height: '0' },
},
scroll: {
to: {
transform: 'translate(calc(-50% - 0.5rem))',
},
},
},
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out',
scroll:
'scroll var(--animation-duration, 40s) var(--animation-direction, forwards) linear infinite',
},
},
plugins: [addVariablesForColors],
},
plugins: [require('tailwindcss-animate')],
} satisfies Config;

function addVariablesForColors({ addBase, theme }: any) {
let allColors = flattenColorPalette(theme('colors'));
let newVars = Object.fromEntries(
Object.entries(allColors).map(([key, val]) => [`--${key}`, val])
);

addBase({
':root': newVars,
});
}

export default config;
Loading