1
1
mirror of https://github.com/primer/css.git synced 2024-11-27 17:52:45 +03:00

fix table of contents instances

This commit is contained in:
emplums 2019-04-22 15:06:23 -07:00
parent 6a8733ea0f
commit 5f4d689974
36 changed files with 34 additions and 76 deletions

View File

@ -1,30 +0,0 @@
import React from 'react'
import {Box} from '@primer/components'
export default function Outline({outline, ...rest}) {
if (outline && outline.length) {
return (
<Box as="details" mb={4}>
<summary>Table of contents</summary>
<OutlineList items={outline} {...rest} />
</Box>
)
}
return null
}
export function OutlineList({items, ...rest}) {
if (items && items.length) {
return (
<ul {...rest}>
{items.map(item => (
<li key={item.id}>
<a href={`#${item.id}`}>{item.title}</a>
<OutlineList items={item.children} />
</li>
))}
</ul>
)
}
return null
}

View File

@ -1,27 +1,16 @@
import React from 'react'
import {Heading, Link} from '@primer/components'
import {CodeExample} from '@primer/blueprints'
import Outline from './Outline'
export const H1 = props => <Heading fontSize={6} fontWeight="light" {...props} />
export default function getComponents(page = {}) {
const {outline: getOutline = () => []} = page
return {
h1: H1,
// render links with our component
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
}

View File

@ -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
@ -154,4 +154,3 @@ For specific cases where two badges or more need to be shown as related or conne
</ul>
</div>
```

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -9,7 +9,7 @@ bundle: navigation
Primer 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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -9,7 +9,7 @@ bundle: tooltips
Add tooltips built entirely in CSS to nearly any element.
{:toc}
## Table of Contents
## Implementation and accessibility

View File

@ -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

View File

@ -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

View File

@ -5,7 +5,7 @@ path: principles/accessibility
Accessibility is everyones responsibility, and the purpose of this document is to provide general accessibility guidelines to developers and designers.
{:toc}
## Table of Contents
## Overview

View File

@ -3,7 +3,7 @@ title: HTML
path: principles/html
---
{:toc}
## Table of Contents
## General formatting

View File

@ -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

View File

@ -3,7 +3,7 @@ title: SCSS
path: priniciples/scss
---
{:toc}
## Table of Contents
## Spacing

View File

@ -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.**

View File

@ -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

View File

@ -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`.

View File

@ -7,7 +7,7 @@ source: 'https://github.com/primer/css/blob/master/src/support/variables/typogra
bundle: support
---
{:toc}
## Table of Contents
## Type Scale

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -9,7 +9,7 @@ bundle: utilities
Utilities for borders, border radius, and box shadows.
{:toc}
## Table of Contents
## Default border

View File

@ -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

View File

@ -8,7 +8,7 @@ bundle: utilities
Details classes are created to enhance the native behaviors of `<details>`.
{:toc}
## Table of Contents
## Fullscreen click area

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.