@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,6 +1,6 @@
1
1
  {
2
2
  "name": "Primer Components",
3
- "image": "mcr.microsoft.com/vscode/devcontainers/typescript-node:14",
3
+ "image": "mcr.microsoft.com/vscode/devcontainers/typescript-node:16",
4
4
  "extensions": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"],
5
5
  "forwardPorts": [8000],
6
6
  "postCreateCommand": ["/bin/bash", "-c", "pushd docs && npm install && popd && npm install"],
@@ -16,7 +16,7 @@ jobs:
16
16
  - name: Set up Node.js
17
17
  uses: actions/setup-node@v2
18
18
  with:
19
- node-version: 14
19
+ node-version: 16
20
20
 
21
21
  - name: Install dependencies
22
22
  run: npm ci
@@ -18,7 +18,7 @@ jobs:
18
18
  - name: Set up Node.js
19
19
  uses: actions/setup-node@v2
20
20
  with:
21
- node-version: 14
21
+ node-version: 16
22
22
 
23
23
  - name: Install dependencies
24
24
  run: npm ci
@@ -29,7 +29,7 @@ jobs:
29
29
  - name: Set up Node.js
30
30
  uses: actions/setup-node@v2
31
31
  with:
32
- node-version: 14.x
32
+ node-version: 16
33
33
 
34
34
  - name: Install dependencies
35
35
  run: npm ci
@@ -20,7 +20,7 @@ jobs:
20
20
  - name: Set up Node.js
21
21
  uses: actions/setup-node@v2
22
22
  with:
23
- node-version: 14.x
23
+ node-version: 16
24
24
 
25
25
  - name: Install dependencies
26
26
  run: npm ci
@@ -0,0 +1,32 @@
1
+ name: Update status project
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ # Only run workflow on changes to component docs
8
+ paths:
9
+ - 'docs/content/**'
10
+
11
+ jobs:
12
+ build-and-deploy:
13
+ name: Update status project
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Setup Ruby
18
+ uses: actions/setup-ruby@v1
19
+ with:
20
+ ruby-version: 2.7.x
21
+ - name: Set up Node.js
22
+ uses: actions/setup-node@v2
23
+ with:
24
+ node-version: 14
25
+ - name: Install node deps
26
+ run: npm ci
27
+ - name: Install ruby deps
28
+ run: gem install graphql-client
29
+ - name: Build statuses
30
+ run: npx ts-node script/component-status-project/build.ts
31
+ - name: Deploy statuses to project
32
+ run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} script/component-status-project/deploy.rb
package/.gitignore CHANGED
@@ -8,3 +8,4 @@ lib/
8
8
  lib-esm/
9
9
  public/
10
10
  stats.html
11
+ .env
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- v14
1
+ v16
package/CHANGELOG.md CHANGED
@@ -1,10 +1,28 @@
1
1
  # @primer/components
2
2
 
3
- ## 32.1.1
3
+ ## 33.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#1643](https://github.com/primer/react/pull/1643) [`3938550f`](https://github.com/primer/react/commit/3938550fb3ea3fbec542a0cadaf6aeb734fba938) Thanks [@jfuchs](https://github.com/jfuchs)! - Details no longer accepts styled-system props. Please use the `sx` prop to extend Primer component styling instead. See also https://primer.style/react/overriding-styles for information about `sx` and https://primer.style/react/system-props for context on the removal.
8
+
9
+ * [#1643](https://github.com/primer/react/pull/1643) [`3938550f`](https://github.com/primer/react/commit/3938550fb3ea3fbec542a0cadaf6aeb734fba938) Thanks [@jfuchs](https://github.com/jfuchs)! - Avatar no longer accepts styled-system props. Please use the `sx` prop to extend Primer component styling instead. See also https://primer.style/react/overriding-styles for information about `sx` and https://primer.style/react/system-props for context on the removal.
10
+
11
+ - [#1643](https://github.com/primer/react/pull/1643) [`3938550f`](https://github.com/primer/react/commit/3938550fb3ea3fbec542a0cadaf6aeb734fba938) Thanks [@jfuchs](https://github.com/jfuchs)! - BranchName no longer accepts styled-system props. Please use the `sx` prop to extend Primer component styling instead. See also https://primer.style/react/overriding-styles for information about `sx` and https://primer.style/react/system-props for context on the removal.
12
+
13
+ * [#1643](https://github.com/primer/react/pull/1643) [`3938550f`](https://github.com/primer/react/commit/3938550fb3ea3fbec542a0cadaf6aeb734fba938) Thanks [@jfuchs](https://github.com/jfuchs)! - Heading no longer accepts styled-system props. Please use the `sx` prop to extend Primer component styling instead. See also https://primer.style/react/overriding-styles for information about `sx` and https://primer.style/react/system-props for context on the removal.
14
+
15
+ ### Minor Changes
16
+
17
+ - [#1619](https://github.com/primer/react/pull/1619) [`a13efa45`](https://github.com/primer/react/commit/a13efa457ded69656fb390b5b9b666d00157fd21) Thanks [@siddharthkp](https://github.com/siddharthkp)! - Add composable `ActionMenu` to `@primer/components/drafts`
4
18
 
5
19
  ### Patch Changes
6
20
 
7
- - [#1596](https://github.com/primer/react/pull/1596) [`5c6dc644`](https://github.com/primer/react/commit/5c6dc644c1e68b36d309deac653aca189f1fa624) Thanks [@dmarcey](https://github.com/dmarcey)! - Fix alignment of items in ActionList (single-select) if some of the items have wrapping text.
21
+ - [#1668](https://github.com/primer/react/pull/1668) [`98dc6336`](https://github.com/primer/react/commit/98dc633674b793edfa4fbeb88fd239e6ca40544e) Thanks [@siddharthkp](https://github.com/siddharthkp)! - ActionList: Fix multiple selection svg by overriding global shape-rendering for github.com
22
+
23
+ * [#1596](https://github.com/primer/react/pull/1596) [`5c6dc644`](https://github.com/primer/react/commit/5c6dc644c1e68b36d309deac653aca189f1fa624) Thanks [@dmarcey](https://github.com/dmarcey)! - Fix alignment of items in ActionList (single-select) if some of the items have wrapping text.
24
+
25
+ - [#1538](https://github.com/primer/react/pull/1538) [`dda6e5d7`](https://github.com/primer/react/commit/dda6e5d7204347c3c66183464dd0903e878a4f20) Thanks [@shiftkey](https://github.com/shiftkey)! - Update `typescript` package to correct generated type declarations.
8
26
 
9
27
  ## 32.1.0
10
28
 
@@ -77,65 +77,35 @@ Additionally, every component should support [the `sx` prop](https://primer.styl
77
77
 
78
78
  Here's an example of a basic component written in the style of Primer Components:
79
79
 
80
- ```jsx
81
- import {TYPOGRAPHY, COMMON} from './constants'
82
- import sx from './sx'
80
+ ```tsx
81
+ import sx, {SxProp} from './sx'
83
82
 
84
- const Component = styled.div`
83
+ const Component = styled.div<SxProp>`
85
84
  // additional styles here
86
85
 
87
- ${COMMON};
88
- ${TYPOGRAPHY};
89
86
  ${sx};
90
87
  `
91
88
 
92
89
  Component.defaultProps = {
93
90
  m: 0,
94
- fontSize: 5,
91
+ fontSize: 5
95
92
  }
96
93
 
97
94
  export default Component
98
95
  ```
99
96
 
100
- ### Adding system props
101
-
102
- Each component should have access to the appropriate system props. Every component has access to `COMMON`. For **most** components added, you'll only need to give the component to `COMMON`. If you are unsure, ping a DS team member on your PR.
103
-
104
- Categories of system props are exported from `src/constants.js`:
105
-
106
- - `COMMON` includes color and spacing (margin and padding) props
107
- - `TYPOGRAPHY` includes font family, font weight, and line-height props
108
- - `POSITION` includes positioning props
109
- - `FLEX` includes flexbox props
110
- - `BORDER` includes border and box-shadow props
111
- - `GRID` includes grid props
112
-
113
- To give the component access to a group of system props, import the system prop function from `./constants` and include the system prop function in your styled-component like so:
114
-
115
- ```jsx
116
- import {COMMON} from './constants'
117
-
118
- const Component = styled.div`
119
- // additional styles here
120
- ${COMMON};
121
- `
122
- ```
123
-
124
- Remember that the system prop function inside your style declaration needs to go _after_ any built-in styles you want to be overridable.
125
-
126
97
  ### Adding the `sx` prop
127
98
 
128
- Each component should provide access to a prop called `sx` that allows for setting theme-aware ad-hoc styles. See the [overriding styles](https://primer.style/components/overriding-styles) doc for more information on using the prop.
99
+ Each component should accept a prop called `sx` that allows for setting theme-aware ad-hoc styles. See the [overriding styles](https://primer.style/components/overriding-styles) doc for more information on using the prop.
129
100
 
130
- Adding the `sx` prop is similar to adding system props; import the default export from the `sx` module, add it to your style definition, and add the appropriate prop types. **The `sx` prop should go at the _very end_ of your style definition.**
101
+ To add the `sx` prop to your component: import the default export from the `sx` module, add it to your style definition, and add the appropriate prop types. **The `sx` prop should go at the _very end_ of your style definition.**
131
102
 
132
- ```jsx
133
- import {COMMON} from './constants'
134
- import sx from './sx'
103
+ ```tsx
104
+ import sx, {SxProp} from './sx'
135
105
 
136
- const Component = styled.div`
106
+ const Component = styled.div<SxProp>`
137
107
  // additional styles here
138
- ${COMMON};
108
+
139
109
  ${sx};
140
110
  `
141
111
  ```
@@ -175,15 +145,16 @@ See [`src/__tests__/example.js`](src/__tests__/example.js) for examples of ways
175
145
 
176
146
  ### TypeScript support
177
147
 
178
- Several of the projects that consume Primer Components are written in TypeScript. Though Primer Components is not currently written in TS, we do export type definitions in order to make Primer Components compatible with other TS projects.
148
+ Primer React is written in TypeScript. We include type definitions in our built artifacts. To check types, run the `typecheck` script:
179
149
 
180
- Whenever adding new components or modifying the props of an existing component, **please make sure to update the type definition** in `index.d.ts`! This is super important to make sure we don't break compatibility :)
150
+ ```
151
+ npm run typecheck
152
+ ```
181
153
 
182
154
  ### Additional resources
183
155
 
184
156
  - [Primer Components Philosophy](https://primer.style/components/philosophy)
185
157
  - [Primer Components Core Concepts](https://primer.style/components/core-concepts)
186
- - [Primer Components System Props](https://primer.style/components/system-props)
187
158
  - [Styled Components docs](https://styled-components.com/)
188
159
  - [Styled System docs](https://styled-system.com/)
189
160
 
@@ -206,7 +177,6 @@ After opening a pull request, a member of the design systems team will add the a
206
177
  - If it's a new component, does the component make sense to add to Primer Components? (Ideally this is discussed before the pull request stage, please reach out to a DS member if you aren't sure if a component should be added to Primer Components!)
207
178
  - Does the component follow our [Primer Components code style](#component-patterns)?
208
179
  - Does the component use theme values for most CSS values?
209
- - Does the component have the [correct system props implemented](#adding-system-props)?
210
180
  - Is the component API intuitive?
211
181
  - Does the component have the appropriate [type definitions in `index.d.ts`](#typescript-support)?
212
182
  - Is the component documented accurately?
@@ -251,20 +221,6 @@ Make sure to run `npm install` from inside the `docs/` subfolder _as well as_ th
251
221
 
252
222
  Ensure you are using the latest minor of Node.js for the major version specified in the `.nvmrc` file. For example, if `.nvmrc` contains `8`, make sure you're using the latest version of Node.js with the major version of 8.
253
223
 
254
- ## Glossary
255
-
256
- ### System props
257
-
258
- System props are style functions that provide one or more props, and can be passed directly the return value of [styled-components]'s `styled()` function:
259
-
260
- ```jsx
261
- import styled from 'styled-components'
262
- import {space} from 'styled-system'
263
- const SpaceDiv = styled.div`
264
- ${space}
265
- `
266
- ```
267
-
268
224
  [classnames]: https://www.npmjs.com/package/classnames
269
225
  [spread syntax]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax
270
226
  [styled-system]: https://styled-system.com