-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
components page, use github api for posts
- Loading branch information
Showing
23 changed files
with
458 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,3 @@ export default function BlogLayout({ | |
</Outline> | ||
) | ||
} | ||
|
||
export const config = { runtime: 'experimental-edge' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--gap); | ||
|
||
section { | ||
margin-bottom: var(--gap); | ||
} | ||
|
||
ul { | ||
padding: 0; | ||
} | ||
|
||
h2 { | ||
margin: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import Badge from '@components/badge' | ||
import Button from '@components/button' | ||
import { GitHub } from '@components/icons' | ||
import Link from '@components/link' | ||
import styles from './page.module.css' | ||
import * as FileTree from '@components/file-tree' | ||
import { Entry } from '@components/entry' | ||
import BlockEntry from '@components/entry/block' | ||
import Tooltip from '@components/tooltip' | ||
import { Metadata } from 'next' | ||
|
||
export const metadata: Metadata = { | ||
title: 'Components', | ||
description: 'A collection of components on this website.', | ||
robots: { | ||
index: false, | ||
}, | ||
} | ||
|
||
export default function ComponentsPage() { | ||
return ( | ||
<section className={styles.wrapper}> | ||
<h1>Components</h1> | ||
<p> | ||
This page is a collection of components on this website. I use many of | ||
them in my other projects as well. Feel free to take what you need. | ||
</p> | ||
<ExampleWrapper> | ||
<h2>Button</h2> | ||
<Button width={100}>Click me</Button> | ||
<Button loading width={100}> | ||
Click me | ||
</Button> | ||
<Button disabled width={100}> | ||
Click me | ||
</Button> | ||
</ExampleWrapper> | ||
<ExampleWrapper> | ||
<h2>Icon</h2> | ||
<p> | ||
{' '} | ||
SVG Icons largely from{' '} | ||
<Link href="https://feathericons.com/">Feather Icons</Link>{' '} | ||
</p> | ||
<GitHub /> <GitHub size={40} /> <GitHub strokeWidth={3} /> | ||
</ExampleWrapper> | ||
<ExampleWrapper> | ||
<h2>Link</h2> | ||
|
||
<Link href="">A Link</Link> | ||
<Link href="" underline={false}> | ||
No underline | ||
</Link> | ||
</ExampleWrapper> | ||
<ExampleWrapper> | ||
<h2>Badge</h2> | ||
<Badge width={75}>A badge</Badge> | ||
</ExampleWrapper> | ||
<ExampleWrapper> | ||
<h2>File tree</h2> | ||
<FileTree.FileTree> | ||
<FileTree.Folder name="src" open> | ||
<FileTree.File name="page.tsx" type="page" /> | ||
<FileTree.File name="layout.tsx" type="layout" /> | ||
<FileTree.Folder name="components" open> | ||
<FileTree.File name="button.tsx" type="component" note="A note" /> | ||
<FileTree.File name="icon.tsx" type="component" /> | ||
</FileTree.Folder> | ||
</FileTree.Folder> | ||
</FileTree.FileTree> | ||
</ExampleWrapper> | ||
<ExampleWrapper> | ||
<h2>Entries</h2> | ||
<h3>Regular</h3> | ||
<ul style={{ listStyle: 'none', margin: 0 }}> | ||
<Entry | ||
description="Description" | ||
role="Role" | ||
title="Title" | ||
href="" | ||
years={['2023']} | ||
showYears | ||
/> | ||
</ul> | ||
<h3>Block</h3> | ||
<ul style={{ listStyle: 'none', margin: 0 }}> | ||
<BlockEntry | ||
title="Title" | ||
href="" | ||
description="Description" | ||
date={new Date()} | ||
views={0} | ||
/> | ||
</ul> | ||
<h4>Skeleton</h4> | ||
<ul style={{ listStyle: 'none', margin: 0 }}> | ||
<BlockEntry skeleton /> | ||
</ul> | ||
</ExampleWrapper> | ||
<ExampleWrapper> | ||
<h2>Tooltip</h2> | ||
<Tooltip text="This is a tooltip">Hover me</Tooltip> | ||
</ExampleWrapper> | ||
</section> | ||
) | ||
} | ||
|
||
const ExampleWrapper = ({ children }: { children: React.ReactNode }) => ( | ||
<section className={styles.wrapper}>{children}</section> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,87 @@ | ||
import styles from './button.module.css' | ||
import { forwardRef, Ref } from 'react' | ||
import styles from "./button.module.css" | ||
import { forwardRef } from "react" | ||
import clsx from "clsx" | ||
import { Spinner } from "@components/spinner" | ||
|
||
type Props = React.HTMLProps<HTMLButtonElement> & { | ||
onClick?: () => void | ||
children: React.ReactNode | ||
disabled?: boolean | ||
width?: number | ||
height?: number | ||
type Props = React.DetailedHTMLProps< | ||
React.ButtonHTMLAttributes<HTMLButtonElement>, | ||
HTMLButtonElement | ||
> & { | ||
children?: React.ReactNode | ||
buttonType?: "primary" | "secondary" | ||
className?: string | ||
// eslint-disable-next-line no-unused-vars | ||
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void | ||
iconRight?: React.ReactNode | ||
iconLeft?: React.ReactNode | ||
height?: string | number | ||
width?: string | number | ||
padding?: string | number | ||
margin?: string | number | ||
loading?: boolean | ||
} | ||
|
||
// eslint-disable-next-line react/display-name | ||
const Button = forwardRef( | ||
( | ||
{ onClick, children, disabled, width, height, ...props }: Props, | ||
ref: Ref<HTMLButtonElement> | ||
) => { | ||
return ( | ||
<button | ||
onClick={onClick} | ||
className={styles.button} | ||
disabled={disabled} | ||
ref={ref} | ||
style={{ | ||
width: width ? `${width}px` : 'auto', | ||
height: height ? `${height}px` : 'auto', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}} | ||
{...props} | ||
type={(props.type as any) || 'button'} | ||
> | ||
{children} | ||
</button> | ||
) | ||
} | ||
const Button = forwardRef<HTMLButtonElement, Props>( | ||
( | ||
{ | ||
children, | ||
onClick, | ||
className, | ||
buttonType = "secondary", | ||
disabled = false, | ||
iconRight, | ||
iconLeft, | ||
height = 40, | ||
width, | ||
padding = 10, | ||
margin, | ||
loading, | ||
style, | ||
...props | ||
}, | ||
ref | ||
) => { | ||
return ( | ||
<button | ||
ref={ref} | ||
className={clsx(styles.button, className, { | ||
[styles.primary]: buttonType === "primary", | ||
[styles.secondary]: buttonType === "secondary" | ||
})} | ||
disabled={disabled || loading} | ||
onClick={onClick} | ||
style={{ height, width, margin, padding, ...style }} | ||
{...props} | ||
> | ||
{children && iconLeft && ( | ||
<span className={clsx(styles.icon, styles.iconLeft)}>{iconLeft}</span> | ||
)} | ||
{!loading && | ||
(children ? ( | ||
children | ||
) : ( | ||
<span className={styles.icon}>{iconLeft || iconRight}</span> | ||
))} | ||
{loading && ( | ||
<span | ||
style={{ | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center" | ||
}} | ||
> | ||
<Spinner /> | ||
</span> | ||
)} | ||
{children && iconRight && ( | ||
<span className={clsx(styles.icon, styles.iconRight)}> | ||
{iconRight} | ||
</span> | ||
)} | ||
</button> | ||
) | ||
} | ||
) | ||
|
||
export default Button |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.