Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

64 docs add badge links to sources for components #65

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cSpell.words": [
"csstools",
"frontmatter",
"nextjs",
"omni",
"oxlint",
Expand Down
76 changes: 76 additions & 0 deletions docs/app/components/ApiLinks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { css } from '@/styled-system/css'
import { hstack } from '@/styled-system/patterns'
import { LogoGithub, LogoNpm } from '@cerberus-design/icons'
import { Show } from '@cerberus-design/react'

const apiLinkStyles = css({
alignItems: 'center',
border: '1px solid',
borderColor: 'action.border.100',
bgColor: 'action.bg.100.initial',
display: 'inline-flex',
gap: '2',
pxi: '2',
rounded: 'full',
textStyle: 'body-xs',
textDecoration: 'none',
transition: 'all 200ms ease-in-out',
_hover: {
bgColor: 'action.navigation.hover',
color: 'neutral.text.inverse !important',
textStyle: 'link',
},
})

interface ApiLinksProps {
npm?: string
source?: string
recipe?: string
}

export default function ApiLinks(props: ApiLinksProps) {
return (
<ul
className={hstack({
gap: '4',
mb: '8',
})}
>
<Show when={Boolean(props.npm)}>
<li>
<a
className={apiLinkStyles}
href={`https://www.npmjs.com/package/${props.npm}`}
>
<LogoNpm />
npm
</a>
</li>
</Show>

<Show when={Boolean(props.source)}>
<li>
<a
className={apiLinkStyles}
href={`https://github.com/omnifed/cerberus/blob/main/packages/react/src/${props.source}`}
>
<LogoGithub />
source
</a>
</li>
</Show>

<Show when={Boolean(props.recipe)}>
<li>
<a
className={apiLinkStyles}
href={`https://github.com/omnifed/cerberus/tree/main/packages/panda-preset/src/recipes/${props.recipe}`}
>
<LogoGithub />
recipe
</a>
</li>
</Show>
</ul>
)
}
34 changes: 27 additions & 7 deletions docs/app/components/RootHeadline.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
'use client'

import { css } from '@/styled-system/css'
import { useThemeContext } from '@cerberus-design/react'
import { css, cx } from '@/styled-system/css'
import { Show, useThemeContext } from '@cerberus-design/react'
import { Splash } from 'next/font/google'

const rootHeadlineText = {
light: 'The cutest protector of brand consistency in the realm.',
dark: 'The most vicious protector of brand consistency in the realm.',
}
const splash = Splash({
display: 'swap',
subsets: ['latin'],
weight: ['400'],
})

export default function RootHeadline() {
const { mode } = useThemeContext()
Expand All @@ -16,9 +18,27 @@ export default function RootHeadline() {
className={css({
lineHeight: '135%',
textStyle: 'display-lg',
textWrap: 'pretty',
})}
>
{rootHeadlineText[mode]}
<Show
when={mode === 'dark'}
fallback={<>The cutest protector of brand consistency in the realm.</>}
>
The{' '}
<span
className={cx(
splash.className,
css({
color: 'danger.bg.initial',
fontSize: '7rem',
}),
)}
>
most vicious
</span>{' '}
protector of brand consistency in the realm.
</Show>
</h1>
)
}
6 changes: 6 additions & 0 deletions docs/app/global.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
declare module 'color-space'

declare module '*.mdx' {
let MDXComponent: (props: any) => JSX.Element
export const frontmatter: Record<string, string>
export default MDXComponent
}
89 changes: 84 additions & 5 deletions docs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,95 @@
import { vstack } from '@/styled-system/patterns'
import { grid, gridItem, vstack } from '@/styled-system/patterns'
import RootHeadline from './components/RootHeadline'
import { Image as ImageIcon } from '@cerberus-design/icons'
import { css } from '@/styled-system/css'
import Link from 'next/link'

export default function Home() {
return (
<div
className={vstack({
className={css({
pxi: '4',
py: '20',
pt: '10',
pb: '20',
})}
>
<main>
<RootHeadline />
<main
className={grid({
gap: '4',
columns: 12,
justifyContent: 'center',
})}
>
<div
className={gridItem({
gridColumnStart: 1,
gridColumnEnd: 13,
md: {
gridColumnStart: 7,
h: '66dvh',
},
})}
>
<div
className={vstack({
bgColor: 'gray',
gap: '0',
justify: 'center',
h: '15rem',
w: 'full',
md: {
h: 'full',
},
})}
>
<ImageIcon size={32} />
</div>
</div>

<div
className={gridItem({
gridColumnStart: 1,
gridColumnEnd: 13,
md: {
alignSelf: 'center',
gridColumnStart: 1,
gridColumnEnd: 6,
gridRowStart: 1,
paddingInlineStart: '6',
},
})}
>
<RootHeadline />
<div
className={css({
mt: '4',
})}
>
<Link
className={css({
alignItems: 'center',
bgColor: 'action.navigation.initial',
color: 'neutral.text.inverse',
display: 'inline-flex',
h: '3.3rem',
justifyContent: 'center',
pxi: '4',
w: 'full',
rounded: 'md',
transition: 'background-color 0.2s ease-in-out',
_hover: {
bgColor: 'action.navigation.hover',
},
md: {
w: 'auto',
},
})}
href="/preset/"
>
Get Started
</Link>
</div>
</div>
</main>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion docs/app/preset/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { Poppins } from 'next/font/google'
const poppins = Poppins({
display: 'swap',
subsets: ['latin'],
weight: ['400', '600', '700', '800'],
weight: ['400', '600', '700'],
})
```

Expand Down
6 changes: 6 additions & 0 deletions docs/app/react/show/doc.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
npm: '@cerberus-design/react'
source: 'components/Show.tsx'
recipe: ''
---

import {
WhenToUseAdmonition,
WhenNotToUseAdmonition,
Expand Down
4 changes: 3 additions & 1 deletion docs/app/react/show/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import ApiLinks from '@/app/components/ApiLinks'
import OnThisPage from '../../components/OnThisPage'
import { PageMainContent, PageSections } from '../../components/PageLayout'
import Doc from './doc.mdx'
import Doc, { frontmatter } from './doc.mdx'

export default function ShowPage() {
return (
<>
<PageMainContent>
<ApiLinks {...frontmatter} />
<main>
<Doc />
</main>
Expand Down
6 changes: 6 additions & 0 deletions docs/app/react/use-theme-context/doc.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
npm: '@cerberus-design/react'
source: 'context/theme.tsx'
recipe: ''
---

import {
WhenToUseAdmonition,
WhenNotToUseAdmonition,
Expand Down
4 changes: 3 additions & 1 deletion docs/app/react/use-theme-context/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import ApiLinks from '@/app/components/ApiLinks'
import OnThisPage from '../../components/OnThisPage'
import { PageMainContent, PageSections } from '../../components/PageLayout'
import UseThemeDoc from './doc.mdx'
import UseThemeDoc, { frontmatter } from './doc.mdx'

export default function UseThemeContextPage() {
return (
<>
<PageMainContent>
<ApiLinks {...frontmatter} />
<main>
<UseThemeDoc />
</main>
Expand Down
6 changes: 6 additions & 0 deletions docs/app/react/use-theme/doc.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
npm: '@cerberus-design/react'
source: 'hooks/useTheme.ts'
recipe: ''
---

import {
WhenToUseAdmonition,
WhenNotToUseAdmonition,
Expand Down
4 changes: 3 additions & 1 deletion docs/app/react/use-theme/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import ApiLinks from '@/app/components/ApiLinks'
import OnThisPage from '../../components/OnThisPage'
import { PageMainContent, PageSections } from '../../components/PageLayout'
import UseThemeDoc from './doc.mdx'
import UseThemeDoc, { frontmatter } from './doc.mdx'

export default function UseThemePage() {
return (
<>
<PageMainContent>
<ApiLinks {...frontmatter} />
<main>
<UseThemeDoc />
</main>
Expand Down
2 changes: 1 addition & 1 deletion docs/app/styles/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { css } from '@/styled-system/css'

const headlineStyles = {
color: 'neutral.text.initial',
pb: '2',
py: '2',
}

export const markdown = css({
Expand Down
10 changes: 9 additions & 1 deletion docs/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import createMDX from '@next/mdx'
import emoji from 'remark-emoji'
import remarkParse from 'remark-parse'
import remarkGfm from 'remark-gfm'
import remarkFrontmatter from 'remark-frontmatter'
import remarkMdxFrontmatter from 'remark-mdx-frontmatter'
import rehypeExpressiveCode from 'rehype-expressive-code'
import rehypeStringify from 'rehype-stringify'
import rehypeSlug from 'rehype-slug'
Expand All @@ -22,7 +24,13 @@ const nextConfig = {

const withMDX = createMDX({
options: {
remarkPlugins: [emoji, remarkParse, remarkGfm],
remarkPlugins: [
emoji,
remarkParse,
remarkGfm,
remarkFrontmatter,
remarkMdxFrontmatter,
],
rehypePlugins: [
[
rehypeExpressiveCode,
Expand Down
2 changes: 2 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
"rehype-slug": "^6.0.0",
"rehype-stringify": "^10.0.0",
"remark-emoji": "^4.0.1",
"remark-frontmatter": "^5.0.0",
"remark-gfm": "^4.0.0",
"remark-mdx-frontmatter": "^4.0.0",
"remark-parse": "^11.0.0"
}
}
3 changes: 3 additions & 0 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"@/*": ["./*"]
}
},
"mdx": {
"plugins": ["remark-frontmatter", "remark-frontmatter-mdx"]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
Loading