Skip to content

Commit

Permalink
feat:首页样式优化 (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
kankan-web authored Sep 20, 2024
1 parent 88da1c2 commit 8845cf3
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 41 deletions.
25 changes: 25 additions & 0 deletions public/arrow.svg
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/images/home.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/images/step-1.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/images/step-2.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/images/step-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/preact.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 44 additions & 24 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,62 @@ import Head from 'next/head';
import Link from 'next/link';
import { FaGithub } from 'react-icons/fa';
import { RiTwitterXFill, RiRocketLine } from 'react-icons/ri';
import { PiAcorn } from 'react-icons/pi';

import { Header } from '@/components/home/header';
import { HoverEffect } from '@/components/home/card-hover-effect';
import { ContainerScroll } from '@/components/home/container-scroll-animation';
import { BackgroundBeams } from '@/components/home/background-beams';
import { Footer } from '@/components/home/footer';
import { UseSteps } from '@/components/home/useSteps';
import { PROJECT_Name, PATHS } from '@/utils';

const projects = [
{
icon: <PiAcorn className="w-8 h-8" />,
title: 'title1',
description: 'desc1!',
icon: '/react.svg',
title: 'React',
description: 'JavaScript',
link: '/a',
},
{
icon: <PiAcorn className="w-8 h-8" />,
title: 'title2',
description: 'desc2',
icon: '/react.svg',
title: 'React',
description: 'TypeScript',
link: '/b',
},
{
icon: <PiAcorn className="w-8 h-8" />,
title: 'title3',
description: 'desc3',
icon: '/vue.svg',
title: 'Vue',
description: 'JavaScript',
link: '/c',
},
{
icon: <PiAcorn className="w-8 h-8" />,
title: 'title4',
description: 'desc4',
icon: '/vue.svg',
title: 'Vue',
description: 'TypeScript',
link: '/d',
},
{
icon: <PiAcorn className="w-8 h-8" />,
title: 'title5',
description: 'desc5',
icon: '/preact.svg',
title: 'Preact',
description: 'JavaScript',
link: '/e',
},
{
icon: <PiAcorn className="w-8 h-8" />,
title: 'title6',
description: 'desc6',
icon: '/preact.svg',
title: 'Preact',
description: 'TypeScript',
link: '/f',
},
{
icon: '/node.svg',
title: 'Vanilla',
description: 'JavaScript',
link: '/f',
},
{
icon: '/node.svg',
title: 'Vanilla',
description: 'TypeScript',
link: '/f',
},
];
Expand All @@ -64,11 +76,11 @@ const socialIcons = [

const router = [
{
title: 'page1',
title: 'Docs',
link: '/a',
},
{
title: 'page2',
title: 'Blog',
link: '/b',
},
];
Expand Down Expand Up @@ -112,7 +124,7 @@ const Home: NextPage = () => {
'0 2px 15px -3px var(--next-devtools-widget-shadow), 0 4px 6px -4px var(--next-devtools-widget-shadow)',
}}
>
<img alt="preview" className="object-contain" src="/images/preview.png" />
<img alt="preview" className="object-contain" src="/images/home.png" />
</div>
}
titleComponent={
Expand All @@ -131,13 +143,21 @@ const Home: NextPage = () => {
</header>

<main className="container mt-12 mx-auto bg-[#111111]">
<h3 className="text-white mx-auto text-center text-3xl">
Boot a shareable environment in <strong className="text-[#1779ff]">milliseconds</strong>
</h3>
<HoverEffect items={projects} />
</main>

<section className="container relative mx-auto mb-20 space-y-6">
<hr className="border-t border-gray-300 h-px top-[-1em] absolute w-full border-dashed" />
<div className="flex ">
<UseSteps />
</div>
</section>
<div className="container mx-auto mt-20 mb-20 space-y-6">
<div className="text-center">{getStartedButton}</div>
</div>
<Footer />
<Footer icons={socialIcons} />
</div>
</>
);
Expand Down
20 changes: 9 additions & 11 deletions src/components/home/card-hover-effect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function Card({ className, children }: { className?: string; children: Re
)}
>
<div className="relative z-50">
<div className="p-4">{children}</div>
<div className="p-4 flex space-x-4">{children}</div>
</div>
</div>
);
Expand All @@ -29,9 +29,7 @@ export function CardTitle({
className?: string;
children: React.ReactNode;
}) {
return (
<h4 className={cn('text-zinc-100 font-bold tracking-wide mt-4', className)}>{children}</h4>
);
return <h4 className={cn('text-zinc-100 font-bold tracking-wide', className)}>{children}</h4>;
}

export function CardDescription({
Expand All @@ -55,15 +53,15 @@ export function HoverEffect({
items: {
title: ReactNode;
description: ReactNode;
icon: ReactNode;
icon: string;
link: string;
}[];
className?: string;
}) {
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);

return (
<div className={cn('grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 py-10', className)}>
<div className={cn('grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 py-10', className)}>
{items.map((item, idx) => (
<Link
key={item?.link}
Expand All @@ -90,11 +88,11 @@ export function HoverEffect({
)}
</AnimatePresence>
<Card>
<CardTitle className="flex flex-col space-y-4">
{item.icon}
<span>{item.title}</span>
</CardTitle>
<CardDescription>{item.description}</CardDescription>
<img className="rounded-[6px] w-1/4" src={item.icon} />
<div className="flex flex-col justify-center w-3/4">
<CardTitle>{item.title}</CardTitle>
<CardDescription>{item.description}</CardDescription>
</div>
</Card>
</Link>
))}
Expand Down
151 changes: 145 additions & 6 deletions src/components/home/footer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,152 @@
import React from 'react';
import Link from 'next/link';
interface Icon {
icon: React.ReactNode;
link: string;
}
interface LinkProps {
name: string;
link: string;
}
interface FooterProps {
icons: Icon[];
}

export const Footer: React.FC = () => {
const Product: LinkProps[] = [
{
name: 'Features',
link: '/',
},
{
name: 'Pricing',
link: '/',
},
{
name: 'Documentation',
link: '/',
},
{
name: 'Changelog',
link: '/',
},
];
const Resources: LinkProps[] = [
{
name: 'Blog',
link: '/',
},
{
name: 'Tutorials',
link: '/',
},
{
name: 'Community',
link: '/',
},
{
name: 'FAQ',
link: '/',
},
];
const About: LinkProps[] = [
{
name: 'Company',
link: '/',
},
{
name: 'Team',
link: '/',
},
{
name: 'Careers',
link: '/',
},
{
name: 'Contact Us',
link: '/',
},
];
const Partners: LinkProps[] = [
{
name: 'GitHub',
link: '/',
},
{
name: 'Stack Overflow',
link: '/',
},
{
name: 'Careers',
link: '/',
},
{
name: 'VS Code',
link: '/',
},
];
// 渲染链接
const renderLink = (products: LinkProps[]) =>
products.map((item) => (
<li>
<Link href={item.link}>{item.name}</Link>
</li>
));

const renderIcon = (icons: Icon[]) =>
icons.map((icon) => (
<a
href={icon.link}
key={icon.link}
className="p-2 rounded-md text-white border border-white/30 hover:bg-white/10 transition-colors"
>
{icon.icon}
</a>
));

export const Footer: React.FC<FooterProps> = ({ icons }) => {
return (
<footer className="flex items-center justify-between py-16 px-10 mx-auto border-t border-t-[#e5e5e5]/10">
<Link href="https://github.com/xun082/online-edit-web" className="text-white">
online edit
</Link>
<span className="text-white opacity-50">Published under MIT License</span>
<footer className="py-16 px-10 mx-auto border-t border-t-[#e5e5e5]/10">
<div className="max-w-6xl mx-auto">
<div className="flex">
{/* 左侧: 信息相关内容 (占1/3宽度) */}
<div className="w-1/3 pr-8">
<div className="flex flex-col mb-4">
<h2 className="text-white font-bold text-3xl mb-2">Online Edit</h2>
<p className="text-white opacity-70">Made with ❤️ by Coder</p>
<div className="flex mt-3 space-x-3">{renderIcon(icons)}</div>
</div>
<p className="text-white opacity-50">
2024 © All Rights Reserved
{/* 一个简单易用的在线代码编辑器,提供高效便捷的编程体验。无论您是初学者还是专业人士,我们都能满足您的所有需求。 */}
</p>
</div>

{/* 右侧: 四个内容块 (占2/3宽度) */}
<div className="w-2/3 flex space-x-8">
<div className="flex-1">
<h4 className="text-white font-semibold mb-4">Product</h4>
<ul className="text-white opacity-70 space-y-2">{renderLink(Product)}</ul>
</div>
<div className="flex-1">
<h4 className="text-white font-semibold mb-4">Resources</h4>
<ul className="text-white opacity-70 space-y-2">{renderLink(Resources)}</ul>
</div>

<div className="flex-1">
<h4 className="text-white font-semibold mb-4">About Us</h4>
<ul className="text-white opacity-70 space-y-2">{renderLink(About)}</ul>
</div>
<div className="flex-1">
<h4 className="text-white font-semibold mb-4">Partners</h4>
<ul className="text-white opacity-70 space-y-2">{renderLink(Partners)}</ul>
</div>
</div>
</div>

{/* <div className="mt-12 text-center text-white opacity-50">
<p>© 2024 Online Editor. Published under MIT License.</p>
</div> */}
</div>
</footer>
);
};
Loading

0 comments on commit 8845cf3

Please sign in to comment.