@primer/doctocat-nextjs 0.5.1 → 0.5.2-rc.3d762f6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @primer/doctocat-nextjs
2
2
 
3
+ ## 0.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#41](https://github.com/primer/doctocat-nextjs/pull/41) [`e1ffb3a`](https://github.com/primer/doctocat-nextjs/commit/e1ffb3a630c51316a19e25869f731b4ef3660d2b) Thanks [@danielguillan](https://github.com/danielguillan)! - - Updated sidebar styles.
8
+
9
+ - Added active header link as sidebar heading.
10
+ - Made active header the root item of breadcrumbs, if available.
11
+ - Made sidebar group headins link to the index page.
12
+
13
+ - [#39](https://github.com/primer/doctocat-nextjs/pull/39) [`9090a35`](https://github.com/primer/doctocat-nextjs/commit/9090a3516de8657321ff2217e944cca6466ec9a0) Thanks [@danielguillan](https://github.com/danielguillan)! - Updated index pages to use a grid of Cards with thumbnails
14
+
15
+ - [#38](https://github.com/primer/doctocat-nextjs/pull/38) [`e950c9a`](https://github.com/primer/doctocat-nextjs/commit/e950c9af9ad410025437510113172e207e2e30a2) Thanks [@danielguillan](https://github.com/danielguillan)! - Updated Primer Brand library to v0.54.0
16
+
3
17
  ## 0.5.1
4
18
 
5
19
  ### Patch Changes
@@ -1,12 +1,5 @@
1
- .heading a {
2
- color: var(--brand-InlineLink-color-rest);
3
- text-decoration: none;
4
- }
5
-
6
- .heading a:hover {
7
- text-decoration: underline;
8
- }
9
-
10
- .heading a:active {
11
- color: var(--brand-InlineLink-color-pressed);
1
+ .IndexCards {
2
+ --brand-Grid-spacing-column-gap: var(--base-size-24);
3
+ --brand-Grid-spacing-row: var(--base-size-24);
4
+ padding-inline: 0;
12
5
  }
@@ -1,9 +1,9 @@
1
1
  import React from 'react'
2
- import {Heading, Stack, Text} from '@primer/react-brand'
2
+ import {Card, Grid} from '@primer/react-brand'
3
+ import {DocsItem} from '../../../types'
4
+ import {useColorMode} from '../../context/color-modes/useColorMode'
3
5
 
4
- import Link from 'next/link'
5
6
  import styles from './IndexCards.module.css'
6
- import {DocsItem} from '../../../types'
7
7
 
8
8
  type IndexCardsProps = {
9
9
  route: string
@@ -27,23 +27,29 @@ export function IndexCards({route, folderData}: IndexCardsProps) {
27
27
  })
28
28
 
29
29
  const filteredData = onlyDirectChildren.filter(item => item.type === 'doc')
30
+
31
+ const {colorMode} = useColorMode()
32
+
30
33
  return (
31
- <Stack direction="vertical" padding="none" gap="spacious">
34
+ <Grid className={styles.IndexCards}>
32
35
  {filteredData.map((item: DocsItem) => {
33
36
  if (item.type !== 'doc' || !item.frontMatter) return null
34
37
 
38
+ const thumbnailUrl =
39
+ colorMode === 'dark' && item.frontMatter.thumbnail_darkMode
40
+ ? item.frontMatter.thumbnail_darkMode
41
+ : item.frontMatter.thumbnail
42
+
35
43
  return (
36
- <Stack direction="vertical" padding="none" gap="condensed" key={item.frontMatter.title}>
37
- <Heading as="h2" size="6" className={styles.heading}>
38
- <Link href={item.route} legacyBehavior passHref>
39
- {item.frontMatter.title}
40
- </Link>
41
- </Heading>
42
-
43
- {item.frontMatter.description && <Text as="p">{item.frontMatter.description}</Text>}
44
- </Stack>
44
+ <Grid.Column span={{xsmall: 12, small: 12, medium: 12, large: 6, xlarge: 4}} key={item.frontMatter.title}>
45
+ <Card href={item.route} hasBorder>
46
+ <Card.Image src={thumbnailUrl} alt="" aspectRatio="4:3" />
47
+ <Card.Heading>{item.frontMatter.title}</Card.Heading>
48
+ {item.frontMatter.description && <Card.Description>{item.frontMatter.description}</Card.Description>}
49
+ </Card>
50
+ </Grid.Column>
45
51
  )
46
52
  })}
47
- </Stack>
53
+ </Grid>
48
54
  )
49
55
  }
@@ -28,6 +28,8 @@ import '@primer/react-brand/lib/css/main.css'
28
28
  import {normalizePages} from 'nextra/normalize-pages'
29
29
  import {usePathname} from 'next/navigation'
30
30
 
31
+ import {useConfig} from '../../context/useConfig'
32
+
31
33
  import {Header} from '../header/Header'
32
34
  import {IndexCards} from '../index-cards/IndexCards'
33
35
  import {useColorMode} from '../../context/color-modes/useColorMode'
@@ -75,6 +77,9 @@ export function Theme({pageMap, children}: ThemeProps) {
75
77
 
76
78
  // eslint-disable-next-line i18n-text/no-en
77
79
  const siteTitle = process.env.NEXT_PUBLIC_SITE_TITLE || 'Example Site'
80
+ const {headerLinks} = useConfig()
81
+ const activeHeaderLink = headerLinks.find(link => link.isActive)
82
+
78
83
  const isHomePage = route === '/'
79
84
 
80
85
  const activeFile = isHomePage
@@ -133,7 +138,7 @@ export function Theme({pageMap, children}: ThemeProps) {
133
138
  <>
134
139
  {activePath.length && (
135
140
  <Breadcrumbs>
136
- {siteTitle && (
141
+ {(activeHeaderLink || siteTitle) && (
137
142
  <Breadcrumbs.Item
138
143
  as={NextLink}
139
144
  href="/"
@@ -141,7 +146,7 @@ export function Theme({pageMap, children}: ThemeProps) {
141
146
  color: 'var(--brand-InlineLink-color-rest)',
142
147
  }}
143
148
  >
144
- {siteTitle}
149
+ {activeHeaderLink ? activeHeaderLink.title : siteTitle}
145
150
  </Breadcrumbs.Item>
146
151
  )}
147
152
  {activePath.map((item, index) => {
@@ -1,3 +1,13 @@
1
+ .Sidebar__title {
2
+ display: block;
3
+ padding: var(--base-size-24) var(--base-size-16) 0;
4
+ }
5
+
6
+ .NavList {
7
+ font-family: var(--brand-fontStack-sansSerif);
8
+ font-size: inherit;
9
+ }
10
+
1
11
  @media (min-width: 768px) {
2
12
  .Sidebar {
3
13
  padding-inline-start: var(--base-size-8);
@@ -5,18 +15,21 @@
5
15
  }
6
16
 
7
17
  .NavList h3 {
8
- font-weight: normal;
9
- text-transform: uppercase;
18
+ color: var(--brand-color-text-default);
19
+ font-size: var(--brand-text-size-100);
10
20
  }
11
21
 
12
- .NavList [data-component='ActionList.Divider'] {
13
- display: none; /* TODO: Find workaround to hide this in component */
22
+ .NavList__Container li a,
23
+ .NavList__Container li button {
24
+ font-size: var(--brand-text-size-200);
25
+ padding-block: 0.5em;
14
26
  }
15
27
 
16
- .NavList h3 {
17
- text-transform: initial;
18
- color: var(--brand-color-text-default);
19
- font-weight: var(--brand-text-subhead-weight-medium);
20
- font-size: var(--brand-text-subhead-size-medium);
21
- line-height: var(--brand-text-subhead-lineHeight-medium);
28
+ .NavList .NavListItem {
29
+ margin-top: var(--base-size-4);
30
+ }
31
+
32
+ .NavList .NavListItem,
33
+ .NavList .NavListItem a {
34
+ font-size: inherit;
22
35
  }
@@ -1,6 +1,7 @@
1
1
  import React, {useMemo} from 'react'
2
2
  import NextLink from 'next/link'
3
3
  import {NavList} from '@primer/react'
4
+ import {Text} from '@primer/react-brand'
4
5
  import type {Folder, MdxFile, PageMapItem} from 'nextra'
5
6
 
6
7
  import styles from './Sidebar.module.css'
@@ -20,7 +21,8 @@ type SidebarProps = {
20
21
 
21
22
  export function Sidebar({pageMap}: SidebarProps) {
22
23
  const pathname = usePathname()
23
- const {sidebarLinks} = useConfig()
24
+ const {headerLinks, sidebarLinks} = useConfig()
25
+ const activeHeaderLink = headerLinks.find(link => link.isActive)
24
26
 
25
27
  /**
26
28
  * Sorts the incoming data so that folders with a menu-position frontmatter value
@@ -46,6 +48,12 @@ export function Sidebar({pageMap}: SidebarProps) {
46
48
 
47
49
  return (
48
50
  <div className={styles.Sidebar}>
51
+ {activeHeaderLink && (
52
+ <Text size="400" weight="semibold" className={styles.Sidebar__title}>
53
+ {activeHeaderLink.title}
54
+ </Text>
55
+ )}
56
+
49
57
  <NavList className={styles.NavList} aria-label="Menu links">
50
58
  {reorderedPageMap.map(item => {
51
59
  if (item.hasOwnProperty('data')) return null
@@ -70,6 +78,9 @@ export function Sidebar({pageMap}: SidebarProps) {
70
78
 
71
79
  return (
72
80
  <NavList.Group title={subNavName} key={item.name} sx={{mb: 24}}>
81
+ <NavList.GroupHeading as="h3">
82
+ <NextLink href={item.route}>{subNavName}</NextLink>
83
+ </NavList.GroupHeading>
73
84
  {item.children
74
85
  .sort((a, b) => ((a as MdxFile).name === 'index' ? -1 : (b as MdxFile).name === 'index' ? 1 : 0)) // puts index page first
75
86
  // only show index page if it has show-tabs
@@ -85,6 +96,7 @@ export function Sidebar({pageMap}: SidebarProps) {
85
96
  key={name}
86
97
  href={route}
87
98
  aria-current={route === cleanPathname ? 'page' : undefined}
99
+ className={styles.NavListItem}
88
100
  >
89
101
  {(child as MdxFile).frontMatter?.title || name}
90
102
  </NavList.Item>
@@ -110,6 +122,7 @@ export function Sidebar({pageMap}: SidebarProps) {
110
122
  href={landingPageItem.route}
111
123
  sx={{textTransform: 'capitalize'}}
112
124
  aria-current={isCurrentOrChild ? 'page' : undefined}
125
+ className={styles.NavListItem}
113
126
  >
114
127
  {landingPageItem.frontMatter?.title || item.name}
115
128
  </NavList.Item>
@@ -129,6 +142,7 @@ export function Sidebar({pageMap}: SidebarProps) {
129
142
  href={link.href}
130
143
  {...(link.isExternal && {target: '_blank', rel: 'noopener noreferrer'})}
131
144
  aria-current={link.isActive ? 'page' : undefined}
145
+ className={styles.NavListItem}
132
146
  >
133
147
  {link.title}
134
148
  {link.isExternal && (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/doctocat-nextjs",
3
- "version": "0.5.1",
3
+ "version": "0.5.2-rc.3d762f6",
4
4
  "description": "A Next.js theme for building Primer documentation sites",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  "@next/mdx": "15.2.4",
21
21
  "@primer/octicons-react": "19.15.1",
22
22
  "@primer/react": "^37.11.0",
23
- "@primer/react-brand": "0.49.0",
23
+ "@primer/react-brand": "0.54.0",
24
24
  "@types/lodash.debounce": "^4.0.9",
25
25
  "framer-motion": "12.4.0",
26
26
  "lodash.debounce": "^4.0.8",
package/types.ts CHANGED
@@ -38,4 +38,6 @@ export type FrontMatter = {
38
38
  timestamp?: number
39
39
  title?: string
40
40
  [key: string]: unknown
41
+ thumbnail?: string
42
+ thumbnail_darkMode?: string
41
43
  }