Skip to content

Commit

Permalink
docs: improve landing page cards
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalbdivad committed Jan 24, 2025
1 parent b227e45 commit ff6c075
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 102 deletions.
40 changes: 15 additions & 25 deletions ark/docs/app/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,32 @@ export default () => (

<ArkCards>
<ArkCard title="Unparalleled DX" icon={<TsIcon height={20} />}>
<p>
Type syntax you already know with safety and completions unlike
anything you&apos;ve ever seen
</p>
Type syntax you already know with safety and completions unlike anything
you've ever seen
<CodeBlock fromFile="unparalleledDx" includesCompletions />
</ArkCard>
<ArkCard title="Faster... everything" icon={<RocketIcon />}>
<p>
100x faster than Zod at runtime with editor performance that will
remind you how autocomplete is supposed to feel
</p>
<RuntimeBenchmarksGraph className="mt-2" />
<ArkCard title="Better Errors" icon={<MessageCircleWarning />}>
Deeply customizable messages with great defaults
<CodeBlock fromFile="betterErrors" />
</ArkCard>
<ArkCard title="Clarity and Concision" icon={<MessageSquareTextIcon />}>
<p>
Definitions are half as long, type errors are twice as readable, and
hovers tell you just what really matters
</p>
Definitions are half as long, type errors are twice as readable, and
hovers tell you just what really matters
<CodeBlock fromFile="clarityAndConcision" />
</ArkCard>
<ArkCard title="Better Errors" icon={<MessageCircleWarning />}>
<p>Deeply customizable messages with great defaults</p>
<CodeBlock fromFile="betterErrors" />
<ArkCard title="Faster... everything" icon={<RocketIcon />}>
100x faster than Zod and 2,000x faster than Yup at runtime, with editor
performance that will remind you how autocomplete is supposed to feel
<RuntimeBenchmarksGraph className="mt-2" />
</ArkCard>
<ArkCard title="Deep Introspectability" icon={<SearchIcon />}>
<p>
ArkType uses set theory to understand and expose the relationships
between your types at runtime the way TypeScript does at compile time
</p>
ArkType uses set theory to understand and expose the relationships
between your types at runtime the way TypeScript does at compile time
<CodeBlock fromFile="deepIntrospectability" />
</ArkCard>
<ArkCard title="Intrinsic Optimization" icon={<LightbulbIcon />}>
<p>
Every schema is internally normalized and reduced to its purest and
fastest representation
</p>
Every schema is internally normalized and reduced to its purest and
fastest representation
<CodeBlock fromFile="intrinsicOptimization" />
</ArkCard>
{/* <Card title="Portable" icon="seti:json">
Expand Down
4 changes: 3 additions & 1 deletion ark/docs/components/ArkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export const ArkCard: React.FC<CardProps> = ({
{...props}
className={cn(
"ark-card", // special class for ArkCards targeting
"sm:even:translate-y-10 [&>h3]:text-2xl [&>h3]:font-semibold border-[#003b62]",
"sm:even:translate-y-10 [&>h3]:text-2xl [&>h3]:font-semibold [&_.prose-no-margin]:text-lg border-[#003b62]",
"[&>.prose-no-margin]:flex [&>.prose-no-margin]:flex-col [&>.prose-no-margin]:flex-grow",
"flex flex-col",
className
)}
>
Expand Down
119 changes: 43 additions & 76 deletions ark/docs/components/RuntimeBenchmarksGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,104 +1,71 @@
import { cn } from "fumadocs-ui/components/api"
import React from "react"

const barStyles: React.CSSProperties = {
height: "30px",
borderRadius: "5px",
borderRadius: "8px",
display: "flex",
alignItems: "baseline",
marginRight: "1rem",
marginRight: "0.5rem",
marginBottom: "0.5rem",
color: "black"
}

const arkBarStyles = {
...barStyles,
background:
"repeating-linear-gradient(135deg, #40decc, #40decc 10px, #34c8b9 10px, #34c8b9 20px)"
"repeating-linear-gradient(135deg, #00ffd5, #00ffd5 12px, #00e6bf 12px, #00e6bf 24px)"
}

const zodBarStyles = {
...barStyles,
background:
"repeating-linear-gradient(135deg, #b084f6, #b084f6 10px, #9a6fe3 10px, #9a6fe3 20px)"
"repeating-linear-gradient(135deg, rgba(140, 205, 255, 0.6), rgba(140, 205, 255, 0.6) 12px, rgba(124, 189, 237, 0.6) 12px, rgba(124, 189, 237, 0.6) 24px)"
}

const yupBarStyles = {
...barStyles,
background:
"repeating-linear-gradient(135deg, rgba(144, 175, 224, 0.7), rgba(144, 175, 224, 0.7) 12px, rgba(133, 157, 199, 0.7) 12px, rgba(133, 157, 199, 0.7) 24px)"
}

export const RuntimeBenchmarksGraph: React.FC<{ className?: string }> = ({
className
}) => (
<div
style={{ fontSize: 14, fontWeight: 500 }}
style={{
fontSize: 16.8,
fontWeight: 500,
display: "flex",
flexDirection: "column",
flexGrow: 1
}}
className={cn("font-semibold text-white", className)}
>
<div
style={{
display: "flex",
flexDirection: "row"
}}
>
<h6 className="text-lg mb-2">
Object Validation, Node v22.2.0 (
<a
target="_blank"
href="https://moltar.github.io/typescript-runtime-type-benchmarks/"
>
source
</a>
)
</h6>
</div>
<div
style={{
display: "flex",
alignItems: "center"
}}
>
<div style={{ ...arkBarStyles, width: "1.06%" }}></div>
ArkType (15 nanoseconds)
</div>
<div style={{ ...zodBarStyles, width: "100%" }}>
&nbsp;&nbsp;Zod (1374 nanoseconds)
</div>
</div>
)

export const TypeBenchmarksGraph = () => (
<div style={{ fontSize: 14, fontWeight: 500 }}>
<div
style={{
display: "flex",
flexDirection: "row"
}}
>
<h6 style={{ fontSize: 15 }}>
Union Type Instantiations, TypeScript 5.5.3 (
<a
target="_blank"
href="https://github.com/arktypeio/arktype/blob/468da965d9a2bbb16fe38d37e82c3b35e5158334/ark/repo/scratch/discriminatedComparison.ts"
>
source
</a>
)
</h6>
</div>
<div
style={{
display: "flex",
alignItems: "center"
}}
>
<div style={{ ...arkBarStyles, width: "10.94%" }}></div>
ArkType Auto-Discriminated (7,801)
</div>
<div
style={{
display: "flex",
alignItems: "center"
}}
>
<div style={{ ...zodBarStyles, width: "34.98%" }}></div>
Zod Raw (24,944)
<div style={{ display: "flex", flexDirection: "row" }}>
<h6 className="text-xl mb-2">Object Validation, Node v23.6.1</h6>{" "}
<a
className="underline ml-2"
target="_blank"
href="https://moltar.github.io/typescript-runtime-type-benchmarks/"
style={{ textDecoration: "underline", color: "#1e90ff" }}
>
(source)
</a>
</div>
<div style={{ ...zodBarStyles, width: "100%", justifyContent: "end" }}>
Zod Discriminated (71,312)&nbsp;&nbsp;
<div style={{ display: "flex", flexDirection: "column", flexGrow: 1 }}>
<div style={{ display: "flex", alignItems: "center" }}>
<div style={{ ...arkBarStyles, width: "0.5%" }}></div>
ArkType ⚡ 14 nanoseconds
</div>
<div style={{ ...zodBarStyles, width: "50%" }}>
&nbsp;&nbsp;&nbsp;Zod 👍 1397 nanoseconds
</div>
<div style={{ ...yupBarStyles, width: "100%" }}>
&nbsp;&nbsp;&nbsp;Yup 🐌 40755 nanoseconds*
</div>
<div className="text-xs mt-auto self-end">
*scaling generously logarithmized
</div>
</div>
</div>
)

0 comments on commit ff6c075

Please sign in to comment.