Skip to content

Commit

Permalink
feat(frontmatter): outline, sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Nov 25, 2023
1 parent 7340493 commit c6be4fd
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 69 deletions.
8 changes: 8 additions & 0 deletions site/pages/blank.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
outline: false
# sidebar: false
---

# Blank page

This is a blank page.
23 changes: 23 additions & 0 deletions src/app/components/DesktopTopNav.css.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { style } from '@vanilla-extract/css'
import { leftGutterWidthVar } from '../layouts/DocsLayout.css.js'
import {
borderRadiusVars,
primitiveColorVars,
sidebarVars,
spaceVars,
topNavVars,
viewportVars,
Expand Down Expand Up @@ -69,6 +71,27 @@ export const icon = style(

export const item = style({ alignItems: 'center', display: 'flex', height: '100%' }, 'item')

export const logo = style(
{
paddingLeft: sidebarVars.horizontalPadding,
paddingRight: sidebarVars.horizontalPadding,
width: sidebarVars.width,
},
'logo',
)

export const logoWrapper = style(
{
display: 'flex',
height: '100%',
justifyContent: 'flex-end',
left: 0,
position: 'absolute',
width: leftGutterWidthVar,
},
'logoWrapper',
)

export const section = style(
{ alignItems: 'center', display: 'flex', height: '100%', gap: spaceVars[16] },
'section',
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/DesktopTopNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTheme } from '../hooks/useTheme.js'
import { visibleDark, visibleLight } from '../styles/utils.css.js'
import * as styles from './DesktopTopNav.css.js'
import { Icon } from './Icon.js'
import { Logo } from './Logo.js'
import { Discord } from './icons/Discord.js'
import { GitHub } from './icons/GitHub.js'
import { Moon } from './icons/Moon.js'
Expand All @@ -18,6 +19,11 @@ export function DesktopTopNav() {
const config = useConfig()
return (
<div className={styles.root}>
<div className={styles.logoWrapper}>
<div className={styles.logo}>
<Logo />
</div>
</div>
<div className={styles.section} />
<div className={styles.section}>
{config.socials && (
Expand Down
29 changes: 29 additions & 0 deletions src/app/components/Logo.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { globalStyle, style } from '@vanilla-extract/css'
import { fontSizeVars, fontWeightVars, lineHeightVars } from '../styles/vars.css.js'

export const logoImage = style(
{
height: '30%',
width: 'max-content',
},
'logoImage',
)

export const logoDark = style({}, 'logoDark')
globalStyle(`:root:not(.dark) ${logoDark}`, {
display: 'none',
})

export const logoLight = style({}, 'logoLight')
globalStyle(`:root.dark ${logoLight}`, {
display: 'none',
})

export const title = style(
{
fontSize: fontSizeVars['18'],
fontWeight: fontWeightVars.semibold,
lineHeight: lineHeightVars.heading,
},
'title',
)
35 changes: 35 additions & 0 deletions src/app/components/Logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import clsx from 'clsx'
import { Link } from 'react-router-dom'

import { useConfig } from '../hooks/useConfig.js'
import * as styles from './Logo.css.js'

export function Logo() {
const config = useConfig()
return (
<Link to="/" style={{ alignItems: 'center', display: 'flex', height: '100%' }}>
{config.logoUrl ? (
<>
{typeof config.logoUrl === 'string' ? (
<img alt="Logo" className={styles.logoImage} src={config.logoUrl} />
) : (
<>
<img
alt="Logo"
className={clsx(styles.logoImage, styles.logoDark)}
src={config.logoUrl.dark}
/>
<img
alt="Logo"
className={clsx(styles.logoImage, styles.logoLight)}
src={config.logoUrl.light}
/>
</>
)}
</>
) : (
<div className={styles.title}>{config.title}</div>
)}
</Link>
)
}
45 changes: 16 additions & 29 deletions src/app/components/Sidebar.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ export const root = style({
},
})

export const divider = style(
{
backgroundColor: primitiveColorVars.border,
width: '100%',
height: '1px',
},
'divider',
)

export const item = style(
{
color: primitiveColorVars.text3,
Expand Down Expand Up @@ -52,36 +61,23 @@ export const items = style(
export const logo = style(
{
alignItems: 'center',
borderBottom: `1px solid ${primitiveColorVars.border}`,
display: 'flex',
height: topNavVars.height,
'@media': {
'screen and (max-width: 1080px)': {
display: 'none',
},
},
},
'logo',
)

export const logoImage = style(
export const logoWrapper = style(
{
height: '30%',
width: 'max-content',
'@media': {
'screen and (max-width: 1080px)': {
display: 'none',
},
},
},
'logoImage',
'logoWrapper',
)

export const logoDark = style({}, 'logoDark')
globalStyle(`:root:not(.dark) ${logoDark}`, {
display: 'none',
})

export const logoLight = style({}, 'logoLight')
globalStyle(`:root.dark ${logoLight}`, {
display: 'none',
})

export const navigation = style(
{
selectors: {
Expand Down Expand Up @@ -151,12 +147,3 @@ export const socials = style(
},
'socials',
)

export const title = style(
{
fontSize: fontSizeVars['18'],
fontWeight: fontWeightVars.semibold,
lineHeight: lineHeightVars.heading,
},
'title',
)
33 changes: 8 additions & 25 deletions src/app/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Link, useMatch } from 'react-router-dom'
import type { ParsedSocialItem } from '../../config.js'
import { useConfig } from '../hooks/useConfig.js'
import { Icon } from './Icon.js'
import { Logo } from './Logo.js'
import * as styles from './Sidebar.css.js'
import { Discord } from './icons/Discord.js'
import { GitHub } from './icons/GitHub.js'
Expand All @@ -20,31 +21,13 @@ export function Sidebar({
if (!sidebar) return null
return (
<aside className={clsx(styles.root, className)}>
<div className={styles.logo}>
<Link to="/" style={{ alignItems: 'center', display: 'flex', height: '100%' }}>
{config.logoUrl ? (
<>
{typeof config.logoUrl === 'string' ? (
<img alt="Logo" className={styles.logoImage} src={config.logoUrl} />
) : (
<>
<img
alt="Logo"
className={clsx(styles.logoImage, styles.logoDark)}
src={config.logoUrl.dark}
/>
<img
alt="Logo"
className={clsx(styles.logoImage, styles.logoLight)}
src={config.logoUrl.light}
/>
</>
)}
</>
) : (
<div className={styles.title}>{config.title}</div>
)}
</Link>
<div className={styles.logoWrapper}>
<div className={styles.logo}>
<Link to="/" style={{ alignItems: 'center', display: 'flex', height: '100%' }}>
<Logo />
</Link>
</div>
<div className={styles.divider} />
</div>
<nav className={styles.navigation}>
<section className={styles.section}>
Expand Down
2 changes: 1 addition & 1 deletion src/app/hooks/usePageData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, createContext } from 'react'
import { createContext, useContext } from 'react'

import { type Module } from '../types.js'

Expand Down
47 changes: 42 additions & 5 deletions src/app/layouts/DocsLayout.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
zIndexVars,
} from '../styles/vars.css.js'

const leftGutterWidthVar = createVar('leftGutterWidth')
export const leftGutterWidthVar = createVar('leftGutterWidth')

export const root = style({
vars: {
Expand All @@ -19,7 +19,8 @@ export const root = style({

export const content = style(
{
marginLeft: leftGutterWidthVar,
marginLeft: 'auto',
marginRight: 'auto',
maxWidth: contentVars.width,
minHeight: `calc(100vh - (${topNavVars.height} + ${topNavVars.curtainHeight}))`,
'@media': {
Expand All @@ -35,6 +36,14 @@ export const content = style(
'content',
)

export const content_withSidebar = style(
{
marginLeft: leftGutterWidthVar,
marginRight: 'unset',
},
'content_withSidebar',
)

export const gutterLeft = style(
{
backgroundColor: primitiveColorVars.backgroundDark,
Expand All @@ -61,7 +70,7 @@ export const gutterTop = style(
zIndex: zIndexVars.gutterTop,
'@media': {
[viewportVars['min-1080px']]: {
paddingLeft: leftGutterWidthVar,
paddingLeft: `calc(${leftGutterWidthVar} - ${sidebarVars.width})`,
paddingRight: `calc(${leftGutterWidthVar} - ${sidebarVars.width})`,
position: 'fixed',
top: 0,
Expand All @@ -74,6 +83,17 @@ export const gutterTop = style(
'gutterTop',
)

export const gutterTop_withSidebar = style(
{
'@media': {
[viewportVars['min-1080px']]: {
paddingLeft: leftGutterWidthVar,
},
},
},
'gutterTop_withSidebar',
)

export const gutterTopCurtain = style(
{
display: 'flex',
Expand All @@ -82,7 +102,6 @@ export const gutterTopCurtain = style(
zIndex: zIndexVars.gutterTop,
'@media': {
[viewportVars['min-1080px']]: {
marginLeft: leftGutterWidthVar,
position: 'fixed',
top: topNavVars.height,
},
Expand All @@ -95,6 +114,17 @@ export const gutterTopCurtain = style(
'gutterTopCurtain',
)

export const gutterTopCurtain_withSidebar = style(
{
'@media': {
[viewportVars['min-1080px']]: {
marginLeft: leftGutterWidthVar,
},
},
},
'gutterTopCurtain_withSidebar',
)

export const gutterRight = style(
{
display: 'flex',
Expand All @@ -104,7 +134,7 @@ export const gutterRight = style(
position: 'fixed',
top: '0',
right: '0',
width: `calc(100vw - ${contentVars.width} - ${leftGutterWidthVar})`,
width: `calc((100vw - ${contentVars.width}) / 2)`,
zIndex: zIndexVars.gutterRight,
'@media': {
[viewportVars['max-1280px']]: {
Expand All @@ -115,6 +145,13 @@ export const gutterRight = style(
'gutterRight',
)

export const gutterRight_withSidebar = style(
{
width: `calc(100vw - ${contentVars.width} - ${leftGutterWidthVar})`,
},
'gutterRight_withSidebar',
)

export const outlinePopover = style(
{
display: 'none',
Expand Down
Loading

0 comments on commit c6be4fd

Please sign in to comment.