Skip to content

Commit c9021e3

Browse files
authored
docs: update docs layout & template (codse#103)
1 parent 61c5686 commit c9021e3

File tree

112 files changed

+519
-1046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+519
-1046
lines changed

animata/list/menu-animation.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
import { ArrowRight } from "lucide-react";
2+
23
interface MenuAnimationProps {
34
menuItems: string[];
45
}
6+
57
export default function MenuAnimation({ menuItems }: MenuAnimationProps) {
68
return (
7-
<div className="flex flex-col overflow-hidden px-10">
9+
<div className="flex min-w-fit flex-col gap-2 overflow-hidden px-10">
810
{menuItems.map((item, index) => (
9-
<div key={index} className="group flex items-center">
10-
<div className="relative">
11-
<ArrowRight
12-
className="absolute transform text-black opacity-0 transition-transform duration-300 ease-out hover:z-20 group-hover:translate-x-0 group-hover:text-blue-500 group-hover:opacity-100"
13-
size={20}
14-
/>
15-
<h1 className="z-10 cursor-pointer font-mono font-semibold text-black transition-transform duration-300 ease-out group-hover:translate-x-[30px] group-hover:text-blue-500 dark:text-white">
16-
{item}
17-
</h1>
18-
</div>
11+
<div key={index} className="group flex items-center gap-2">
12+
<ArrowRight className="size-5 -translate-x-full text-black opacity-0 transition-all duration-300 ease-out hover:z-20 group-hover:translate-x-0 group-hover:text-blue-500 group-hover:opacity-100 md:size-10" />
13+
14+
<h1 className="z-10 -translate-x-6 cursor-pointer font-mono font-semibold text-black transition-transform duration-300 ease-out group-hover:translate-x-0 group-hover:text-blue-500 dark:text-white md:-translate-x-12 md:text-4xl md:group-hover:translate-x-0">
15+
{item}
16+
</h1>
1917
</div>
2018
))}
2119
</div>

animata/text/counter.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ export default function Counter({
6161
return;
6262
}
6363

64-
setTimeout(() => {
64+
const timer = setTimeout(() => {
6565
motionValue.set(isGoingUp ? targetValue : 0);
6666
}, delay);
67+
68+
return () => clearTimeout(timer);
6769
}, [isInView, delay, isGoingUp, targetValue, motionValue]);
6870

6971
useEffect(() => {

animata/text/typing-text.stories.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type Story = StoryObj<typeof meta>;
1717
export const Primary: Story = {
1818
args: {
1919
text: "> yarn add @animata/awesomeness",
20-
repeat: true,
2120
grow: false,
2221
},
2322
render: (props) => (
@@ -27,16 +26,16 @@ export const Primary: Story = {
2726
),
2827
};
2928

30-
export const Quote: Story = {
29+
export const Smooth: Story = {
3130
args: {
32-
text: "The following excerpt from Carl Sagan's book Pale Blue Dot was inspired by an image taken, at Sagan's suggestion, by Voyager 1 on 14 February 1990. As the spacecraft was departing our planetary neighborhood for the fringes of the solar system, it turned it around for one last look at its home planet.",
33-
repeat: true,
34-
delay: 16,
31+
text: "This is a smooth typing text",
32+
delay: 50,
3533
alwaysVisibleCount: 0,
34+
smooth: true,
35+
waitTime: 5000,
3636
},
3737
render: (props) => (
38-
<div className="min-w-96 max-w-96 rounded-sm bg-blue-200 px-4 py-2 text-blue-600 shadow-lg">
39-
<div className="mb-1 text-lg font-bold">Quote</div>
38+
<div className="min-w-96 max-w-96 rounded-sm bg-gray-800 px-4 py-2 text-yellow-400 shadow-lg">
4039
<TypingText {...props} />
4140
</div>
4241
),

animata/widget/reminder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function Reminder({ className }: { className?: string }) {
2323

2424
<div className="flex flex-row gap-1 text-muted-foreground">
2525
<ArrowRight size={18} className="self-center" />
26-
<p className="text-md font-semibold">Meeting in 30 mins</p>
26+
<p className="text-sm font-semibold">Meeting in 30 mins</p>
2727
</div>
2828
</div>
2929
);

animata/widget/sleep-tracker.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,12 @@ export default function SleepTracker({
108108
<div className="icon flex h-4 w-4 items-center justify-center rounded-full bg-red-50">
109109
<div className="inner-icon h-2 w-2 rounded-full bg-red-500"></div>
110110
</div>
111-
<p className="text-gray-600 dark:text-white">Sleep Tracker</p>
111+
<p className="text-sm text-gray-600 dark:text-white">Sleep Tracker</p>
112112
</div>
113-
<img className="h-20 w-full rounded-xl object-cover" src={image} alt="Sleep Tracker" />
113+
<img className="h-16 w-full rounded-xl object-cover" src={image} alt="Sleep Tracker" />
114114

115-
<div className="graph-container">
116-
<BarChart className="pt-3" items={items} height={40} />
117-
</div>
118-
<div className="activity mt-2 flex flex-row justify-between">
115+
<BarChart className="pt-1" items={items} height={40} />
116+
<div className="activity mt-2 flex flex-row justify-between text-sm">
119117
<p className="text-primary opacity-70">Activity</p>
120118
<p className="text-muted-foreground">
121119
<strong>32m</strong> ago

components/component-list-item.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { useState } from "react";
2+
3+
import { CopyButton } from "@/components/copy-button";
4+
import { ReloadButton } from "@/components/reload-button";
5+
import { cn } from "@/lib/utils";
6+
7+
function Actions({ copyId, onRefresh }: { copyId: string; onRefresh: () => void }) {
8+
return (
9+
<div className="inline-flex w-full justify-end p-2">
10+
<CopyButton
11+
className="bg-white text-zinc-600 shadow-none dark:bg-zinc-950 dark:text-white"
12+
proxyId={`source-${copyId}`}
13+
value=""
14+
/>
15+
<ReloadButton
16+
className="bg-white text-zinc-600 shadow-none dark:bg-zinc-950 dark:text-white"
17+
onClick={onRefresh}
18+
/>
19+
</div>
20+
);
21+
}
22+
23+
export default function ComponentListItem({
24+
children,
25+
className,
26+
copyId,
27+
...props
28+
}: {
29+
copyId: string;
30+
className?: string;
31+
children: React.ReactNode;
32+
}) {
33+
const [forceUpdate, setForceUpdate] = useState(0);
34+
return (
35+
<div {...props} className={cn("component-list-item relative rounded-xl border", className)}>
36+
<Actions copyId={copyId} onRefresh={() => setForceUpdate((prev) => prev + 1)} />
37+
<div
38+
key={`component-list-item-${copyId}-${forceUpdate}`}
39+
className="flex min-h-56 flex-col items-center justify-center px-4 pb-4"
40+
>
41+
{children}
42+
</div>
43+
</div>
44+
);
45+
}

components/copy-button.tsx

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import * as React from "react";
44
import { CheckIcon, ClipboardIcon } from "lucide-react";
5-
import { NpmCommands } from "types/unist";
5+
import { NpmCommands, TouchCommands } from "types/unist";
66

77
import { Button, ButtonProps } from "@/components/ui/button";
88
import {
@@ -125,6 +125,57 @@ interface CopyNpmCommandButtonProps extends DropdownMenuTriggerProps {
125125
commands: Required<NpmCommands>;
126126
}
127127

128+
interface CopyTouchCommandButtonProps extends DropdownMenuTriggerProps {
129+
commands: Required<TouchCommands>;
130+
}
131+
132+
export function CopyTouchCommandButton({ commands, className }: CopyTouchCommandButtonProps) {
133+
const [hasCopied, setHasCopied] = React.useState(false);
134+
135+
React.useEffect(() => {
136+
setTimeout(() => {
137+
setHasCopied(false);
138+
}, 2000);
139+
}, [hasCopied]);
140+
141+
const copyCommand = React.useCallback((value: string, os: "windows" | "macOS/Linux") => {
142+
copyToClipboardWithMeta(value, {
143+
name: "copy_touch_command",
144+
properties: {
145+
command: value,
146+
os,
147+
},
148+
});
149+
setHasCopied(true);
150+
}, []);
151+
152+
return (
153+
<DropdownMenu>
154+
<DropdownMenuTrigger asChild>
155+
<Button
156+
size="icon"
157+
variant="ghost"
158+
className={cn(
159+
"relative z-10 h-6 w-6 text-zinc-50 hover:bg-zinc-700 hover:text-zinc-50",
160+
className,
161+
)}
162+
>
163+
{hasCopied ? <CheckIcon className="h-3 w-3" /> : <ClipboardIcon className="h-3 w-3" />}
164+
<span className="sr-only">Copy</span>
165+
</Button>
166+
</DropdownMenuTrigger>
167+
<DropdownMenuContent align="end">
168+
<DropdownMenuItem onClick={() => copyCommand(commands.__unix__, "macOS/Linux")}>
169+
macOS/Linux
170+
</DropdownMenuItem>
171+
<DropdownMenuItem onClick={() => copyCommand(commands.__windows__, "windows")}>
172+
Windows
173+
</DropdownMenuItem>
174+
</DropdownMenuContent>
175+
</DropdownMenu>
176+
);
177+
}
178+
128179
export function CopyNpmCommandButton({ commands, className }: CopyNpmCommandButtonProps) {
129180
const [hasCopied, setHasCopied] = React.useState(false);
130181

components/mdx-components.tsx

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@ import { ComponentProps, HTMLAttributes } from "react";
33
import Image from "next/image";
44
import Link from "next/link";
55
import { useMDXComponent } from "next-contentlayer/hooks";
6-
import { NpmCommands } from "types/unist";
6+
import { NpmCommands, TouchCommands } from "types/unist";
77

88
import Modal from "@/animata/overlay/modal";
99
import { Callout } from "@/components/callout";
1010
import { CodeBlockWrapper } from "@/components/code-block-wrapper";
1111
import { ComponentExample } from "@/components/component-example";
12+
import ComponentListItem from "@/components/component-list-item";
1213
import { ComponentPreview } from "@/components/component-preview";
1314
import { ComponentSource } from "@/components/component-source";
14-
import { CopyButton, copyToClipboardWithMeta } from "@/components/copy-button";
15+
import {
16+
CopyButton,
17+
CopyNpmCommandButton,
18+
copyToClipboardWithMeta,
19+
CopyTouchCommandButton,
20+
} from "@/components/copy-button";
1521
import { FrameworkDocs } from "@/components/framework-docs";
1622
import {
1723
Accordion,
@@ -43,14 +49,21 @@ const components = {
4349
__src__,
4450
__event__,
4551
__copyId__,
52+
__windows__,
53+
__unix__,
54+
__bunCommand__,
55+
__npmCommand__,
56+
__pnpmCommand__,
57+
__yarnCommand__,
4658
...props
4759
}: React.HTMLAttributes<HTMLPreElement> & {
4860
__copyId__?: string;
4961
__rawString__?: string;
5062
__withMeta__?: boolean;
5163
__src__?: string;
5264
__event__?: Event["name"];
53-
} & NpmCommands) => {
65+
} & NpmCommands &
66+
TouchCommands) => {
5467
if (__copyId__ && __rawString__) {
5568
return (
5669
<div
@@ -71,14 +84,34 @@ const components = {
7184
)}
7285
{...props}
7386
/>
74-
{__rawString__ && (
87+
88+
{__rawString__ && !__windows__ && (
7589
<CopyButton
7690
value={__rawString__}
7791
src={__src__}
7892
event={__event__}
7993
className={cn("absolute right-4 top-4", __withMeta__ && "top-16")}
8094
/>
8195
)}
96+
97+
{__windows__ && __unix__ && (
98+
<CopyTouchCommandButton
99+
commands={{ __windows__, __unix__ }}
100+
className="absolute right-4 top-4"
101+
/>
102+
)}
103+
104+
{__npmCommand__ && __yarnCommand__ && __pnpmCommand__ && __bunCommand__ && (
105+
<CopyNpmCommandButton
106+
commands={{
107+
__npmCommand__,
108+
__yarnCommand__,
109+
__pnpmCommand__,
110+
__bunCommand__,
111+
}}
112+
className={cn("absolute right-4 top-4", __withMeta__ && "top-16")}
113+
/>
114+
)}
82115
</>
83116
);
84117
},
@@ -163,33 +196,7 @@ const components = {
163196
</div>
164197
);
165198
},
166-
ComponentListItem: ({
167-
children,
168-
className,
169-
copyId,
170-
...props
171-
}: {
172-
copyId: string;
173-
className?: string;
174-
children: React.ReactNode;
175-
}) => {
176-
return (
177-
<div
178-
{...props}
179-
className={cn(
180-
"component-list-item relative flex min-h-72 items-center justify-center rounded-xl border p-4",
181-
className,
182-
)}
183-
>
184-
{children}
185-
<CopyButton
186-
className="visible absolute right-1 top-1 text-zinc-600"
187-
proxyId={`source-${copyId}`}
188-
value=""
189-
/>
190-
</div>
191-
);
192-
},
199+
ComponentListItem,
193200
};
194201

195202
interface MdxProps {

config/docs.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const isDev = process.env.NODE_ENV !== "production";
1515

1616
const createLinks = (category: string) => {
1717
return allDocs
18-
.filter((doc) => doc.slug.startsWith(`/docs/${category}`))
18+
.filter((doc) => doc.slug.startsWith(`/docs/${category}`) && doc.published)
1919
.map((doc) => ({
2020
// Make sure the index page is the first item
2121
title: doc.title,
@@ -156,6 +156,10 @@ const sidebarNav: SidebarNavItem[] = [
156156
title: "Carousel",
157157
items: createLinks("carousel"),
158158
},
159+
{
160+
title: "Skeleton",
161+
items: createLinks("skeleton"),
162+
},
159163
]
160164
.filter((category) => Boolean(category.items?.length || category.label))
161165
.sort((a, b) => {

content/docs/background/blurry-blob.mdx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,20 @@ author: ll4xmii
66

77
<ComponentPreview name="background-blurry-blob--docs" />
88

9-
# Installation
9+
## Installation
1010

1111
1. Create a new file called `blurry-blob.tsx` inside the `components/animata/background` directory.
1212

13-
macOS/Linux:
14-
1513
```bash
1614
mkdir -p components/animata/background && touch components/animata/background/blurry-blob.tsx
1715
```
1816

19-
windows:
20-
21-
```bash
22-
mkdir components\animata\background && type null > components\animata\background\blurry-blob.tsx
23-
```
24-
2517
2. Open the newly created file and add the following code:
2618

2719
```jsx file=<rootDir>/animata/background/blurry-blob.tsx
2820

2921
```
3022

31-
# Credits
23+
## Credits
3224

3325
Built by [Laxmi Lamichhane](https://github.com/llaxmi)

0 commit comments

Comments
 (0)