In order to use the components and cookies you must have the following dependencies and configs in your project. Here's a step-by-step setup guide.
The setup is going to require a NextJS app with Typescript & Tailwind. Make sure you have a simple project setup, If you have it already, you can go to the next step.
# using npm
npx create-next-app app-name
# using yarn
yarn create next-app app-name
All the cookies, components and required utilities are using various npm dependencies. Install them as your first step to get started.
yarn add lucide-react framer-motion clsx tailwind-merge
The configurations are going to provide basic animations to your components. You can customize and add custom animations in this code.
export type ComponentAnimationType =
| 'none'
| 'from-top'
| 'from-bottom'
| 'from-left'
| 'from-right';
export type ComponentAnimationFramerConfigType = {
opacity?: number;
y?: number;
x?: number;
scale?: number;
zoom?: number;
width?: number;
height?: number;
};
export const ComponentAnimation: Record<
ComponentAnimationType,
{
initial: ComponentAnimationFramerConfigType;
animate: ComponentAnimationFramerConfigType;
}
> = {
none: {
initial: {},
animate: {},
},
'from-bottom': {
initial: {
opacity: 0,
y: 12,
},
animate: {
opacity: 1,
y: 0,
},
},
'from-top': {
initial: {
opacity: 0,
y: -12,
},
animate: {
opacity: 1,
y: 0,
},
},
'from-left': {
initial: {
opacity: 0,
x: -12,
},
animate: {
opacity: 1,
x: 0,
},
},
'from-right': {
initial: {
opacity: 0,
x: 12,
},
animate: {
opacity: 1,
x: 0,
},
},
};
Components are using cn() to combine the classNames, supporting tailwind-merge. All thanks to shadcn for writing this.
import { type ClassValue, clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}