import React from 'react'
import ReactDomServer from 'react-dom/server'
import { BumpLink, BumpLinkPropsT } from 'components/ui/BumpLink/BumpLink'
import { Callout, CalloutPropsT } from 'components/ui/Callout/Callout'
import {
MarkdownContent,
MarkdownContentPropsT,
} from 'components/ui/MarkdownContent/MarkdownContent'
const markdownExample = (
<>
Header Level 1: Steps example
- Start with step 1
- Continue with step 2
- Finish with step 3
Header Level 2: Highlighted code example
steps:
{'\n'}
- uses:{' '}
actions/checkout@v2
{'\n'}
- uses:{' '}
actions/setup-java@v2
{'\n '}
with:
{'\n '}
java-version: '11'
{'\n '}
distribution:{' '}
'adopt'
Header Level 3: Table example
Qualifier |
Example |
sort:interactions or sort:interactions-desc
|
org:github sort:interactions
{' '}
matches issues in repositories owned by GitHub, sorted by the highest combined number of
reactions and comments.
|
sort:interactions-asc
|
org:github sort:interactions-asc
{' '}
matches issues in repositories owned by GitHub, sorted by the lowest combined number of
reactions and comments.
|
Header Level 4: Procedural image example
>
)
const stories = [
{
name: 'BumpLink',
component: BumpLink,
variants: [
{ title: 'Think basic', href: 'http://example.com' } as BumpLinkPropsT,
{
title: 'Think different',
href: 'http://example.com',
children: 'This is child text',
} as BumpLinkPropsT,
{
as: 'div',
title: 'Think as div',
href: 'http://example.com',
className: 'color-bg-warning',
} as BumpLinkPropsT,
],
},
{
name: 'Callout', // {component.name} gets optimized away
component: Callout,
variants: [
{ variant: 'success', children: 'Yay you did it!', className: '' } as CalloutPropsT,
{ variant: 'info', children: 'Captain I have information.', className: '' } as CalloutPropsT,
{ variant: 'warning', children: 'Warning... warning...', className: '' } as CalloutPropsT,
{ variant: 'success', children: 'I am a little font', className: 'f6' } as CalloutPropsT,
],
},
{
name: 'MarkdownContent',
component: MarkdownContent,
variants: [{ children: markdownExample } as MarkdownContentPropsT],
},
]
function displayProps(props: Object) {
const xprops = Object.fromEntries(
Object.entries(props).map(([key, value]) => [
key,
key === 'children' ? ReactDomServer.renderToString(value) : value,
])
)
return JSON.stringify(xprops, null, 2)
}
export default function Storybook() {
return (
GitHub Docs Storybook
This page lists React components unique to the GitHub docs.
{stories.map(({ name, component, variants }) => (
{name}
{variants.map((props) => (
{/* @ts-ignore */}
{React.createElement(component, props)}
{displayProps(props)}
))}
))}
)
}