@primer/components 32.1.1-rc.92743105 → 33.0.0-rc.9cc2a259

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. package/.devcontainer/devcontainer.json +1 -1
  2. package/.github/workflows/ci.yml +1 -1
  3. package/.github/workflows/release.yml +1 -1
  4. package/.github/workflows/release_canary.yml +1 -1
  5. package/.github/workflows/release_candidate.yml +1 -1
  6. package/.github/workflows/statuses.yml +32 -0
  7. package/.gitignore +1 -0
  8. package/.nvmrc +1 -1
  9. package/CHANGELOG.md +20 -2
  10. package/contributor-docs/CONTRIBUTING.md +14 -58
  11. package/dist/browser.esm.js +105 -108
  12. package/dist/browser.esm.js.map +1 -1
  13. package/dist/browser.umd.js +105 -108
  14. package/dist/browser.umd.js.map +1 -1
  15. package/docs/content/BranchName.md +6 -5
  16. package/docs/content/Details.md +4 -8
  17. package/docs/content/Heading.md +5 -10
  18. package/docs/content/Label.md +6 -7
  19. package/docs/content/ProgressBar.mdx +7 -6
  20. package/docs/content/Text.md +0 -6
  21. package/docs/content/{ActionList2.mdx → drafts/ActionList2.mdx} +5 -9
  22. package/docs/content/drafts/ActionMenu2.mdx +251 -0
  23. package/docs/content/status.mdx +1 -1
  24. package/docs/content/system-props.mdx +1 -1
  25. package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +9 -1
  26. package/docs/src/@primer/gatsby-theme-doctocat/nav.yml +1 -1
  27. package/docs/src/component-checklist.js +10 -2
  28. package/lib/ActionList/Item.js +1 -1
  29. package/lib/ActionList2/Divider.d.ts +3 -2
  30. package/lib/ActionList2/Divider.js +10 -5
  31. package/lib/ActionList2/Item.js +21 -5
  32. package/lib/ActionList2/List.js +11 -1
  33. package/lib/ActionList2/MenuContext.d.ts +10 -0
  34. package/lib/ActionList2/MenuContext.js +15 -0
  35. package/lib/ActionList2/Selection.js +14 -1
  36. package/lib/ActionList2/index.d.ts +1 -2
  37. package/lib/ActionMenu2.d.ts +313 -0
  38. package/lib/ActionMenu2.js +91 -0
  39. package/lib/Autocomplete/Autocomplete.d.ts +2 -1
  40. package/lib/Autocomplete/AutocompleteInput.d.ts +2 -1
  41. package/lib/Avatar.d.ts +1 -2
  42. package/lib/Avatar.js +1 -1
  43. package/lib/BranchName.d.ts +1 -2
  44. package/lib/BranchName.js +1 -1
  45. package/lib/Button/Button.d.ts +2 -2
  46. package/lib/Button/ButtonClose.d.ts +2 -2
  47. package/lib/Button/ButtonDanger.d.ts +2 -2
  48. package/lib/Button/ButtonInvisible.d.ts +2 -2
  49. package/lib/Button/ButtonOutline.d.ts +2 -2
  50. package/lib/Button/ButtonPrimary.d.ts +2 -2
  51. package/lib/CircleOcticon.d.ts +35 -35
  52. package/lib/Details.d.ts +1 -2
  53. package/lib/Details.js +1 -3
  54. package/lib/Dialog.d.ts +37 -37
  55. package/lib/Dropdown.d.ts +8 -72
  56. package/lib/DropdownMenu/DropdownButton.d.ts +6 -3
  57. package/lib/FilterList.d.ts +1 -1
  58. package/lib/Heading.d.ts +1 -2
  59. package/lib/Heading.js +1 -6
  60. package/lib/Position.d.ts +4 -4
  61. package/lib/ProgressBar.d.ts +16 -11
  62. package/lib/ProgressBar.js +6 -10
  63. package/lib/SelectMenu/SelectMenu.d.ts +11 -10
  64. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  65. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  66. package/lib/Spinner.d.ts +1 -2
  67. package/lib/Spinner.js +1 -3
  68. package/lib/TextInputWithTokens.d.ts +2 -1
  69. package/lib/Token/AvatarToken.d.ts +1 -1
  70. package/lib/Token/IssueLabelToken.d.ts +1 -1
  71. package/lib/Token/Token.d.ts +1 -1
  72. package/lib/__tests__/Avatar.test.js +4 -2
  73. package/lib/__tests__/Avatar.types.test.d.ts +3 -0
  74. package/lib/__tests__/Avatar.types.test.js +31 -0
  75. package/lib/__tests__/BranchName.types.test.d.ts +3 -0
  76. package/lib/__tests__/BranchName.types.test.js +28 -0
  77. package/lib/__tests__/Details.types.test.d.ts +3 -0
  78. package/lib/__tests__/Details.types.test.js +28 -0
  79. package/lib/__tests__/Heading.test.js +63 -30
  80. package/lib/__tests__/Heading.types.test.d.ts +3 -0
  81. package/lib/__tests__/Heading.types.test.js +28 -0
  82. package/lib/drafts.d.ts +1 -0
  83. package/lib/drafts.js +13 -0
  84. package/lib/stories/ActionMenu2.stories.js +433 -0
  85. package/lib-esm/ActionList/Item.js +1 -1
  86. package/lib-esm/ActionList2/Divider.d.ts +3 -2
  87. package/lib-esm/ActionList2/Divider.js +8 -5
  88. package/lib-esm/ActionList2/Item.js +19 -5
  89. package/lib-esm/ActionList2/List.js +9 -1
  90. package/lib-esm/ActionList2/MenuContext.d.ts +10 -0
  91. package/lib-esm/ActionList2/MenuContext.js +3 -0
  92. package/lib-esm/ActionList2/Selection.js +12 -1
  93. package/lib-esm/ActionList2/index.d.ts +1 -2
  94. package/lib-esm/ActionMenu2.d.ts +313 -0
  95. package/lib-esm/ActionMenu2.js +67 -0
  96. package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -1
  97. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -1
  98. package/lib-esm/Avatar.d.ts +1 -2
  99. package/lib-esm/Avatar.js +2 -2
  100. package/lib-esm/BranchName.d.ts +1 -2
  101. package/lib-esm/BranchName.js +2 -2
  102. package/lib-esm/Button/Button.d.ts +2 -2
  103. package/lib-esm/Button/ButtonClose.d.ts +2 -2
  104. package/lib-esm/Button/ButtonDanger.d.ts +2 -2
  105. package/lib-esm/Button/ButtonInvisible.d.ts +2 -2
  106. package/lib-esm/Button/ButtonOutline.d.ts +2 -2
  107. package/lib-esm/Button/ButtonPrimary.d.ts +2 -2
  108. package/lib-esm/CircleOcticon.d.ts +35 -35
  109. package/lib-esm/Details.d.ts +1 -2
  110. package/lib-esm/Details.js +1 -2
  111. package/lib-esm/Dialog.d.ts +37 -37
  112. package/lib-esm/Dropdown.d.ts +8 -72
  113. package/lib-esm/DropdownMenu/DropdownButton.d.ts +6 -3
  114. package/lib-esm/FilterList.d.ts +1 -1
  115. package/lib-esm/Heading.d.ts +1 -2
  116. package/lib-esm/Heading.js +2 -6
  117. package/lib-esm/Position.d.ts +4 -4
  118. package/lib-esm/ProgressBar.d.ts +16 -11
  119. package/lib-esm/ProgressBar.js +7 -11
  120. package/lib-esm/SelectMenu/SelectMenu.d.ts +11 -10
  121. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  122. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  123. package/lib-esm/Spinner.d.ts +1 -2
  124. package/lib-esm/Spinner.js +1 -2
  125. package/lib-esm/TextInputWithTokens.d.ts +2 -1
  126. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  127. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  128. package/lib-esm/Token/Token.d.ts +1 -1
  129. package/lib-esm/__tests__/Avatar.test.js +4 -2
  130. package/lib-esm/__tests__/Avatar.types.test.d.ts +3 -0
  131. package/lib-esm/__tests__/Avatar.types.test.js +16 -0
  132. package/lib-esm/__tests__/BranchName.types.test.d.ts +3 -0
  133. package/lib-esm/__tests__/BranchName.types.test.js +13 -0
  134. package/lib-esm/__tests__/Details.types.test.d.ts +3 -0
  135. package/lib-esm/__tests__/Details.types.test.js +13 -0
  136. package/lib-esm/__tests__/Heading.test.js +62 -30
  137. package/lib-esm/__tests__/Heading.types.test.d.ts +3 -0
  138. package/lib-esm/__tests__/Heading.types.test.js +13 -0
  139. package/lib-esm/drafts.d.ts +1 -0
  140. package/lib-esm/drafts.js +2 -1
  141. package/lib-esm/stories/ActionMenu2.stories.js +376 -0
  142. package/package-lock.json +321 -269
  143. package/package.json +11 -5
  144. package/script/component-status-project/build.ts +100 -0
  145. package/script/component-status-project/deploy.rb +142 -0
  146. package/src/ActionList/Item.tsx +1 -0
  147. package/src/ActionList2/Divider.tsx +13 -8
  148. package/src/ActionList2/Item.tsx +13 -3
  149. package/src/ActionList2/List.tsx +6 -2
  150. package/src/ActionList2/MenuContext.tsx +6 -0
  151. package/src/ActionList2/Selection.tsx +11 -1
  152. package/src/ActionMenu2.tsx +94 -0
  153. package/src/Avatar.tsx +2 -4
  154. package/src/BranchName.tsx +3 -3
  155. package/src/Details.tsx +1 -5
  156. package/src/Heading.tsx +2 -9
  157. package/src/ProgressBar.tsx +11 -10
  158. package/src/Spinner.tsx +1 -3
  159. package/src/__tests__/Avatar.test.tsx +1 -1
  160. package/src/__tests__/Avatar.types.test.tsx +11 -0
  161. package/src/__tests__/BranchName.types.test.tsx +11 -0
  162. package/src/__tests__/Details.types.test.tsx +11 -0
  163. package/src/__tests__/Heading.test.tsx +71 -25
  164. package/src/__tests__/Heading.types.test.tsx +11 -0
  165. package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +4 -0
  166. package/src/drafts.ts +1 -0
  167. package/src/stories/ActionMenu2.stories.tsx +551 -0
  168. package/stats.html +1 -1
  169. package/tsconfig.build.json +1 -1
  170. package/tsconfig.json +1 -1
@@ -1,13 +1,15 @@
1
1
  import React from 'react'
2
2
  import styled from 'styled-components'
3
3
  import {width, WidthProps} from 'styled-system'
4
- import {COMMON, get, SystemCommonProps} from './constants'
4
+ import {get} from './constants'
5
5
  import sx, {SxProp} from './sx'
6
- import {ComponentProps} from './utils/types'
7
6
 
8
- const Bar = styled.span<{progress?: string | number} & SystemCommonProps>`
7
+ type ProgressProp = {progress?: string | number}
8
+
9
+ const Bar = styled.span<ProgressProp & SxProp>`
9
10
  width: ${props => (props.progress ? `${props.progress}%` : 0)};
10
- ${COMMON}
11
+
12
+ ${sx};
11
13
  `
12
14
 
13
15
  const sizeMap = {
@@ -20,7 +22,6 @@ type StyledProgressContainerProps = {
20
22
  inline?: boolean
21
23
  barSize?: keyof typeof sizeMap
22
24
  } & WidthProps &
23
- SystemCommonProps &
24
25
  SxProp
25
26
 
26
27
  const ProgressContainer = styled.span<StyledProgressContainerProps>`
@@ -29,17 +30,17 @@ const ProgressContainer = styled.span<StyledProgressContainerProps>`
29
30
  background-color: ${get('colors.border.default')};
30
31
  border-radius: ${get('radii.1')};
31
32
  height: ${props => sizeMap[props.barSize || 'default']};
32
- ${COMMON}
33
+
33
34
  ${width}
34
35
  ${sx};
35
36
  `
36
37
 
37
- export type ProgressBarProps = ComponentProps<typeof ProgressContainer> & ComponentProps<typeof Bar>
38
+ export type ProgressBarProps = {bg: string} & StyledProgressContainerProps & ProgressProp
38
39
 
39
- function ProgressBar({progress, bg, theme, ...rest}: ProgressBarProps) {
40
+ function ProgressBar({progress, bg, ...rest}: ProgressBarProps) {
40
41
  return (
41
- <ProgressContainer theme={theme} {...rest}>
42
- <Bar progress={progress} bg={bg} theme={theme} />
42
+ <ProgressContainer {...rest}>
43
+ <Bar progress={progress} sx={{bg}} />
43
44
  </ProgressContainer>
44
45
  )
45
46
  }
package/src/Spinner.tsx CHANGED
@@ -1,6 +1,5 @@
1
1
  import React from 'react'
2
2
  import styled from 'styled-components'
3
- import {COMMON, SystemCommonProps} from './constants'
4
3
  import sx, {SxProp} from './sx'
5
4
  import {ComponentProps} from './utils/types'
6
5
 
@@ -40,7 +39,7 @@ function Spinner({size: sizeKey = 'medium', ...props}: SpinnerInternalProps) {
40
39
  )
41
40
  }
42
41
 
43
- const StyledSpinner = styled(Spinner)<SystemCommonProps & SxProp>`
42
+ const StyledSpinner = styled(Spinner)<SxProp>`
44
43
  @keyframes rotate-keyframes {
45
44
  100% {
46
45
  transform: rotate(360deg);
@@ -49,7 +48,6 @@ const StyledSpinner = styled(Spinner)<SystemCommonProps & SxProp>`
49
48
 
50
49
  animation: rotate-keyframes 1s linear infinite;
51
50
 
52
- ${COMMON}
53
51
  ${sx}
54
52
  `
55
53
 
@@ -39,6 +39,6 @@ describe('Avatar', () => {
39
39
  })
40
40
 
41
41
  it('respects margin props', () => {
42
- expect(render(<Avatar m={2} src="primer.png" alt="" />)).toHaveStyleRule('margin', px(theme.space[2]))
42
+ expect(render(<Avatar src="primer.png" alt="" sx={{m: 2}} />)).toHaveStyleRule('margin', px(theme.space[2]))
43
43
  })
44
44
  })
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import Avatar from '../Avatar'
3
+
4
+ export function shouldAcceptCallWithNoProps() {
5
+ return <Avatar src="https://avatars.githubusercontent.com/primer" />
6
+ }
7
+
8
+ export function shouldNotAcceptSystemProps() {
9
+ // @ts-expect-error system props should not be accepted
10
+ return <Avatar src="https://avatars.githubusercontent.com/primer" backgroundColor="thistle" />
11
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import BranchName from '../BranchName'
3
+
4
+ export function shouldAcceptCallWithNoProps() {
5
+ return <BranchName />
6
+ }
7
+
8
+ export function shouldNotAcceptSystemProps() {
9
+ // @ts-expect-error system props should not be accepted
10
+ return <BranchName backgroundColor="thistle" />
11
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import Details from '../Details'
3
+
4
+ export function shouldAcceptCallWithNoProps() {
5
+ return <Details />
6
+ }
7
+
8
+ export function shouldNotAcceptSystemProps() {
9
+ // @ts-expect-error system props should not be accepted
10
+ return <Details backgroundColor="thistle" />
11
+ }
@@ -4,6 +4,7 @@ import {render, behavesAsComponent, checkExports} from '../utils/testing'
4
4
  import {render as HTMLRender, cleanup} from '@testing-library/react'
5
5
  import {axe, toHaveNoViolations} from 'jest-axe'
6
6
  import 'babel-polyfill'
7
+ import ThemeProvider from '../ThemeProvider'
7
8
  expect.extend(toHaveNoViolations)
8
9
 
9
10
  const theme = {
@@ -48,44 +49,89 @@ describe('Heading', () => {
48
49
  })
49
50
 
50
51
  it('respects fontWeight', () => {
51
- expect(render(<Heading fontWeight="bold" theme={theme} />)).toHaveStyleRule('font-weight', theme.fontWeights.bold)
52
- expect(render(<Heading fontWeight="normal" theme={theme} />)).toHaveStyleRule(
53
- 'font-weight',
54
- theme.fontWeights.normal
55
- )
56
- expect(render(<Heading fontWeight="semibold" theme={theme} />)).toHaveStyleRule(
57
- 'font-weight',
58
- theme.fontWeights.semibold
59
- )
60
- expect(render(<Heading fontWeight="light" theme={theme} />)).toHaveStyleRule('font-weight', theme.fontWeights.light)
52
+ expect(
53
+ render(
54
+ <ThemeProvider theme={theme}>
55
+ <Heading sx={{fontWeight: 'bold'}} />
56
+ </ThemeProvider>
57
+ )
58
+ ).toHaveStyleRule('font-weight', theme.fontWeights.bold)
59
+ expect(
60
+ render(
61
+ <ThemeProvider theme={theme}>
62
+ <Heading sx={{fontWeight: 'normal'}} />
63
+ </ThemeProvider>
64
+ )
65
+ ).toHaveStyleRule('font-weight', theme.fontWeights.normal)
66
+ expect(
67
+ render(
68
+ <ThemeProvider theme={theme}>
69
+ <Heading sx={{fontWeight: 'semibold'}} />
70
+ </ThemeProvider>
71
+ )
72
+ ).toHaveStyleRule('font-weight', theme.fontWeights.semibold)
73
+ expect(
74
+ render(
75
+ <ThemeProvider theme={theme}>
76
+ <Heading sx={{fontWeight: 'light'}} />
77
+ </ThemeProvider>
78
+ )
79
+ ).toHaveStyleRule('font-weight', theme.fontWeights.light)
61
80
  })
62
81
 
63
82
  it('respects lineHeight', () => {
64
- expect(render(<Heading lineHeight="normal" theme={theme} />)).toHaveStyleRule(
65
- 'line-height',
66
- String(theme.lineHeights.normal)
67
- )
68
- expect(render(<Heading lineHeight="condensed" theme={theme} />)).toHaveStyleRule(
69
- 'line-height',
70
- String(theme.lineHeights.condensed)
71
- )
72
- expect(render(<Heading lineHeight="condensedUltra" theme={theme} />)).toHaveStyleRule(
73
- 'line-height',
74
- String(theme.lineHeights.condensedUltra)
75
- )
83
+ expect(
84
+ render(
85
+ <ThemeProvider theme={theme}>
86
+ <Heading sx={{lineHeight: 'normal'}} />
87
+ </ThemeProvider>
88
+ )
89
+ ).toHaveStyleRule('line-height', String(theme.lineHeights.normal))
90
+ expect(
91
+ render(
92
+ <ThemeProvider theme={theme}>
93
+ <Heading sx={{lineHeight: 'condensed'}} />
94
+ </ThemeProvider>
95
+ )
96
+ ).toHaveStyleRule('line-height', String(theme.lineHeights.condensed))
97
+ expect(
98
+ render(
99
+ <ThemeProvider theme={theme}>
100
+ <Heading sx={{lineHeight: 'condensedUltra'}} />
101
+ </ThemeProvider>
102
+ )
103
+ ).toHaveStyleRule('line-height', String(theme.lineHeights.condensedUltra))
76
104
  })
77
105
 
78
106
  it('respects fontFamily="mono"', () => {
79
- expect(render(<Heading fontFamily="mono" theme={theme} />)).toHaveStyleRule('font-family', theme.fonts.mono)
107
+ expect(
108
+ render(
109
+ <ThemeProvider theme={theme}>
110
+ <Heading sx={{fontFamily: 'mono'}} />
111
+ </ThemeProvider>
112
+ )
113
+ ).toHaveStyleRule('font-family', theme.fonts.mono)
80
114
  })
81
115
 
82
116
  it('renders fontSize', () => {
83
117
  for (const fontSize of theme.fontSizes) {
84
- expect(render(<Heading fontSize={fontSize} theme={theme} />)).toHaveStyleRule('font-size', `${fontSize}`)
118
+ expect(
119
+ render(
120
+ <ThemeProvider theme={theme}>
121
+ <Heading sx={{fontSize}} />
122
+ </ThemeProvider>
123
+ )
124
+ ).toHaveStyleRule('font-size', `${fontSize}`)
85
125
  }
86
126
  })
87
127
 
88
128
  it('respects the "fontStyle" prop', () => {
89
- expect(render(<Heading fontStyle="italic" />)).toHaveStyleRule('font-style', 'italic')
129
+ expect(
130
+ render(
131
+ <ThemeProvider theme={theme}>
132
+ <Heading sx={{fontStyle: 'italic'}} />
133
+ </ThemeProvider>
134
+ )
135
+ ).toHaveStyleRule('font-style', 'italic')
90
136
  })
91
137
  })
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import Heading from '../Heading'
3
+
4
+ export function shouldAcceptCallWithNoProps() {
5
+ return <Heading />
6
+ }
7
+
8
+ export function shouldNotAcceptSystemProps() {
9
+ // @ts-expect-error system props should not be accepted
10
+ return <Heading backgroundColor="thistle" />
11
+ }
@@ -513,6 +513,7 @@ Array [
513
513
  .c6 rect {
514
514
  fill: #ffffff;
515
515
  stroke: #d0d7de;
516
+ shape-rendering: auto;
516
517
  }
517
518
 
518
519
  .c6 path {
@@ -1386,6 +1387,7 @@ Array [
1386
1387
  .c6 rect {
1387
1388
  fill: #ffffff;
1388
1389
  stroke: #d0d7de;
1390
+ shape-rendering: auto;
1389
1391
  }
1390
1392
 
1391
1393
  .c6 path {
@@ -2206,6 +2208,7 @@ Array [
2206
2208
  .c10 rect {
2207
2209
  fill: #ffffff;
2208
2210
  stroke: #d0d7de;
2211
+ shape-rendering: auto;
2209
2212
  }
2210
2213
 
2211
2214
  .c10 path {
@@ -2216,6 +2219,7 @@ Array [
2216
2219
  .c6 rect {
2217
2220
  fill: #0969da;
2218
2221
  stroke: #0969da;
2222
+ shape-rendering: auto;
2219
2223
  }
2220
2224
 
2221
2225
  .c6 path {
package/src/drafts.ts CHANGED
@@ -8,3 +8,4 @@
8
8
  // Components
9
9
  export * from './ActionList2'
10
10
  export * from './NewButton'
11
+ export * from './ActionMenu2'