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

Fix table of contents instances #762

Merged
merged 8 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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
30 changes: 0 additions & 30 deletions docs/Outline.js

This file was deleted.

13 changes: 1 addition & 12 deletions docs/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ import React from 'react'
import {Link} from '@primer/components'
import {MarkdownHeading} from '@primer/blueprints'
import {CodeExample} from '@primer/blueprints/next-components'
import Outline from './Outline'

export const H1 = props => <MarkdownHeading {...props} />
export const H2 = props => <MarkdownHeading as="h2" {...props} />
export const H3 = props => <MarkdownHeading as="h3" {...props} />
export const H4 = props => <MarkdownHeading as="h4" {...props} />
export const H5 = props => <MarkdownHeading as="h5" {...props} />

export default function getComponents(page = {}) {
const {outline: getOutline = () => []} = page

export default function getComponents() {
shawnbot marked this conversation as resolved.
Show resolved Hide resolved
return {
h1: H1,
h2: H2,
Expand All @@ -23,14 +20,6 @@ export default function getComponents(page = {}) {
a: Link,
// render code blocks with our wrapper around react-live
code: CodeExample,
// render the outline for <p> tags with exactly the text "{:toc}"
p: ({children, ...rest}) => {
if (children === '{:toc}') {
return <Outline outline={getOutline()} {...rest} />
} else {
return <p {...rest}>{children}</p>
}
},
// "unwrap" <pre> elements around <code> blocks
pre: props => props.children
}
Expand Down
3 changes: 1 addition & 2 deletions pages/css/components/avatars.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: avatars

Avatars are images that users can set as their profile picture. On GitHub, they're always going to be rounded squares. They can be custom photos, uploaded by users, or generated as Identicons as a placeholder.

{:toc}
## Table of Contents

## Basic example

Expand Down Expand Up @@ -154,4 +154,3 @@ For specific cases where two badges or more need to be shown as related or conne
</ul>
</div>
```

2 changes: 1 addition & 1 deletion pages/css/components/box.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bundle: box

The `.Box` component can be used for something as simple as a rounded corner box, or more complex lists and forms. It includes optional modifiers for padding density and color themes.

{:toc}
## Table of Contents

## Box

Expand Down
2 changes: 1 addition & 1 deletion pages/css/components/buttons.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: buttons

Buttons are used for **actions**, like in forms, while textual hyperlinks are used for **destinations**, or moving from one page to another.

{:toc}
## Table of Contents

## Default button

Expand Down
2 changes: 1 addition & 1 deletion pages/css/components/dropdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ symbols: [active, anim-scale-in, btn-link, dropdown, dropdown-caret, dropdown-di

Dropdowns are lightweight, JavaScript-powered context menus for housing navigation and actions. They're great for instances where you don't need the full power (and code) of the select menu.

{:toc}
## Table of Contents

## Basic examples

Expand Down
2 changes: 1 addition & 1 deletion pages/css/components/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: forms

Style individual form controls and utilize common layouts.

{:toc}
## Table of Contents

Overview:
- We reset several elements' default styles for cross browser consistency and easier manipulation later. This includes `<fieldset>`s, WebKit validation bubbles, and most textual `<input>`s.
Expand Down
2 changes: 1 addition & 1 deletion pages/css/components/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bundle: labels
Labels add metatdata or indicate status of items and navigational elements. Three different types of labels are available: [Labels](#default-label-styles) for adding metadata, [States](#states) for indicating status, and [Counters](#counters) for showing the count for a number of items.


{:toc}
## Table of Contents

## Labels

Expand Down
2 changes: 1 addition & 1 deletion pages/css/components/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: navigation

Primer CSS comes with several navigation components. Some were designed with singular purposes, while others were design to be more flexible and appear quite frequently.

{:toc}
## Table of Contents

## Menu

Expand Down
2 changes: 1 addition & 1 deletion pages/css/components/pagehead.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ symbols: [account-switcher, active, admin, avatar, dropdown-menu-content, experi

Give a page a clear, separated title and optional top nav by adding a `.pagehead`.

{:toc}
## Table of Contents

## Basic pagehead

Expand Down
2 changes: 1 addition & 1 deletion pages/css/components/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: pagination

Use the pagination component to apply button styles to a connected set of links that go to related pages (for example, previous, next, or page numbers).

{:toc}
## Table of Contents

## Previous/next pagination

Expand Down
2 changes: 1 addition & 1 deletion pages/css/components/popover.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: popover

Popovers are used to bring attention to specific user interface elements, typically to suggest an action or to guide users through a new experience.

{:toc}
## Table of Contents

A popover consist of:

Expand Down
2 changes: 1 addition & 1 deletion pages/css/components/select-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ symbols: [active, close-button, css-truncate-target, description, description-in

The select menu provides advanced support for navigation, filtering, and more. Any popover within a select menu can make use of JavaScript-enabled live filtering, selected states, tabbed lists, and keyboard navigation with a bit of markup.

{:toc}
## Table of Contents

## Basic example

Expand Down
2 changes: 1 addition & 1 deletion pages/css/components/tooltips.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: tooltips

Add tooltips built entirely in CSS to nearly any element.

{:toc}
## Table of Contents

## Implementation and accessibility

Expand Down
2 changes: 1 addition & 1 deletion pages/css/getting-started/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ The source option will let you point the document to the source file. **This is

#### Tables of contents

In the style guide you can add a `{:toc}` tag to have a table of contents automatically generated.
In the style guide you can add a `## Table of Contents` heading to have a table of contents automatically generated.

#### Code blocks

Expand Down
2 changes: 1 addition & 1 deletion pages/css/objects/grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: layout

The grid is 12 columns and percentage-based. The number of columns a container spans can be adjusted across breakpoints for responsive layouts. The grid system works with a variety of layout utilities to achieve different results.

{:toc}
## Table of Contents

## Float based grid

Expand Down
2 changes: 1 addition & 1 deletion pages/css/principles/accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ path: principles/accessibility

Accessibility is everyone’s responsibility, and the purpose of this document is to provide general accessibility guidelines to developers and designers.

{:toc}
## Table of Contents

## Overview

Expand Down
2 changes: 1 addition & 1 deletion pages/css/principles/html.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: HTML
path: principles/html
---

{:toc}
## Table of Contents

## General formatting

Expand Down
2 changes: 1 addition & 1 deletion pages/css/principles/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ path: principles/index

The CSS styleguide enables us to create a consistent user experience across GitHub, manage CSS bloat, and make our CSS easier to maintain. These principles should serve as guidelines for how we write and use CSS.

{:toc}
## Table of Contents


## Styleguide driven design and development
Expand Down
2 changes: 1 addition & 1 deletion pages/css/principles/scss.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: SCSS
path: priniciples/scss
---

{:toc}
## Table of Contents

## Spacing

Expand Down
2 changes: 1 addition & 1 deletion pages/css/support/breakpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: 'https://github.com/primer/css/blob/master/src/support/variables/layout.
bundle: support
---

{:toc}
## Table of Contents

Our breakpoints are based on screen widths where our content starts to break. Since most of GitHub is currently a fixed-width with we use pixel widths to make it easy for us to match page widths for responsive and non-responsive pages. **Our breakpoints may change as we move more of the product into responsive layouts.**

Expand Down
2 changes: 1 addition & 1 deletion pages/css/support/color-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package:
import {BorderBox, Box, Flex, Heading, Text} from '@primer/components'
import {ColorPalette, ColorVariables} from '../../../docs/color-system'

{:toc}
## Table of Contents

## Color palette

Expand Down
2 changes: 1 addition & 1 deletion pages/css/support/spacing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: 'https://github.com/primer/css/blob/master/src/support/variables/layout.
bundle: support
---

{:toc}
## Table of Contents

## Spacing scale
The spacing scale is a **base-8** scale. We chose a base-8 scale because eight is a highly composable number (it can be divided and multiplied many times and result in whole numbers), yet allows spacing dense enough for GitHub's UI. The scale's exception is that it begins at 4px to allow smaller padding and margin for denser parts of the site, from there on it steps up consistently in equal values of `8px`.
Expand Down
2 changes: 1 addition & 1 deletion pages/css/support/typography.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source: 'https://github.com/primer/css/blob/master/src/support/variables/typogra
bundle: support
---

{:toc}
## Table of Contents

## Type Scale

Expand Down
2 changes: 1 addition & 1 deletion pages/css/tools/atom-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ We keep a list of suggested packages in our [atom-packages repository](https://g
apm install $(curl -L https://raw.githubusercontent.com/primer/atom-packages/master/packages)
```

{:toc}
## Table of Contents

## Autocomplete Primer

Expand Down
2 changes: 1 addition & 1 deletion pages/css/tools/linting.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ For teams working on `github/github` this configuration is all setup for you. Wh

For everyone else we encourage you to adopt all or some of these tools in your workflow.

{:toc}
## Table of Contents

## CSS

Expand Down
2 changes: 1 addition & 1 deletion pages/css/utilities/animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: utilities

Animations are reusable animation classes that you can use to emphasize an element. All of these animations will animate if you toggle their visibility using the "Toggle" button.

{:toc}
## Table of Contents

## Fade In

Expand Down
2 changes: 1 addition & 1 deletion pages/css/utilities/borders.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: utilities

Utilities for borders, border radius, and box shadows.

{:toc}
## Table of Contents

## Default border

Expand Down
2 changes: 1 addition & 1 deletion pages/css/utilities/box-shadow.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: utilities

Box shadows are used to make content appear elevated. They are typically applied to containers of content that users need to pay attention to or content that appears on top of (overlapping) other elements on the page (like a pop-over or modal).

{:toc}
## Table of Contents

## Default

Expand Down
2 changes: 1 addition & 1 deletion pages/css/utilities/details.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bundle: utilities

Details classes are created to enhance the native behaviors of `<details>`.

{:toc}
## Table of Contents

## Fullscreen click area

Expand Down
2 changes: 1 addition & 1 deletion pages/css/utilities/flexbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: utilities

Flex utilities can be used to apply `flexbox` behaviors to elements by using utility classes.

{:toc}
## Table of Contents

## Required reading

Expand Down
2 changes: 1 addition & 1 deletion pages/css/utilities/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bundle: utilities

Change the document layout with display, float, alignment, and other utilities.

{:toc}
## Table of Contents

## Display
Adjust the display of an element with `.d-block`, `.d-none`, `.d-inline`, `.d-inline-block`, `.d-table`, `.d-table-cell` utilities.
Expand Down
2 changes: 1 addition & 1 deletion pages/css/utilities/margin.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bundle: utilities

Margin utilities are based on a global [spacing scale](/css/support/spacing) which helps keep horizontal and vertical spacing consistent. These utilities help us reduce the amount of custom CSS that share the same properties, and allows to achieve many different page layouts using the same styles.

{:toc}
## Table of Contents

## Naming convention

Expand Down
2 changes: 1 addition & 1 deletion pages/css/utilities/marketing-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bundle: marketing-utilities

Marketing layout utilities build on top of [primer-core utilities](/css/utilities/layout#position), adding the option of responsive positioning.

{:toc}
## Table of Contents

## Position elements with spacing utilities

Expand Down
2 changes: 1 addition & 1 deletion pages/css/utilities/padding.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bundle: utilities

Padding utilities are based on a global [spacing scale](/css/support/spacing) which helps keep horizontal and vertical spacing consistent. These utilities help us reduce the amount of custom CSS that could share the same properties, and allows to achieve many different page layouts using the same styles.

{:toc}
## Table of Contents

## Shorthand

Expand Down
2 changes: 1 addition & 1 deletion pages/css/utilities/typography.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bundle: utilities

Type utilities are designed to work in combination with line-height utilities so as to result in more sensible numbers wherever possible. These also exist as [variables](/css/support/typography#typography-variables) that you can use in components or custom CSS.

{:toc}
## Table of Contents

Font sizes are smaller on mobile and scale up at the `md` [breakpoint](/css/support/breakpoints) to be larger on desktop.

Expand Down