generated from timelessco/next-ts-app-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): ✨ add nextra with initial set of docs
- Loading branch information
1 parent
23beaf2
commit 62eec35
Showing
41 changed files
with
5,673 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { SiGithub, SiStorybook } from "react-icons/si"; | ||
import { Link } from "@renderlesskit/react"; | ||
import { Button, ButtonGroup } from "@renderlesskit/react-tailwind"; | ||
|
||
type ComponentLinkProps = { | ||
github: string; | ||
story: string; | ||
theme: string; | ||
}; | ||
|
||
const ComponentLinks: React.FC<ComponentLinkProps> = ({ | ||
github, | ||
story, | ||
theme, | ||
}) => { | ||
const githubBase = | ||
"https://github.com/timelessco/renderlesskit-react-tailwind/tree/main/src/"; | ||
const themeBase = | ||
"https://github.com/timelessco/renderlesskit-react-tailwind/tree/main/src/theme/defaultTheme/"; | ||
const storybookBase = | ||
"https://renderlesskit-react-tailwind.vercel.app/?path=/story/"; | ||
|
||
return ( | ||
<ButtonGroup size="md" className="mt-5 component-links"> | ||
{github && ( | ||
<Button | ||
as={Link} | ||
isExternal | ||
variant="outline" | ||
className="no-underline" | ||
prefix={<SiGithub />} | ||
href={`${githubBase}${github}`} | ||
> | ||
View source | ||
</Button> | ||
)} | ||
|
||
{theme && ( | ||
<Button | ||
as={Link} | ||
isExternal | ||
variant="outline" | ||
className="no-underline" | ||
prefix={<SiGithub />} | ||
href={`${themeBase}${theme}.ts`} | ||
> | ||
View theme source | ||
</Button> | ||
)} | ||
|
||
{story && ( | ||
<Button | ||
as={Link} | ||
isExternal | ||
variant="outline" | ||
className="no-underline" | ||
prefix={<SiStorybook />} | ||
href={`${storybookBase}${story}`} | ||
> | ||
View storybook | ||
</Button> | ||
)} | ||
</ButtonGroup> | ||
); | ||
}; | ||
|
||
export default ComponentLinks; |
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,154 @@ | ||
import React from "react"; | ||
import { | ||
Popover as ReakitPopover, | ||
PopoverArrow, | ||
PopoverDisclosure, | ||
usePopoverState, | ||
} from "reakit/Popover"; | ||
import { | ||
Box, | ||
Button, | ||
InfoCircleIcon, | ||
useTheme, | ||
} from "@renderlesskit/react-tailwind"; | ||
import { get } from "lodash"; | ||
|
||
import { RegionTable } from "./RegionTable"; | ||
|
||
type PropDef = { | ||
name: string; | ||
themeKey?: string; | ||
required?: boolean; | ||
default?: string | boolean; | ||
type: string; | ||
typeSimple: string; | ||
description?: string; | ||
}; | ||
|
||
type PopoverTypes = { | ||
children: React.ReactNode; | ||
content: React.ReactNode; | ||
label?: string; | ||
}; | ||
const Popover: React.FC<PopoverTypes> = ({ children, content, label }) => { | ||
const popover = usePopoverState({ placement: "top" }); | ||
return ( | ||
<> | ||
<PopoverDisclosure | ||
as={Button} | ||
size="sm" | ||
variant="subtle" | ||
className="mx-2 text-sm" | ||
{...popover} | ||
> | ||
{children} | ||
</PopoverDisclosure> | ||
<ReakitPopover | ||
{...popover} | ||
aria-label={label || ""} | ||
className="max-w-xs px-3 py-3 text-sm text-gray-800 bg-white border-none rounded-md shadow-xl outline-none" | ||
> | ||
<PopoverArrow size="12px" style={{ fill: "white" }} {...popover} /> | ||
{content} | ||
</ReakitPopover> | ||
</> | ||
); | ||
}; | ||
|
||
type PropsTableProps = { | ||
data: PropDef[]; | ||
"aria-label"?: string; | ||
"aria-labelledby"?: string; | ||
}; | ||
|
||
const PropsTable: React.FC<PropsTableProps> = ({ | ||
data, | ||
"aria-label": ariaLabel, | ||
"aria-labelledby": ariaLabelledBy, | ||
}) => { | ||
const theme = useTheme(); | ||
const hasAriaLabel = !!(ariaLabel || ariaLabelledBy); | ||
|
||
const tdStyles = "border-0 border-b-0 border-gray-500"; | ||
const thStyles = `px-2 py-2 text-gray-800 ${tdStyles}`; | ||
const typeStyles = "bg-blue-100 text-blue-800 px-2 py-1"; | ||
|
||
return ( | ||
<RegionTable | ||
className="w-full border-collapse p-left" | ||
aria-label={hasAriaLabel ? ariaLabel : "Component Props"} | ||
aria-labelledby={ariaLabelledBy} | ||
> | ||
<thead> | ||
<tr className="bg-transparent"> | ||
<Box as="th" className={thStyles}> | ||
<p>Prop</p> | ||
</Box> | ||
<Box as="th" className={thStyles}> | ||
<p>Type</p> | ||
</Box> | ||
<Box as="th" className={thStyles}> | ||
<p>Default</p> | ||
</Box> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{data.map( | ||
( | ||
{ | ||
name, | ||
themeKey, | ||
type, | ||
typeSimple, | ||
required, | ||
default: defaultValue, | ||
description, | ||
}, | ||
i, | ||
) => ( | ||
<tr className="bg-transparent" key={`${name}-${i}`}> | ||
<Box as="td" className={tdStyles}> | ||
<code> | ||
{name} | ||
{required ? "*" : null} | ||
</code> | ||
{description && ( | ||
<Popover content={description}> | ||
<InfoCircleIcon aria-label="Prop description" /> | ||
</Popover> | ||
)} | ||
</Box> | ||
<Box as="td" className={tdStyles}> | ||
<code className="text-gray-800"> | ||
{themeKey ? "union" : Boolean(typeSimple) ? typeSimple : type} | ||
</code> | ||
{!!(typeSimple || themeKey) && ( | ||
<Popover | ||
content={ | ||
<code className={typeStyles}> | ||
{themeKey | ||
? Object.keys(get(theme, themeKey)).join(" | ") | ||
: type} | ||
</code> | ||
} | ||
> | ||
<InfoCircleIcon aria-label="See full type" /> | ||
</Popover> | ||
)} | ||
</Box> | ||
<Box as="td" className={tdStyles}> | ||
{!!defaultValue ? ( | ||
<code className="text-gray-800">{defaultValue}</code> | ||
) : ( | ||
"-" | ||
)} | ||
</Box> | ||
</tr> | ||
), | ||
)} | ||
</tbody> | ||
</RegionTable> | ||
); | ||
}; | ||
|
||
export default PropsTable; |
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,21 @@ | ||
import React from "react"; | ||
import { Box, BoxProps } from "@renderlesskit/react-tailwind"; | ||
|
||
export function RegionTable({ | ||
"aria-label": ariaLabel, | ||
"aria-labelledby": ariaLabelledBy, | ||
...props | ||
}: BoxProps) { | ||
return ( | ||
<Box | ||
as="div" | ||
role="region" | ||
aria-label={ariaLabel} | ||
aria-labelledby={ariaLabelledBy} | ||
tabIndex={0} | ||
className="region-table relative mt-8" | ||
> | ||
<Box as="table" className="border-0 outline-none" {...props} /> | ||
</Box> | ||
); | ||
} |
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,8 @@ | ||
const withNextra = require("nextra")({ | ||
theme: "nextra-theme-docs", | ||
themeConfig: "./theme.config.js", | ||
unstable_stork: false, | ||
unstable_staticImage: true, | ||
}); | ||
|
||
module.exports = withNextra({}); |
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,7 +1,13 @@ | ||
import { RenderlesskitProvider } from "@renderlesskit/react-tailwind"; | ||
import type { AppProps } from "next/app"; | ||
|
||
import "@/styles/global.css"; | ||
import "nextra-theme-docs/style.css"; | ||
|
||
export default function MyApp({ Component, pageProps }: AppProps) { | ||
return <Component {...pageProps} />; | ||
return ( | ||
<RenderlesskitProvider> | ||
<Component {...pageProps} /> | ||
</RenderlesskitProvider> | ||
); | ||
} |
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,19 @@ | ||
import Document, { Head, Html, Main, NextScript } from "next/document"; | ||
|
||
class MyDocument extends Document { | ||
render() { | ||
return ( | ||
<Html> | ||
<Head> | ||
<link href="https://rsms.me/inter/inter.css" rel="stylesheet" /> | ||
</Head> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
); | ||
} | ||
} | ||
|
||
export default MyDocument; |
Oops, something went wrong.