code examples
This commit is contained in:
parent
438aa3f5b4
commit
7db4fe00fd
|
|
@ -3,6 +3,7 @@ import { H2, Text } from "./text"
|
||||||
import "hono/jsx"
|
import "hono/jsx"
|
||||||
import type { FC, JSX } from "hono/jsx"
|
import type { FC, JSX } from "hono/jsx"
|
||||||
import { VStack, HStack } from "./stack"
|
import { VStack, HStack } from "./stack"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
export type AvatarProps = {
|
export type AvatarProps = {
|
||||||
src: string
|
src: string
|
||||||
|
|
@ -36,12 +37,14 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<Section>
|
<Section>
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<VStack gap={2} style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px" }}>
|
<CodeExamples
|
||||||
<div><Avatar src="/user.jpg" /></div>
|
examples={[
|
||||||
<div><Avatar src="/user.jpg" size={64} /></div>
|
'<Avatar src="/user.jpg" />',
|
||||||
<div><Avatar src="/user.jpg" size={48} rounded /></div>
|
'<Avatar src="/user.jpg" size={64} />',
|
||||||
<div><Avatar src="/user.jpg" style={{ border: "2px solid blue" }} /></div>
|
'<Avatar src="/user.jpg" size={48} rounded />',
|
||||||
</VStack>
|
'<Avatar src="/user.jpg" style={{ border: "2px solid blue" }} />',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Size variations */}
|
{/* Size variations */}
|
||||||
<VStack gap={4}>
|
<VStack gap={4}>
|
||||||
|
|
|
||||||
15
src/box.tsx
15
src/box.tsx
|
|
@ -1,5 +1,6 @@
|
||||||
import "hono/jsx"
|
import "hono/jsx"
|
||||||
import type { FC, PropsWithChildren, JSX } from "hono/jsx"
|
import type { FC, PropsWithChildren, JSX } from "hono/jsx"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
type BoxProps = PropsWithChildren & {
|
type BoxProps = PropsWithChildren & {
|
||||||
bg?: string
|
bg?: string
|
||||||
|
|
@ -48,12 +49,14 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<div style={{ display: "flex", flexDirection: "column", gap: "32px", padding: "24px" }}>
|
<div style={{ display: "flex", flexDirection: "column", gap: "32px", padding: "24px" }}>
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<div style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px", display: "flex", flexDirection: "column", gap: "8px" }}>
|
<CodeExamples
|
||||||
<div><Box>Content</Box></div>
|
examples={[
|
||||||
<div><Box bg="#3b82f6" p={16}>Content</Box></div>
|
'<Box>Content</Box>',
|
||||||
<div><RedBox>Content</RedBox></div>
|
'<Box bg="#3b82f6" p={16}>Content</Box>',
|
||||||
<div><GrayBox>Content</GrayBox></div>
|
'<RedBox>Content</RedBox>',
|
||||||
</div>
|
'<GrayBox>Content</GrayBox>',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h2 style={{ fontSize: "20px", fontWeight: "bold", marginBottom: "16px" }}>Box Component</h2>
|
<h2 style={{ fontSize: "20px", fontWeight: "bold", marginBottom: "16px" }}>Box Component</h2>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import type { JSX, FC } from "hono/jsx"
|
||||||
import { VStack, HStack } from "./stack"
|
import { VStack, HStack } from "./stack"
|
||||||
import { Section } from "./section"
|
import { Section } from "./section"
|
||||||
import { H2 } from "./text"
|
import { H2 } from "./text"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
export type ButtonProps = JSX.IntrinsicElements["button"] & {
|
export type ButtonProps = JSX.IntrinsicElements["button"] & {
|
||||||
variant?: "primary" | "secondary" | "outline" | "ghost" | "destructive"
|
variant?: "primary" | "secondary" | "outline" | "ghost" | "destructive"
|
||||||
|
|
@ -80,12 +81,14 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<Section>
|
<Section>
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<VStack gap={2} style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px" }}>
|
<CodeExamples
|
||||||
<div><Button>Click Me</Button></div>
|
examples={[
|
||||||
<div><Button variant="secondary">Secondary</Button></div>
|
'<Button>Click Me</Button>',
|
||||||
<div><Button variant="outline" size="lg">Large</Button></div>
|
'<Button variant="secondary">Secondary</Button>',
|
||||||
<div><Button onClick={handleClick}>Action</Button></div>
|
'<Button variant="outline" size="lg">Large</Button>',
|
||||||
</VStack>
|
'<Button onClick={handleClick}>Action</Button>',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Variants */}
|
{/* Variants */}
|
||||||
<VStack gap={4}>
|
<VStack gap={4}>
|
||||||
|
|
|
||||||
226
src/code.tsx
Normal file
226
src/code.tsx
Normal file
|
|
@ -0,0 +1,226 @@
|
||||||
|
import "hono/jsx"
|
||||||
|
import type { FC } from "hono/jsx"
|
||||||
|
import { VStack } from "./stack"
|
||||||
|
|
||||||
|
type CodeProps = {
|
||||||
|
children: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Color scheme
|
||||||
|
const colors = {
|
||||||
|
tag: "#0ea5e9", // cyan-500
|
||||||
|
attr: "#8b5cf6", // violet-500
|
||||||
|
string: "#10b981", // emerald-500
|
||||||
|
number: "#f59e0b", // amber-500
|
||||||
|
brace: "#ef4444", // red-500
|
||||||
|
text: "#374151", // gray-700
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lightweight JSX syntax highlighter
|
||||||
|
export const Code: FC<CodeProps> = ({ children }) => {
|
||||||
|
const tokens = tokenizeJSX(children)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
fontFamily: "monospace",
|
||||||
|
fontSize: "13px",
|
||||||
|
lineHeight: "1.5",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{tokens.map((token, i) => {
|
||||||
|
if (token.type === "tag") {
|
||||||
|
return (
|
||||||
|
<span key={i} style={{ color: colors.tag, fontWeight: "600" }}>
|
||||||
|
{token.value}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (token.type === "attr") {
|
||||||
|
return (
|
||||||
|
<span key={i} style={{ color: colors.attr }}>
|
||||||
|
{token.value}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (token.type === "string") {
|
||||||
|
return (
|
||||||
|
<span key={i} style={{ color: colors.string }}>
|
||||||
|
{token.value}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (token.type === "number") {
|
||||||
|
return (
|
||||||
|
<span key={i} style={{ color: colors.number }}>
|
||||||
|
{token.value}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (token.type === "brace") {
|
||||||
|
return (
|
||||||
|
<span key={i} style={{ color: colors.brace, fontWeight: "600" }}>
|
||||||
|
{token.value}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return <span key={i}>{token.value}</span>
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
type CodeExamplesProps = {
|
||||||
|
examples: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Container for multiple code examples
|
||||||
|
export const CodeExamples: FC<CodeExamplesProps> = ({ examples }) => {
|
||||||
|
return (
|
||||||
|
<VStack
|
||||||
|
gap={2}
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#f9fafb",
|
||||||
|
padding: "16px",
|
||||||
|
borderRadius: "8px",
|
||||||
|
border: "1px solid #e5e7eb",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{examples.map((example, i) => (
|
||||||
|
<Code key={i}>{example}</Code>
|
||||||
|
))}
|
||||||
|
</VStack>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Token = {
|
||||||
|
type: "tag" | "attr" | "string" | "number" | "brace" | "text"
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
|
||||||
|
function tokenizeJSX(code: string): Token[] {
|
||||||
|
const tokens: Token[] = []
|
||||||
|
let i = 0
|
||||||
|
|
||||||
|
while (i < code.length) {
|
||||||
|
// Match opening/closing tags: < or </
|
||||||
|
if (code[i] === "<") {
|
||||||
|
const tagStart = i
|
||||||
|
i++
|
||||||
|
|
||||||
|
// Check for closing tag
|
||||||
|
if (code[i] === "/") {
|
||||||
|
tokens.push({ type: "tag", value: "</" })
|
||||||
|
i++
|
||||||
|
} else {
|
||||||
|
tokens.push({ type: "tag", value: "<" })
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get tag name
|
||||||
|
let tagName = ""
|
||||||
|
while (i < code.length && /[A-Za-z0-9.]/.test(code[i]!)) {
|
||||||
|
tagName += code[i]
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
if (tagName) {
|
||||||
|
tokens.push({ type: "tag", value: tagName })
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse attributes inside the tag
|
||||||
|
while (i < code.length && code[i] !== ">") {
|
||||||
|
// Skip whitespace
|
||||||
|
if (/\s/.test(code[i]!)) {
|
||||||
|
tokens.push({ type: "text", value: code[i]! })
|
||||||
|
i++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for self-closing /
|
||||||
|
if (code[i] === "/" && code[i + 1] === ">") {
|
||||||
|
tokens.push({ type: "tag", value: " />" })
|
||||||
|
i += 2
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse attribute name
|
||||||
|
let attrName = ""
|
||||||
|
while (i < code.length && /[a-zA-Z0-9-]/.test(code[i]!)) {
|
||||||
|
attrName += code[i]
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
if (attrName) {
|
||||||
|
tokens.push({ type: "attr", value: attrName })
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for =
|
||||||
|
if (code[i] === "=") {
|
||||||
|
tokens.push({ type: "text", value: "=" })
|
||||||
|
i++
|
||||||
|
|
||||||
|
// Parse attribute value
|
||||||
|
if (code[i] === '"') {
|
||||||
|
// String value
|
||||||
|
let str = '"'
|
||||||
|
i++
|
||||||
|
while (i < code.length && code[i] !== '"') {
|
||||||
|
str += code[i]
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
if (code[i] === '"') {
|
||||||
|
str += '"'
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
tokens.push({ type: "string", value: str })
|
||||||
|
} else if (code[i] === "{") {
|
||||||
|
// Brace value
|
||||||
|
tokens.push({ type: "brace", value: "{" })
|
||||||
|
i++
|
||||||
|
|
||||||
|
// Get content inside braces
|
||||||
|
let content = ""
|
||||||
|
let depth = 1
|
||||||
|
while (i < code.length && depth > 0) {
|
||||||
|
if (code[i] === "{") depth++
|
||||||
|
if (code[i] === "}") {
|
||||||
|
depth--
|
||||||
|
if (depth === 0) break
|
||||||
|
}
|
||||||
|
content += code[i]
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if content is a number
|
||||||
|
if (/^\d+$/.test(content)) {
|
||||||
|
tokens.push({ type: "number", value: content })
|
||||||
|
} else {
|
||||||
|
tokens.push({ type: "text", value: content })
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code[i] === "}") {
|
||||||
|
tokens.push({ type: "brace", value: "}" })
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Closing >
|
||||||
|
if (code[i] === ">") {
|
||||||
|
tokens.push({ type: "tag", value: ">" })
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Regular text
|
||||||
|
let text = ""
|
||||||
|
while (i < code.length && code[i] !== "<") {
|
||||||
|
text += code[i]
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
if (text) {
|
||||||
|
tokens.push({ type: "text", value: text })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tokens
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@ import { H2 } from "./text"
|
||||||
import "hono/jsx"
|
import "hono/jsx"
|
||||||
import type { FC, PropsWithChildren, JSX } from "hono/jsx"
|
import type { FC, PropsWithChildren, JSX } from "hono/jsx"
|
||||||
import { VStack } from "./stack"
|
import { VStack } from "./stack"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
type DividerProps = PropsWithChildren & {
|
type DividerProps = PropsWithChildren & {
|
||||||
style?: JSX.CSSProperties
|
style?: JSX.CSSProperties
|
||||||
|
|
@ -45,11 +46,13 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<Section gap={4} maxWidth="448px" style={{ padding: "16px" }}>
|
<Section gap={4} maxWidth="448px" style={{ padding: "16px" }}>
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<VStack gap={2} style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px" }}>
|
<CodeExamples
|
||||||
<div><Divider /></div>
|
examples={[
|
||||||
<div><Divider>OR</Divider></div>
|
'<Divider />',
|
||||||
<div><Divider style={{ margin: "24px 0" }} /></div>
|
'<Divider>OR</Divider>',
|
||||||
</VStack>
|
'<Divider style={{ margin: "24px 0" }} />',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
<H2>Divider Examples</H2>
|
<H2>Divider Examples</H2>
|
||||||
|
|
||||||
|
|
|
||||||
15
src/grid.tsx
15
src/grid.tsx
|
|
@ -5,6 +5,7 @@ import { VStack } from "./stack"
|
||||||
import { Button } from "./button"
|
import { Button } from "./button"
|
||||||
import { Section } from "./section"
|
import { Section } from "./section"
|
||||||
import { H2, H3 } from "./text"
|
import { H2, H3 } from "./text"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
type GridProps = PropsWithChildren & {
|
type GridProps = PropsWithChildren & {
|
||||||
cols?: GridCols
|
cols?: GridCols
|
||||||
|
|
@ -73,12 +74,14 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<Section gap={4} style={{ padding: "16px" }}>
|
<Section gap={4} style={{ padding: "16px" }}>
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<VStack gap={2} style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px" }}>
|
<CodeExamples
|
||||||
<div><Grid cols={3}>...</Grid></div>
|
examples={[
|
||||||
<div><Grid cols={4} gap={6}>...</Grid></div>
|
'<Grid cols={3}>...</Grid>',
|
||||||
<div><Grid cols={{ sm: 1, md: 2, lg: 3 }}>...</Grid></div>
|
'<Grid cols={4} gap={6}>...</Grid>',
|
||||||
<div><Grid cols={2} v="center" h="center">...</Grid></div>
|
'<Grid cols={{ sm: 1, md: 2, lg: 3 }}>...</Grid>',
|
||||||
</VStack>
|
'<Grid cols={2} v="center" h="center">...</Grid>',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
<VStack gap={6}>
|
<VStack gap={6}>
|
||||||
<H2>Grid Examples</H2>
|
<H2>Grid Examples</H2>
|
||||||
|
|
|
||||||
15
src/icon.tsx
15
src/icon.tsx
|
|
@ -5,6 +5,7 @@ import { Grid } from "./grid"
|
||||||
import { VStack } from "./stack"
|
import { VStack } from "./stack"
|
||||||
import { Section } from "./section"
|
import { Section } from "./section"
|
||||||
import { H2, Text } from "./text"
|
import { H2, Text } from "./text"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
export type IconName = keyof typeof icons
|
export type IconName = keyof typeof icons
|
||||||
|
|
||||||
|
|
@ -73,12 +74,14 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<Section>
|
<Section>
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<VStack gap={2} style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px" }}>
|
<CodeExamples
|
||||||
<div><Icon name="Heart" /></div>
|
examples={[
|
||||||
<div><Icon name="Star" size={8} /></div>
|
'<Icon name="Heart" />',
|
||||||
<div><Icon name="Home" style={{ color: "#3b82f6" }} /></div>
|
'<Icon name="Star" size={8} />',
|
||||||
<div><IconLink name="ExternalLink" href="/link" /></div>
|
'<Icon name="Home" style={{ color: "#3b82f6" }} />',
|
||||||
</VStack>
|
'<IconLink name="ExternalLink" href="/link" />',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* === ICON TESTS === */}
|
{/* === ICON TESTS === */}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import "hono/jsx"
|
||||||
import type { FC, JSX } from "hono/jsx"
|
import type { FC, JSX } from "hono/jsx"
|
||||||
import { VStack, HStack } from "./stack"
|
import { VStack, HStack } from "./stack"
|
||||||
import { Grid } from "./grid"
|
import { Grid } from "./grid"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
export type ImageProps = {
|
export type ImageProps = {
|
||||||
src: string
|
src: string
|
||||||
|
|
@ -36,12 +37,14 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<Section>
|
<Section>
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<VStack gap={2} style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px" }}>
|
<CodeExamples
|
||||||
<div><Image src="/photo.jpg" /></div>
|
examples={[
|
||||||
<div><Image src="/photo.jpg" width={200} height={200} /></div>
|
'<Image src="/photo.jpg" />',
|
||||||
<div><Image src="/photo.jpg" objectFit="cover" /></div>
|
'<Image src="/photo.jpg" width={200} height={200} />',
|
||||||
<div><Image src="/photo.jpg" style={{ borderRadius: "8px" }} /></div>
|
'<Image src="/photo.jpg" objectFit="cover" />',
|
||||||
</VStack>
|
'<Image src="/photo.jpg" style={{ borderRadius: "8px" }} />',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
<H2>Image Examples</H2>
|
<H2>Image Examples</H2>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { H2, H3, H4, H5, Text, SmallText } from "./text"
|
||||||
import "hono/jsx"
|
import "hono/jsx"
|
||||||
import type { JSX, FC } from "hono/jsx"
|
import type { JSX, FC } from "hono/jsx"
|
||||||
import { VStack, HStack } from "./stack"
|
import { VStack, HStack } from "./stack"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
export type InputProps = JSX.IntrinsicElements["input"] & {
|
export type InputProps = JSX.IntrinsicElements["input"] & {
|
||||||
labelPosition?: "above" | "left" | "right"
|
labelPosition?: "above" | "left" | "right"
|
||||||
|
|
@ -73,12 +74,14 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<Section maxWidth="448px">
|
<Section maxWidth="448px">
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<VStack gap={2} style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px" }}>
|
<CodeExamples
|
||||||
<div><Input placeholder="Enter name" /></div>
|
examples={[
|
||||||
<div><Input type="email" placeholder="Email" /></div>
|
'<Input placeholder="Enter name" />',
|
||||||
<div><Input>Label</Input></div>
|
'<Input type="email" placeholder="Email" />',
|
||||||
<div><Input labelPosition="left">Name</Input></div>
|
'<Input>Label</Input>',
|
||||||
</VStack>
|
'<Input labelPosition="left">Name</Input>',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Basic inputs */}
|
{/* Basic inputs */}
|
||||||
<VStack gap={4}>
|
<VStack gap={4}>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { Image } from "./image"
|
||||||
import type { ImageProps } from "./image"
|
import type { ImageProps } from "./image"
|
||||||
import { VStack, HStack } from "./stack"
|
import { VStack, HStack } from "./stack"
|
||||||
import { Grid } from "./grid"
|
import { Grid } from "./grid"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
export const Placeholder = {
|
export const Placeholder = {
|
||||||
Avatar(props: PlaceholderAvatarProps) {
|
Avatar(props: PlaceholderAvatarProps) {
|
||||||
|
|
@ -38,12 +39,14 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<Section>
|
<Section>
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<VStack gap={2} style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px" }}>
|
<CodeExamples
|
||||||
<div><Placeholder.Avatar /></div>
|
examples={[
|
||||||
<div><Placeholder.Avatar type="avataaars" size={64} /></div>
|
'<Placeholder.Avatar />',
|
||||||
<div><Placeholder.Image width={200} height={200} /></div>
|
'<Placeholder.Avatar type="avataaars" size={64} />',
|
||||||
<div><Placeholder.Image seed={42} /></div>
|
'<Placeholder.Image width={200} height={200} />',
|
||||||
</VStack>
|
'<Placeholder.Image seed={42} />',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* === AVATAR TESTS === */}
|
{/* === AVATAR TESTS === */}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import "hono/jsx"
|
||||||
import type { FC, PropsWithChildren, JSX } from "hono/jsx"
|
import type { FC, PropsWithChildren, JSX } from "hono/jsx"
|
||||||
import { VStack } from "./stack"
|
import { VStack } from "./stack"
|
||||||
import type { TailwindSize } from "./types"
|
import type { TailwindSize } from "./types"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
type SectionProps = PropsWithChildren & {
|
type SectionProps = PropsWithChildren & {
|
||||||
gap?: TailwindSize
|
gap?: TailwindSize
|
||||||
|
|
@ -21,11 +22,15 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<div style={{ backgroundColor: "#f9fafb", padding: "16px", margin: "24px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px", display: "flex", flexDirection: "column", gap: "8px" }}>
|
<div style={{ margin: "24px" }}>
|
||||||
<div><Section>...</Section></div>
|
<CodeExamples
|
||||||
<div><Section gap={4}>...</Section></div>
|
examples={[
|
||||||
<div><Section maxWidth="600px">...</Section></div>
|
'<Section>...</Section>',
|
||||||
<div><Section style={{ backgroundColor: "#f3f4f6" }}>...</Section></div>
|
'<Section gap={4}>...</Section>',
|
||||||
|
'<Section maxWidth="600px">...</Section>',
|
||||||
|
'<Section style={{ backgroundColor: "#f3f4f6" }}>...</Section>',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Section>
|
<Section>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { H2, H3, H4, H5, Text, SmallText } from "./text"
|
||||||
import "hono/jsx"
|
import "hono/jsx"
|
||||||
import type { JSX, FC } from "hono/jsx"
|
import type { JSX, FC } from "hono/jsx"
|
||||||
import { VStack, HStack } from "./stack"
|
import { VStack, HStack } from "./stack"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
export type SelectOption = {
|
export type SelectOption = {
|
||||||
value: string
|
value: string
|
||||||
|
|
@ -164,12 +165,14 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<Section maxWidth="448px">
|
<Section maxWidth="448px">
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<VStack gap={2} style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px" }}>
|
<CodeExamples
|
||||||
<div><Select options={options} /></div>
|
examples={[
|
||||||
<div><Select options={options} placeholder="Choose" /></div>
|
'<Select options={options} />',
|
||||||
<div><Select options={options}>Label</Select></div>
|
'<Select options={options} placeholder="Choose" />',
|
||||||
<div><Select options={options} labelPosition="left">Label</Select></div>
|
'<Select options={options}>Label</Select>',
|
||||||
</VStack>
|
'<Select options={options} labelPosition="left">Label</Select>',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Basic selects */}
|
{/* Basic selects */}
|
||||||
<VStack gap={4}>
|
<VStack gap={4}>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { Grid } from "./grid"
|
||||||
import { Section } from "./section"
|
import { Section } from "./section"
|
||||||
import { H2 } from "./text"
|
import { H2 } from "./text"
|
||||||
import { RedBox, GreenBox, BlueBox } from "./box"
|
import { RedBox, GreenBox, BlueBox } from "./box"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
export const VStack: FC<VStackProps> = (props) => {
|
export const VStack: FC<VStackProps> = (props) => {
|
||||||
return (
|
return (
|
||||||
|
|
@ -69,12 +70,14 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<Section gap={8} style={{ padding: "16px" }}>
|
<Section gap={8} style={{ padding: "16px" }}>
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<VStack gap={2} style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px" }}>
|
<CodeExamples
|
||||||
<div><VStack>...</VStack></div>
|
examples={[
|
||||||
<div><VStack gap={4} v="center">...</VStack></div>
|
'<VStack>...</VStack>',
|
||||||
<div><HStack>...</HStack></div>
|
'<VStack gap={4} v="center">...</VStack>',
|
||||||
<div><HStack gap={6} h="between" v="center">...</HStack></div>
|
'<HStack>...</HStack>',
|
||||||
</VStack>
|
'<HStack gap={6} h="between" v="center">...</HStack>',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* HStack layout matrix */}
|
{/* HStack layout matrix */}
|
||||||
<VStack gap={2}>
|
<VStack gap={2}>
|
||||||
|
|
|
||||||
15
src/text.tsx
15
src/text.tsx
|
|
@ -1,5 +1,6 @@
|
||||||
import "hono/jsx"
|
import "hono/jsx"
|
||||||
import type { FC, PropsWithChildren, JSX } from "hono/jsx"
|
import type { FC, PropsWithChildren, JSX } from "hono/jsx"
|
||||||
|
import { CodeExamples } from "./code"
|
||||||
|
|
||||||
type TextProps = PropsWithChildren & {
|
type TextProps = PropsWithChildren & {
|
||||||
style?: JSX.CSSProperties
|
style?: JSX.CSSProperties
|
||||||
|
|
@ -37,12 +38,14 @@ export const Test = () => {
|
||||||
return (
|
return (
|
||||||
<div style={{ padding: "24px", display: "flex", flexDirection: "column", gap: "32px" }}>
|
<div style={{ padding: "24px", display: "flex", flexDirection: "column", gap: "32px" }}>
|
||||||
{/* API Usage Examples */}
|
{/* API Usage Examples */}
|
||||||
<div style={{ backgroundColor: "#f9fafb", padding: "16px", borderRadius: "8px", fontFamily: "monospace", fontSize: "12px", display: "flex", flexDirection: "column", gap: "8px" }}>
|
<CodeExamples
|
||||||
<div><H1>Heading 1</H1></div>
|
examples={[
|
||||||
<div><H2>Heading 2</H2></div>
|
'<H1>Heading 1</H1>',
|
||||||
<div><Text>Regular text</Text></div>
|
'<H2>Heading 2</H2>',
|
||||||
<div><SmallText>Small text</SmallText></div>
|
'<Text>Regular text</Text>',
|
||||||
</div>
|
'<SmallText>Small text</SmallText>',
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
<div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>
|
<div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>
|
||||||
<H1>Heading 1 (24px, bold)</H1>
|
<H1>Heading 1 (24px, bold)</H1>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { Hono } from 'hono'
|
import { Hono } from 'hono'
|
||||||
import { readdirSync } from 'fs'
|
import { readdirSync } from 'fs'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
import { capitalize } from './utils'
|
||||||
|
|
||||||
const port = process.env.PORT ?? '3100'
|
const port = process.env.PORT ?? '3100'
|
||||||
const app = new Hono()
|
const app = new Hono()
|
||||||
|
|
@ -14,7 +15,7 @@ app.get('/:file', async c => {
|
||||||
return c.text('404 Not Found', 404)
|
return c.text('404 Not Found', 404)
|
||||||
|
|
||||||
const page = await import(path + `?t=${Date.now()}`)
|
const page = await import(path + `?t=${Date.now()}`)
|
||||||
return c.html(<><h1>{file}</h1><page.Test req={c.req} /></>)
|
return c.html(<><h1><{capitalize(file)} /></h1><page.Test req={c.req} /></>)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/', c => {
|
app.get('/', c => {
|
||||||
|
|
|
||||||
4
test/utils.ts
Normal file
4
test/utils.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
// capitalize a word. that's it.
|
||||||
|
export function capitalize(str: string): string {
|
||||||
|
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user