add Fresh Components (#872)
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import DocsTitle from "./DocsTitle.tsx";
|
||||
|
||||
export default function DocsHeader() {
|
||||
export default function DocsHeader(props: { title: string }) {
|
||||
return (
|
||||
<div class="bg-green-300">
|
||||
<header class="mx-auto max-w-screen-lg flex gap-3 justify-between">
|
||||
<div class="p-4 flex">
|
||||
<Logo />
|
||||
<div>
|
||||
<DocsTitle />
|
||||
<DocsTitle title={props.title} />
|
||||
</div>
|
||||
</div>
|
||||
<label
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function DocsTitle() {
|
||||
export default function DocsTitle(props: { title: string }) {
|
||||
return (
|
||||
<>
|
||||
<a
|
||||
@@ -18,7 +18,7 @@ export default function DocsTitle() {
|
||||
fill="#0A140C"
|
||||
/>
|
||||
</svg>
|
||||
<span class="font-light block pb-[1px]">docs</span>
|
||||
<span class="font-light block pb-[1px]">{props.title}</span>
|
||||
</a>
|
||||
<p class="text(sm gray-700)">The next-gen web framework.</p>
|
||||
</>
|
||||
|
||||
@@ -12,6 +12,10 @@ export default function NavigationBar(props: { active: string }) {
|
||||
name: "Showcase",
|
||||
href: "/showcase",
|
||||
},
|
||||
{
|
||||
name: "Components",
|
||||
href: "/components",
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { JSX } from "preact";
|
||||
|
||||
export default function Background(props: JSX.HTMLAttributes<HTMLDivElement>) {
|
||||
return (
|
||||
<div
|
||||
{...props}
|
||||
class="bg-gray-200 py-16 px-8 flex items-center justify-center rounded"
|
||||
style="background-image: url(/gallery/grid.svg)"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { JSX } from "preact";
|
||||
import { IS_BROWSER } from "$fresh/runtime.ts";
|
||||
|
||||
export default function Button(props: JSX.HTMLAttributes<HTMLButtonElement>) {
|
||||
return (
|
||||
<button
|
||||
{...props}
|
||||
disabled={!IS_BROWSER || props.disabled}
|
||||
class={`px-3 py-2 bg-white rounded border(gray-500 2) hover:bg-gray-200 disabled:(opacity-50 cursor-not-allowed) ${
|
||||
props.class ?? ""
|
||||
}`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { useState } from "preact/hooks";
|
||||
|
||||
import Prism from "https://esm.sh/prismjs@1.27.0";
|
||||
import "https://esm.sh/prismjs@1.27.0/components/prism-typescript?no-check";
|
||||
|
||||
interface CodeBoxProps {
|
||||
code: string;
|
||||
}
|
||||
|
||||
export default function CodeBox(props: CodeBoxProps) {
|
||||
const highlighted = Prism.highlight(
|
||||
props.code,
|
||||
Prism.languages.typescript,
|
||||
"typescript",
|
||||
);
|
||||
const onCopy = () => {
|
||||
navigator.clipboard.writeText(props.code);
|
||||
setCopied(true);
|
||||
};
|
||||
|
||||
const [copied, setCopied] = useState(false);
|
||||
return (
|
||||
<div class="">
|
||||
<details>
|
||||
<summary class="text-center cursor-pointer bg-gray-50 select-none text-gray-600 hover:text-gray-800 hover:bg-gray-100 py-2 rounded-b">
|
||||
Code
|
||||
</summary>
|
||||
<code class="relative">
|
||||
<pre
|
||||
class="bg-gray-800 text-blue-300 p-2 text-sm rounded whitespace-pre-wrap"
|
||||
dangerouslySetInnerHTML={{ __html: highlighted }}
|
||||
/>
|
||||
<button
|
||||
onClick={onCopy}
|
||||
class="absolute top-2 right-2 px-3 py-2 border border-gray-400 rounded text-white"
|
||||
>
|
||||
{copied ? "Copied!" : "Copy"}
|
||||
</button>
|
||||
</code>
|
||||
</details>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { JSX } from "preact";
|
||||
import { IS_BROWSER } from "$fresh/runtime.ts";
|
||||
|
||||
export default function ColoredButton(
|
||||
props: JSX.HTMLAttributes<HTMLButtonElement>,
|
||||
) {
|
||||
return (
|
||||
<button
|
||||
{...props}
|
||||
disabled={!IS_BROWSER || props.disabled}
|
||||
class="px-3 py-2 bg-blue-200 text-blue-800 rounded hover:bg-blue-300"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import { ComponentChildren } from "preact";
|
||||
import LemonIcon from "https://deno.land/x/tabler_icons_tsx@0.0.1/tsx/lemon-2.tsx";
|
||||
import BrandGithub from "https://deno.land/x/tabler_icons_tsx@0.0.1/tsx/brand-github.tsx";
|
||||
type Props = {
|
||||
children: ComponentChildren;
|
||||
};
|
||||
|
||||
export default function Footer({ children }: Props) {
|
||||
const menus = [
|
||||
{
|
||||
title: "Documentation",
|
||||
children: [
|
||||
{ name: "Getting Started", href: "#" },
|
||||
{ name: "Guide", href: "#" },
|
||||
{ name: "API", href: "#" },
|
||||
{ name: "Showcase", href: "#" },
|
||||
{ name: "Pricing", href: "#" },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Community",
|
||||
children: [
|
||||
{ name: "Forum", href: "#" },
|
||||
{ name: "Discord", href: "#" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div class="bg-white flex w-full max-w-screen-lg gap-16 px-8 py-8 text-sm">
|
||||
<div class="flex-1">
|
||||
<div class="flex items-center gap-1">
|
||||
<LemonIcon class="inline-block" />
|
||||
<div class="font-bold text-2xl">
|
||||
Fresh
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-gray-500">
|
||||
Full Stack Framework
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{menus.map((item) => (
|
||||
<div class="mb-4" key={item.title}>
|
||||
<div class="font-bold">{item.title}</div>
|
||||
<ul class="mt-2">
|
||||
{item.children.map((child) => (
|
||||
<li class="mt-2" key={child.name}>
|
||||
<a
|
||||
class="text-gray-500 hover:text-gray-700"
|
||||
href={child.href}
|
||||
>
|
||||
{child.name}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
))}
|
||||
|
||||
<div class="text-gray-500 space-y-2">
|
||||
<div class="text-xs">
|
||||
Copyright © 2020 DenoLand<br />
|
||||
All right reserved.
|
||||
</div>
|
||||
|
||||
<a
|
||||
href="https://github.com/denoland/fresh"
|
||||
class="inline-block hover:text-black"
|
||||
>
|
||||
<BrandGithub />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import LemonIcon from "https://deno.land/x/tabler_icons_tsx@0.0.1/tsx/lemon-2.tsx";
|
||||
|
||||
type Props = {
|
||||
active: string;
|
||||
};
|
||||
|
||||
export default function Header({ active }: Props) {
|
||||
const menus = [
|
||||
{ name: "Home", href: "/" },
|
||||
{ name: "Components", href: "/components" },
|
||||
{ name: "Docs", href: "/docs" },
|
||||
];
|
||||
|
||||
return (
|
||||
<div class="bg-white w-full max-w-screen-lg py-6 px-8 flex items-center justify-center">
|
||||
<LemonIcon />
|
||||
<div class="text-2xl flex-1 ml-1 font-bold">
|
||||
Fresh
|
||||
</div>
|
||||
<ul class="flex items-center gap-6">
|
||||
{menus.map((menu) => (
|
||||
<li>
|
||||
<a
|
||||
href={menu.href}
|
||||
class={"text-gray-500 hover:text-gray-700 py-1 border-gray-500" +
|
||||
(menu.href === active ? " font-bold border-b-2" : "")}
|
||||
>
|
||||
{menu.name}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { JSX } from "preact";
|
||||
import { IS_BROWSER } from "$fresh/runtime.ts";
|
||||
|
||||
export default function Input(props: JSX.HTMLAttributes<HTMLInputElement>) {
|
||||
return (
|
||||
<input
|
||||
{...props}
|
||||
disabled={!IS_BROWSER || props.disabled}
|
||||
class={`px-3 py-2 bg-white rounded border(gray-500 2) disabled:(opacity-50 cursor-not-allowed) ${
|
||||
props.class ?? ""
|
||||
}`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { JSX } from "preact";
|
||||
|
||||
export default function LinkButton(
|
||||
props: JSX.HTMLAttributes<HTMLAnchorElement>,
|
||||
) {
|
||||
return (
|
||||
<a
|
||||
{...props}
|
||||
class={`inline-block cursor-pointer px-3 py-2 bg-white rounded hover:bg-gray-100 ${
|
||||
props.class ?? ""
|
||||
}`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user