-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
305 additions
and
16 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { globalStyle, style } from '@vanilla-extract/css' | ||
|
||
import { fontWeightVars, primitiveColorVars, spaceVars, viewportVars } from '../styles/vars.css.js' | ||
import { root as H2 } from './mdx/H2.css.js' | ||
import { root as H3 } from './mdx/H3.css.js' | ||
import { root as H4 } from './mdx/H4.css.js' | ||
import { root as H5 } from './mdx/H5.css.js' | ||
import { root as H6 } from './mdx/H6.css.js' | ||
import { root as CodeGroup, tabsList } from './mdx/CodeGroup.css.js' | ||
|
||
export const root = style({ | ||
selectors: { | ||
'&:not(:last-child)': { | ||
marginBottom: spaceVars['24'], | ||
}, | ||
}, | ||
}) | ||
|
||
export const title = style( | ||
{ | ||
marginBottom: spaceVars['8'], | ||
position: 'relative', | ||
'::before': { | ||
alignItems: 'center', | ||
backgroundColor: primitiveColorVars.background4, | ||
borderRadius: '100%', | ||
border: `0.5em solid ${primitiveColorVars.background}`, | ||
boxSizing: 'content-box', | ||
color: primitiveColorVars.text2, | ||
content: 'counter(step)', | ||
counterIncrement: 'step', | ||
display: 'flex', | ||
fontSize: '0.625em', | ||
fontWeight: fontWeightVars.regular, | ||
height: '2em', | ||
justifyContent: 'center', | ||
left: 'calc(-25.125px - 1.45em)', | ||
position: 'absolute', | ||
top: '-0.5em', | ||
width: '2em', | ||
}, | ||
}, | ||
'title', | ||
) | ||
|
||
export const content = style( | ||
{ | ||
selectors: { | ||
[`${H2}+&,${H3}+&,${H4}+&,${H5}+&,${H6}+&`]: { | ||
marginTop: `calc(${spaceVars['8']} * -1)`, | ||
}, | ||
}, | ||
}, | ||
'content', | ||
) | ||
|
||
globalStyle(`${content} > *:not(:last-child)`, { | ||
marginBottom: spaceVars['16'], | ||
}) | ||
|
||
globalStyle(`${content} > *:last-child`, { | ||
marginBottom: spaceVars['0'], | ||
}) | ||
|
||
globalStyle(`${content} [data-rehype-pretty-code-fragment]`, { | ||
'@media': { | ||
[viewportVars['max-720px']]: { | ||
borderTop: `6px solid ${primitiveColorVars.background}`, | ||
borderBottom: `6px solid ${primitiveColorVars.background}`, | ||
marginLeft: `calc(-1 * ${spaceVars['28']} - 2px)`, | ||
}, | ||
}, | ||
}) | ||
|
||
globalStyle(`${content} ${CodeGroup}`, { | ||
'@media': { | ||
[viewportVars['max-720px']]: { | ||
marginLeft: 0, | ||
marginRight: 0, | ||
}, | ||
}, | ||
}) | ||
|
||
globalStyle(`${content} ${tabsList}`, { | ||
'@media': { | ||
[viewportVars['max-720px']]: { | ||
borderTop: `6px solid ${primitiveColorVars.background}`, | ||
marginLeft: `calc(-1 * ${spaceVars['44']})`, | ||
marginRight: `calc(-1 * ${spaceVars['16']})`, | ||
}, | ||
}, | ||
}) | ||
|
||
globalStyle(`${content} ${CodeGroup} [data-rehype-pretty-code-fragment]`, { | ||
'@media': { | ||
[viewportVars['max-720px']]: { | ||
borderTop: 'none', | ||
}, | ||
}, | ||
}) |
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,34 @@ | ||
import { type ClassValue, clsx } from 'clsx' | ||
import type { ReactNode } from 'react' | ||
|
||
import * as styles from './Step.css.js' | ||
import { H2 } from './mdx/H2.js' | ||
import { H3 } from './mdx/H3.js' | ||
import { H4 } from './mdx/H4.js' | ||
import { H5 } from './mdx/H5.js' | ||
import { H6 } from './mdx/H6.js' | ||
|
||
export type StepProps = { | ||
children: ReactNode | ||
className?: ClassValue | ||
title: ReactNode | string | ||
titleLevel?: 2 | 3 | 4 | 5 | 6 | ||
} | ||
|
||
export function Step({ children, className, title, titleLevel = 2 }: StepProps) { | ||
const Element = (() => { | ||
if (titleLevel === 2) return H2 | ||
if (titleLevel === 3) return H3 | ||
if (titleLevel === 4) return H4 | ||
if (titleLevel === 5) return H5 | ||
if (titleLevel === 6) return H6 | ||
throw new Error('Invalid.') | ||
})() | ||
|
||
return ( | ||
<div className={clsx(className, styles.root)}> | ||
<Element className={styles.title}>{title}</Element> | ||
<div className={styles.content}>{children}</div> | ||
</div> | ||
) | ||
} |
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,16 @@ | ||
import { style } from '@vanilla-extract/css' | ||
|
||
import { primitiveColorVars, spaceVars, viewportVars } from '../styles/vars.css.js' | ||
|
||
export const root = style({ | ||
borderLeft: `1.5px solid ${primitiveColorVars.border}`, | ||
counterReset: 'step', | ||
paddingLeft: spaceVars['24'], | ||
marginLeft: spaceVars['12'], | ||
marginTop: spaceVars['24'], | ||
'@media': { | ||
[viewportVars['max-720px']]: { | ||
marginLeft: spaceVars['4'], | ||
}, | ||
}, | ||
}) |
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,13 @@ | ||
import { type ClassValue, clsx } from 'clsx' | ||
import type { ReactNode } from 'react' | ||
|
||
import * as styles from './Steps.css.js' | ||
|
||
export type StepsProps = { | ||
children: ReactNode | ||
className?: ClassValue | ||
} | ||
|
||
export function Steps({ children, className }: StepsProps) { | ||
return <div className={clsx(className, styles.root)}>{children}</div> | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { ReactNode } from 'react' | ||
|
||
import { Steps as Steps_ } from '../Steps.js' | ||
import { Step } from '../Step.js' | ||
|
||
export function Steps({ children }: { children: ReactNode }) { | ||
if (!Array.isArray(children)) return null | ||
return ( | ||
<Steps_> | ||
{children.map(({ props }, i) => { | ||
const [title, ...children] = props.children | ||
return ( | ||
<Step | ||
key={i} | ||
title={title.props.children} | ||
titleLevel={parseInt(props['data-depth']) as any} | ||
> | ||
{children} | ||
</Step> | ||
) | ||
})} | ||
</Steps_> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { Callout, type CalloutProps } from './app/components/Callout.js' | ||
export { Steps, type StepsProps } from './app/components/Steps.js' | ||
export { Step, type StepProps } from './app/components/Step.js' |
Oops, something went wrong.