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

docs(suspensive.org): beautify main page #1397

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
439 changes: 439 additions & 0 deletions docs/suspensive.org/public/img/homepage_background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 75 additions & 43 deletions docs/suspensive.org/src/components/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { motion } from 'motion/react'
import Image from 'next/image'
import Link from 'next/link'
import { useRouter } from 'nextra/hooks'
import { Link } from 'nextra-theme-docs'

const CodeBlockClassName = 'nextra-code'

Expand All @@ -14,63 +14,95 @@ const backtickToCodeBlock = (text: string) =>
const formatCodeBlocks = (desc: string) => backtickToCodeBlock(escapeHtml(desc))

export const HomePage = ({
title,
description,
buttonText,
items,
version,
children,
}: {
title: string
description: string
buttonText: string
items: { title: string; desc: string }[]
version: number
children?: React.ReactNode
}) => {
const router = useRouter()

return (
<div className="pb-20">
<div className="flex flex-col items-center justify-center gap-8 pt-11 text-center">
<Image
src="/img/logo_background_star.png"
alt="Suspensive with star"
width={400}
height={241}
/>
<div className="flex flex-col items-center gap-4">
<div className="relative text-5xl font-bold">
<span>{title}</span>{' '}
<span className="absolute text-sm">v{version}</span>
<>
<motion.section
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
className="bg-[url('/img/homepage_background.svg')] bg-cover bg-center bg-no-repeat pb-20"
>
<div className="flex flex-col items-center justify-center gap-8 text-center">
<div className="flex flex-col items-center">
<Image
src="/img/homepage_logo.png"
alt="Suspensive with star"
width={360}
height={360}
className="-mb-4 h-52 w-52 md:h-auto md:w-auto"
/>
<div className="flex flex-col items-center gap-4">
<div className="break-keep px-4 text-4xl font-bold leading-tight md:text-6xl">
<span>{description}</span>
</div>
<motion.p
initial={{ opacity: 0 }}
animate={{
opacity: 0.6,
transition: { delay: 0.1, duration: 1 },
}}
className="rounded-full text-xl text-white"
>
npm i @suspensive/react
</motion.p>
</div>
</div>
<p className="text-3xl">{description}</p>
<Link href={`/${router.locale}/docs/react/motivation`}>
<motion.button
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
initial={{ opacity: 0 }}
animate={{ opacity: 1, transition: { delay: 1, duration: 1 } }}
type="button"
className="animate-pulse rounded-xl bg-white px-10 py-3 text-xl font-bold text-[#111111]"
>
{buttonText}
</motion.button>
</Link>
</div>
<Link href={`/${router.locale}/docs/react/motivation`}>
<motion.button
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
type="button"
className="animate-pulse rounded-xl bg-gray-800 px-10 py-3 text-xl font-bold"
>
{buttonText}
</motion.button>
</Link>
</div>

<div className="h-14"></div>
<div className="flex flex-col items-start justify-between gap-8 md:flex-row">
{items.map(({ title, desc }) => (
<div
className="flex flex-1 flex-col items-center justify-center gap-3 text-center"
key={title}
>
<div className="text-xl font-bold">{title}</div>
<p
className="text-lg"
dangerouslySetInnerHTML={{ __html: formatCodeBlocks(desc) }}
></p>
</div>
))}
</div>
</div>
<div className="h-14" />
<div className="container mx-auto flex flex-col items-start justify-between gap-8 px-4 md:flex-row">
{items.map(({ title, desc }, index) => (
<motion.div
initial={{ opacity: 0 }}
animate={{
opacity: 1,
transition: { delay: 0.2 + index * 0.05, duration: 1 },
}}
className="flex flex-1 flex-col items-center justify-center gap-3 text-center"
key={title}
>
<div className="text-xl font-bold">{title}</div>
<p
className="text-lg opacity-75"
dangerouslySetInnerHTML={{ __html: formatCodeBlocks(desc) }}
/>
</motion.div>
))}
</div>
</motion.section>
<motion.section
initial={{ y: 30, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
transition={{ delay: 0.5, duration: 0.2 }}
className="container mx-auto px-6"
>
{children}
</motion.section>
</>
)
}
6 changes: 3 additions & 3 deletions docs/suspensive.org/src/components/Scrollycoding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ export function Scrollycoding(props: unknown) {
className="mb-56 cursor-pointer px-5 py-2 opacity-30 blur-lg transition data-[selected=true]:opacity-100 data-[selected=true]:blur-none"
>
<h2 className="2xl mb-4 mt-4 text-lg font-bold">{step.title}</h2>
<div className="opacity-90">{step.children}</div>
<div className="opacity-75">{step.children}</div>
</Selectable>
))}
</div>

<div
className="rounded-xl border-2 border-[#ffffff10] bg-[#191919]"
className="rounded-xl border-2 border-[#ffffff08] bg-[#ffffff04]"
style={{ flex: 2 }}
>
<div className="scrollbar-none sticky top-16 overflow-auto">
Expand All @@ -116,7 +116,7 @@ export function Scrollycoding(props: unknown) {
className="mb-20 cursor-pointer py-2 opacity-30 blur-lg transition data-[selected=true]:opacity-100 data-[selected=true]:blur-none"
>
<h2 className="mb-2 text-lg font-bold">{step.title}</h2>
<div className="opacity-90">{step.children}</div>
<div className="opacity-75">{step.children}</div>
</Selectable>
))}
</div>
Expand Down
10 changes: 10 additions & 0 deletions docs/suspensive.org/src/components/SectionText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { ReactNode } from 'react'

export const SectionTitle = ({ children }: { children: ReactNode }) => (
<h3 className="text-1xl text-center font-bold opacity-60 md:text-2xl">
{children}
</h3>
)
export const SectionDescription = ({ children }: { children: ReactNode }) => (
<h4 className="text-center text-4xl font-bold">{children}</h4>
)
1 change: 1 addition & 0 deletions docs/suspensive.org/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export { HomePage } from './HomePage'
export { Sandpack } from './Sandpack'
export { BubbleChart } from './BubbleChart'
export { Scrollycoding } from './Scrollycoding'
export { SectionTitle, SectionDescription } from './SectionText'
2 changes: 1 addition & 1 deletion docs/suspensive.org/src/pages/en/_meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default {
type: 'page',
display: 'hidden',
theme: {
layout: 'full',
layout: 'raw',
},
},
docs: {
Expand Down
23 changes: 15 additions & 8 deletions docs/suspensive.org/src/pages/en/index.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { HomePage, Scrollycoding } from '@/components'
import {
HomePage,
Scrollycoding,
SectionDescription,
SectionTitle,
} from '@/components'

<HomePage
title="Suspensive"
version={2}
description="All in one for React Suspense"
buttonText="Get Started"
items={[
Expand All @@ -19,7 +22,7 @@ import { HomePage, Scrollycoding } from '@/components'
desc: 'Suspensive provide clientOnly that make developer can adopt React Suspense gradually in Server-side rendering environment.',
},
]}
/>
>

<Scrollycoding>
# !!steps If you write code without Suspense with TanStack Query, a representative library, you would write it like this.
Expand Down Expand Up @@ -181,9 +184,10 @@ const Page = () => (

</Scrollycoding>

## This is why we make Suspensive.

### Suspense, ClientOnly, DefaultProps
<SectionTitle>This is why we make Suspensive</SectionTitle>
<br />
<SectionDescription>Suspense, ClientOnly, DefaultProps</SectionDescription>
<br />

<Scrollycoding>
# !!steps When using frameworks like Next.js, it can be difficult to use Suspense on the server.
Expand Down Expand Up @@ -299,7 +303,8 @@ const Page = () => (

</Scrollycoding>

### ErrorBoundaryGroup, ErrorBoundary
<SectionDescription>ErrorBoundaryGroup, ErrorBoundary</SectionDescription>
<br />

<Scrollycoding>

Expand Down Expand Up @@ -422,3 +427,5 @@ const DeepComponent = () => (
```

</Scrollycoding>

</HomePage>
2 changes: 1 addition & 1 deletion docs/suspensive.org/src/pages/ko/_meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default {
type: 'page',
display: 'hidden',
theme: {
layout: 'full',
layout: 'raw',
},
},
docs: {
Expand Down
19 changes: 12 additions & 7 deletions docs/suspensive.org/src/pages/ko/index.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { HomePage, Scrollycoding } from '@/components'
import {
HomePage,
Scrollycoding,
SectionDescription,
SectionTitle,
} from '@/components'

<HomePage
title="Suspensive"
version={2}
description="React Suspense를 위한 모든 것"
buttonText="시작하기"
items={[
Expand Down Expand Up @@ -181,9 +184,10 @@ const Page = () => (

</Scrollycoding>

## 이것이 우리가 Suspensive를 만드는 이유입니다.

### Suspense, ClientOnly, DefaultProps
<SectionTitle>이것이 우리가 Suspensive를 만드는 이유입니다</SectionTitle>
<br />
<SectionDescription>Suspense, ClientOnly, DefaultProps</SectionDescription>
<br />

<Scrollycoding>

Expand Down Expand Up @@ -300,7 +304,8 @@ const Page = () => (

</Scrollycoding>

### ErrorBoundaryGroup, ErrorBoundary
<SectionDescription>ErrorBoundaryGroup, ErrorBoundary</SectionDescription>
<br />

<Scrollycoding>

Expand Down
4 changes: 4 additions & 0 deletions docs/suspensive.org/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
.scrollbar-none::-webkit-scrollbar {
display: none; /* Chrome, Safari, Opera*/
}

body {
background-color: #0c0c0c;
}
2 changes: 1 addition & 1 deletion knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"docs/suspensive.org": {
"ignore": ["theme.config.tsx"],
"ignoreDependencies": ["sharp"],
"ignoreDependencies": ["sharp", "nextra-theme-docs"],
"entry": ["src/**/*.{ts,tsx,mdx}"]
},
"packages/react-query-4": {
Expand Down
Loading