Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
845dbac
Initial Timeline component implementation
dmarcey Feb 24, 2020
b1c1609
Match styles to Primer/css
dmarcey Feb 24, 2020
7d0b1f9
Use children as props and add Body component
dmarcey Feb 24, 2020
e07d38a
Added links example
dmarcey Feb 24, 2020
3b3ea58
Removing props for now
dmarcey Feb 24, 2020
0fde57f
Added colored badge example
dmarcey Feb 24, 2020
6ab20b3
Added condensed prop to Timeline.Item
dmarcey Feb 24, 2020
6cf0529
Added break component
dmarcey Feb 24, 2020
0c5f587
Added clipSidebar prop and honor padding on Items
dmarcey Feb 24, 2020
463d3e7
Added propTypes and d.ts props
dmarcey Feb 24, 2020
efec0ee
Replace hard-coded styles with theme variables
dmarcey Feb 24, 2020
79ffef6
Remove redundant prop.
dmarcey Feb 24, 2020
b109030
Remove .condensed class
dmarcey Feb 25, 2020
eefd66a
Added Timeline tests and snapshots
dmarcey Feb 26, 2020
9da9131
Updated docs and props.
dmarcey Feb 26, 2020
4c140a1
Merge branch 'master' into timeline-component
dmarcey Feb 27, 2020
6f8fd7f
Update docs/content/Timeline.md
dmarcey Feb 27, 2020
3fe44a7
PR feedback and prop types cleanup.
dmarcey Feb 27, 2020
ce13b6c
Updated snapshots.
dmarcey Feb 27, 2020
2ffa1d4
update Dropdown title type
Mar 5, 2020
daf2c81
update version
Mar 6, 2020
f54c1b8
PR Feedback - fixes prop types, and uses css helper
dmarcey Mar 9, 2020
be2662a
Bump acorn from 6.4.0 to 6.4.1
dependabot[bot] Mar 14, 2020
f837e39
remove z-index
Mar 15, 2020
cfde7b5
test removing zindex from button group
Mar 15, 2020
4834f2e
update version
Mar 15, 2020
428b4ee
Revert "test removing zindex from button group"
Mar 16, 2020
fe77946
Merge pull request #704 from primer/dropdown-type
Mar 17, 2020
8ec1ff5
Merge branch 'master' into minor
Mar 17, 2020
d9d7ce9
Merge branch 'master' into dependabot/npm_and_yarn/acorn-6.4.1
Mar 17, 2020
90f9c37
Merge branch 'minor' into dependabot/npm_and_yarn/acorn-6.4.1
Mar 17, 2020
96e07ea
Merge branch 'master' into minor
Mar 17, 2020
147d7de
Merge branch 'minor' of github.com:primer/components into minor
Mar 17, 2020
d4c1e71
Merge pull request #710 from primer/dependabot/npm_and_yarn/acorn-6.4.1
Mar 17, 2020
f278e63
Merge pull request #712 from primer/button-index
Mar 17, 2020
3ff8d76
add Grid type definitions
Mar 17, 2020
55e20bb
move order of imports
Mar 18, 2020
2131c01
Merge pull request #719 from primer/grid
Mar 18, 2020
0ccc750
refactor Timeline.Badge
Mar 19, 2020
29ff821
lint it up
Mar 19, 2020
5086624
update tests/snaps
Mar 19, 2020
6c9c1a5
Merge pull request #700 from primer/timeline-component
Mar 19, 2020
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
2 changes: 1 addition & 1 deletion docs/content/Dropdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Dropdown, Dropdown.Menu, and Dropdown.Item all get `COMMON` system props. Read o
| Name | Type | Default | Description |
| :- | :- | :-: | :- |
| direction | String | 'sw' | Sets the direction of the dropdown menu. |
| title | String | | Sets the text inside of the button |
| title | String or Node | | Sets the text inside of the button, can be either a string or a React node |

#### Dropdown.Item
No additional props.
Expand Down
138 changes: 138 additions & 0 deletions docs/content/Timeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
title: Timeline
---

The Timeline.Item component is used to display items on a vertical timeline, connected by Timeline.Badge elements.

## Example with in-line links

```jsx live
<Timeline>
<Timeline.Item>
<Timeline.Badge>
<StyledOcticon icon={Flame} />
</Timeline.Badge>
<Timeline.Body>
<Link href="#" fontWeight="bold" color="gray.8" mr={1} muted>
Monalisa
</Link>
created one <Link href="#" fontWeight="bold" color="gray.8" mr={1} muted>
hot potato
</Link>
<Link href="#" color="gray.7" muted>
Just now
</Link>
</Timeline.Body>
</Timeline.Item>
</Timeline>
```

## Default Color example

The default Timeline.Badge color is dark text on a light grey background.

```jsx live
<Timeline>
<Timeline.Item>
<Timeline.Badge>
<StyledOcticon icon={Flame} />
</Timeline.Badge>
<Timeline.Body>Default badge color</Timeline.Body>
</Timeline.Item>
</Timeline>
```

## Adding color to a Badge

To have color variants, use the `bg` prop on the `Timeline.Badge`. If an icon is being used, set the `color` prop
of the child `StyledOcticon` if necessary.

```jsx live
<Timeline>
<Timeline.Item>
<Timeline.Badge bg="red.5">
<StyledOcticon icon={Flame} color="white" />
</Timeline.Badge>
<Timeline.Body>Red background used when closed events occur</Timeline.Body>
</Timeline.Item>
<Timeline.Item>
<Timeline.Badge bg="green.5">
<StyledOcticon icon={Flame} color="white" />
</Timeline.Badge>
<Timeline.Body>Green background when opened or passed events occur</Timeline.Body>
</Timeline.Item>
<Timeline.Item>
<Timeline.Badge bg="purple.5">
<StyledOcticon icon={Flame} color="white" />
</Timeline.Badge>
<Timeline.Body>Purple background used when pull requests are merged</Timeline.Body>
</Timeline.Item>
<Timeline.Item>
<Timeline.Badge bg="blue.5">
<StyledOcticon icon={Flame} color="white" />
</Timeline.Badge>
<Timeline.Body>Blue background to indicate new events below</Timeline.Body>
</Timeline.Item>
</Timeline>
```

## Condensed items

Timeline has a condensed prop that will reduce the vertical padding and remove the background from the badge item. These are most commonly used in commits. To condense a single item, remove the top or bottom padding with the `pt={0}` or `pb={0}` prop.

```jsx live
<Timeline>
<Timeline.Item condensed>
<Timeline.Badge>
<StyledOcticon icon={GitCommit} />
</Timeline.Badge>
<Timeline.Body>This is the message of a condensed TimelineItem</Timeline.Body>
</Timeline.Item>
<Timeline.Item condensed>
<Timeline.Badge>
<StyledOcticon icon={GitCommit} />
</Timeline.Badge>
<Timeline.Body>This is the message of a condensed TimelineItem</Timeline.Body>
</Timeline.Item>
</Timeline>
```

## Timeline Break

To create a visual break in the timeline, use Timeline.Break. This adds a horizontal bar across the timeline to show that something has disrupted it. Usually this happens when a close or merged event occurs.

```jsx live
<Timeline>
<Timeline.Item>
<Timeline.Badge bg="red.5">
<StyledOcticon icon={Flame} color="white" />
</Timeline.Badge>
<Timeline.Body>Red background used when closed events occur</Timeline.Body>
</Timeline.Item>
<Timeline.Break />
<Timeline.Item>
<Timeline.Badge bg="green.5">
<StyledOcticon icon={Flame} color="white" />
</Timeline.Badge>
<Timeline.Body>Green background when opened or passed events occur</Timeline.Body>
</Timeline.Item>
</Timeline>
```

## System props

Timeline and Timeline.Item components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.

## Component props

### Timeline

| Prop name | Type | Description |
| :---------- | :------ | :-------------------------------------------------------------------------------- |
| clipSidebar | Boolean | Hides the sidebar above the first Timeline.Item and below the last Timeline.Item. |

### Timeline.Item

| Prop name | Type | Description |
| :-------- | :------ | :-------------------------------------------------------------------- |
| condensed | Boolean | Reduces vertical padding and removes background from an item's badge. |
17 changes: 15 additions & 2 deletions docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import * as primerComponents from '@primer/components'
import * as doctocatComponents from '@primer/gatsby-theme-doctocat'
import Octicon, {Check, Zap, X, Search, PrimitiveDot, Octoface, Person, Mail} from '@primer/octicons-react'
import Octicon, {
Check,
Zap,
X,
Search,
PrimitiveDot,
Octoface,
Person,
Mail,
GitCommit,
Flame
} from '@primer/octicons-react'
import State from '../../../components/State'

export default {
Expand All @@ -15,5 +26,7 @@ export default {
PrimitiveDot,
Octoface,
Person,
Mail
Mail,
GitCommit,
Flame
}
2 changes: 2 additions & 0 deletions docs/src/@primer/gatsby-theme-doctocat/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
url: /Text
- title: TextInput
url: /TextInput
- title: Timeline
url: /Timeline
- title: Tooltip
url: /Tooltip
- title: Truncate
Expand Down
37 changes: 35 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ declare module '@primer/components' {

export interface DropdownMenuProps extends CommonProps, Omit<React.HTMLAttributes<HTMLUListElement>, 'color'> {
direction?: string
title: string
title: string | React.ReactNode
}

export const Dropdown: React.FunctionComponent<DropdownProps> & {
Expand Down Expand Up @@ -191,6 +191,10 @@ declare module '@primer/components' {

export const CounterLabel: React.FunctionComponent<CounterLabelProps>

export interface GridProps extends BoxProps, StyledSystem.GridProps, Omit<React.HTMLAttributes<HTMLSpanElement>, 'color'> {}

export const Grid: React.FunctionComponent<GridProps>

export interface LabelProps extends CommonProps, Omit<React.HTMLAttributes<HTMLSpanElement>, 'color'> {
outline?: boolean
variant?: 'small' | 'medium' | 'large' | 'xl'
Expand Down Expand Up @@ -231,7 +235,11 @@ declare module '@primer/components' {
variant?: 'normal' | 'lightweight'
}

export interface SideNavLinkProps extends CommonProps, TypographyProps, LinkProps, Omit<React.HTMLAttributes<HTMLAnchorElement>, 'color'> {
export interface SideNavLinkProps
extends CommonProps,
TypographyProps,
LinkProps,
Omit<React.HTMLAttributes<HTMLAnchorElement>, 'color'> {
variant?: 'normal' | 'full'
}

Expand Down Expand Up @@ -275,6 +283,22 @@ declare module '@primer/components' {
wrap?: boolean
}

export interface TimelineProps extends Omit<FlexProps, 'flexDirection'> {
clipSidebar?: boolean
}

export interface TimelineItemProps extends Omit<FlexProps, 'flexDirection'> {
condensed?: boolean
}
export interface TimelineBadgeProps extends Omit<FlexProps, 'height' | 'width' | 'alignItems' | 'justifyContent'> {}

export const Timeline: React.FunctionComponent<TimelineProps> & {
Item: React.FunctionComponent<TimelineItemProps>
Badge: React.FunctionComponent<TimelineBadgeProps>
Body: React.FunctionComponent<BoxProps>
Break: React.FunctionComponent<BoxProps>
}

export const Tooltip: React.FunctionComponent<TooltipProps>

export interface UnderlineNavProps extends CommonProps, Omit<React.HTMLAttributes<HTMLDivElement>, 'color'> {
Expand Down Expand Up @@ -457,6 +481,11 @@ declare module '@primer/components/src/Flash' {
export default Flash
}

declare module '@primer/components/src/Grid' {
import {Grid} from '@primer/components'
export default Grid
}

declare module '@primer/components/src/CounterLabel' {
import {CounterLabel} from '@primer/components'
export default CounterLabel
Expand Down Expand Up @@ -503,6 +532,10 @@ declare module '@primer/components/src/TextInput' {
import {TextInput} from '@primer/components'
export default TextInput
}
declare module '@primer/components/src/Timeline' {
import {Timeline} from '@primer/components'
export default Timeline
}
declare module '@primer/components/src/Tooltip' {
import {Tooltip} from '@primer/components'
export default Tooltip
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@primer/components",
"version": "16.0.0",
"version": "16.1.0",
"description": "Primer react components",
"main": "dist/index.umd.js",
"module": "dist/index.esm.js",
Expand All @@ -12,6 +12,7 @@
"prepublishOnly": "yarn run dist",
"lint": "eslint src docs/components",
"test": "jest -- src",
"update-snapshots": "jest -u -- src",
"watch": "jest --watch --no-coverage",
"playroom:start": "playroom start",
"playroom:build": "playroom build",
Expand Down
5 changes: 0 additions & 5 deletions src/ButtonStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export default css`
outline: none;
}

&:focus,
&:active {
z-index: 1;
}

&:disabled {
cursor: default;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Dropdown.Item.propTypes = {
Dropdown.defaultProps = {theme}
Dropdown.propTypes = {
children: PropTypes.node,
title: PropTypes.string,
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
...COMMON.propTypes
}

Expand Down
Loading