Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
chore: wip update style landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Jun 4, 2024
1 parent f71cc83 commit 303328f
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 43 deletions.
155 changes: 155 additions & 0 deletions src/components/3dCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import { twMerge } from "tailwind-merge";
import React, {
createContext,
useState,
useContext,
useRef,
useEffect,
} from "react";

const MouseEnterContext = createContext<
[boolean, React.Dispatch<React.SetStateAction<boolean>>] | undefined
>(undefined);

export const CardContainer = ({
children,
className,
containerClassName,
}: {
children?: React.ReactNode;
className?: string;
containerClassName?: string;
}) => {
const containerRef = useRef<HTMLDivElement>(null);
const [isMouseEntered, setIsMouseEntered] = useState(false);

const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
if (!containerRef.current) return;
const { left, top, width, height } =
containerRef.current.getBoundingClientRect();
const x = (e.clientX - left - width / 2) / 25;
const y = (e.clientY - top - height / 2) / 25;
containerRef.current.style.transform = `rotateY(${x}deg) rotateX(${y}deg)`;
};

const handleMouseEnter = (e: React.MouseEvent<HTMLDivElement>) => {
setIsMouseEntered(true);
if (!containerRef.current) return;
};

const handleMouseLeave = (e: React.MouseEvent<HTMLDivElement>) => {
if (!containerRef.current) return;
setIsMouseEntered(false);
containerRef.current.style.transform = `rotateY(0deg) rotateX(0deg)`;
};
return (
<MouseEnterContext.Provider value={[isMouseEntered, setIsMouseEntered]}>
<div
className={twMerge(
"flex items-center justify-center",
containerClassName
)}
style={{
perspective: "1000px",
}}
>
<div
ref={containerRef}
onMouseEnter={handleMouseEnter}
onMouseMove={handleMouseMove}
onMouseLeave={handleMouseLeave}
className={twMerge(
"flex items-center justify-center relative transition-all duration-200 ease-linear",
className
)}
style={{
transformStyle: "preserve-3d",
}}
>
{children}
</div>
</div>
</MouseEnterContext.Provider>
);
};

export const CardBody = ({
children,
className,
}: {
children: React.ReactNode;
className?: string;
}) => {
return (
<div
className={twMerge(
"[transform-style:preserve-3d] [&>*]:[transform-style:preserve-3d]",
className
)}
>
{children}
</div>
);
};

export const CardItem = ({
as: Tag = "div",
children,
className,
translateX = 0,
translateY = 0,
translateZ = 0,
rotateX = 0,
rotateY = 0,
rotateZ = 0,
...rest
}: {
as?: React.ElementType;
children: React.ReactNode;
className?: string;
translateX?: number | string;
translateY?: number | string;
translateZ?: number | string;
rotateX?: number | string;
rotateY?: number | string;
rotateZ?: number | string;
[key: string]: any;
}) => {
const ref = useRef<HTMLDivElement>(null);
const [isMouseEntered] = useMouseEnter();

useEffect(() => {
handleAnimations();
}, [isMouseEntered]);

const handleAnimations = () => {
if (!ref.current) return;
if (isMouseEntered) {
ref.current.style.transform = `translateX(${translateX}px) translateY(${translateY}px) translateZ(${translateZ}px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) rotateZ(${rotateZ}deg)`;
} else {
ref.current.style.transform = `translateX(0px) translateY(0px) translateZ(0px) rotateX(0deg) rotateY(0deg) rotateZ(0deg)`;
}
};

return (
<Tag
ref={ref}
className={twMerge(
"w-fit transition duration-200 ease-linear",
className
)}
{...rest}
>
{children}
</Tag>
);
};

// Create a hook to use the context
export const useMouseEnter = () => {
const context = useContext(MouseEnterContext);
if (context === undefined) {
throw new Error("useMouseEnter must be used within a MouseEnterProvider");
}
return context;
};
2 changes: 0 additions & 2 deletions src/components/typeWriterWffect.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use client";

import { twMerge } from "tailwind-merge";
import { motion as m, stagger, useAnimate, useInView } from "framer-motion";
import { useEffect } from "react";
Expand Down
23 changes: 0 additions & 23 deletions src/pages/index.module.css

This file was deleted.

44 changes: 26 additions & 18 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import Layout from "@theme/Layout";

import TypewriterEffect from "@site/src/components/typeWriterWffect";
import Link from "@docusaurus/Link";
import {
CardContainer,
CardBody,
CardItem,
} from "@site/src//components/3dCard";

const Home = () => {
const { siteConfig } = useDocusaurusContext();
Expand All @@ -25,37 +31,39 @@ const Home = () => {
<Layout title="Homepage">
<main>
<div className="container">
<div className="text-center mt-20">
<div className="text-center mt-40">
<h1 className="text-6xl">Run LLMs Easily</h1>
<p className="text-2xl">
OpenAI Compatible. Multi-engine. For Production
</p>

<code className="bg-transparent my-24 inline-block border-none">
<code className="bg-transparent my-10 inline-block border-none">
<TypewriterEffect words={words} />
</code>

<div className="relative w-full lg:w-1/2 mx-auto">
<div className="rounded-lg dark:border-neutral-800 border-neutral-200 border border-solid">
<CardContainer className="relative w-full lg:w-1/2 mx-auto">
<CardBody className="rounded-lg dark:border-neutral-800 border-neutral-200 border border-solid w-full">
<div className="flex p-2 gap-1.5">
<div className="rounded-full w-3 h-3 bg-red-500" />
<div className="rounded-full w-3 h-3 bg-yellow-500" />
<div className="rounded-full w-3 h-3 bg-green-500" />
</div>
<div className="p-4 text-left">
<code className="bg-transparent border-none inline-block">
<p className="mb-0"># Download a GGUF model</p>
<p className="mb-3">cortex models pull llama3</p>
<p className="mb-0"># Run the model to start chatting</p>
<p className="mb-3">cortex models run llama3</p>
<p className="mb-0">
# Run Cortex in OpenAI-compatible server mode
</p>
<p className="mb-0">cortex serve</p>
</code>
</div>
</div>
</div>
<CardItem>
<div className="p-4 text-left">
<code className="bg-transparent border-none inline-block">
<p className="mb-0"># Download a GGUF model</p>
<p className="mb-3">cortex models pull llama3</p>
<p className="mb-0"># Run the model to start chatting</p>
<p className="mb-3">cortex models run llama3</p>
<p className="mb-0">
# Run Cortex in OpenAI-compatible server mode
</p>
<p className="mb-0">cortex serve</p>
</code>
</div>
</CardItem>
</CardBody>
</CardContainer>
</div>
</div>
</main>
Expand Down

0 comments on commit 303328f

Please sign in to comment.