@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.
- package/.devcontainer/devcontainer.json +1 -1
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/release.yml +1 -1
- package/.github/workflows/release_canary.yml +1 -1
- package/.github/workflows/release_candidate.yml +1 -1
- package/.github/workflows/statuses.yml +32 -0
- package/.gitignore +1 -0
- package/.nvmrc +1 -1
- package/CHANGELOG.md +20 -2
- package/contributor-docs/CONTRIBUTING.md +14 -58
- package/dist/browser.esm.js +105 -108
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +105 -108
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/BranchName.md +6 -5
- package/docs/content/Details.md +4 -8
- package/docs/content/Heading.md +5 -10
- package/docs/content/Label.md +6 -7
- package/docs/content/ProgressBar.mdx +7 -6
- package/docs/content/Text.md +0 -6
- package/docs/content/{ActionList2.mdx → drafts/ActionList2.mdx} +5 -9
- package/docs/content/drafts/ActionMenu2.mdx +251 -0
- package/docs/content/status.mdx +1 -1
- package/docs/content/system-props.mdx +1 -1
- package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +9 -1
- package/docs/src/@primer/gatsby-theme-doctocat/nav.yml +1 -1
- package/docs/src/component-checklist.js +10 -2
- package/lib/ActionList/Item.js +1 -1
- package/lib/ActionList2/Divider.d.ts +3 -2
- package/lib/ActionList2/Divider.js +10 -5
- package/lib/ActionList2/Item.js +21 -5
- package/lib/ActionList2/List.js +11 -1
- package/lib/ActionList2/MenuContext.d.ts +10 -0
- package/lib/ActionList2/MenuContext.js +15 -0
- package/lib/ActionList2/Selection.js +14 -1
- package/lib/ActionList2/index.d.ts +1 -2
- package/lib/ActionMenu2.d.ts +313 -0
- package/lib/ActionMenu2.js +91 -0
- package/lib/Autocomplete/Autocomplete.d.ts +2 -1
- package/lib/Autocomplete/AutocompleteInput.d.ts +2 -1
- package/lib/Avatar.d.ts +1 -2
- package/lib/Avatar.js +1 -1
- package/lib/BranchName.d.ts +1 -2
- package/lib/BranchName.js +1 -1
- package/lib/Button/Button.d.ts +2 -2
- package/lib/Button/ButtonClose.d.ts +2 -2
- package/lib/Button/ButtonDanger.d.ts +2 -2
- package/lib/Button/ButtonInvisible.d.ts +2 -2
- package/lib/Button/ButtonOutline.d.ts +2 -2
- package/lib/Button/ButtonPrimary.d.ts +2 -2
- package/lib/CircleOcticon.d.ts +35 -35
- package/lib/Details.d.ts +1 -2
- package/lib/Details.js +1 -3
- package/lib/Dialog.d.ts +37 -37
- package/lib/Dropdown.d.ts +8 -72
- package/lib/DropdownMenu/DropdownButton.d.ts +6 -3
- package/lib/FilterList.d.ts +1 -1
- package/lib/Heading.d.ts +1 -2
- package/lib/Heading.js +1 -6
- package/lib/Position.d.ts +4 -4
- package/lib/ProgressBar.d.ts +16 -11
- package/lib/ProgressBar.js +6 -10
- package/lib/SelectMenu/SelectMenu.d.ts +11 -10
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/Spinner.d.ts +1 -2
- package/lib/Spinner.js +1 -3
- package/lib/TextInputWithTokens.d.ts +2 -1
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/__tests__/Avatar.test.js +4 -2
- package/lib/__tests__/Avatar.types.test.d.ts +3 -0
- package/lib/__tests__/Avatar.types.test.js +31 -0
- package/lib/__tests__/BranchName.types.test.d.ts +3 -0
- package/lib/__tests__/BranchName.types.test.js +28 -0
- package/lib/__tests__/Details.types.test.d.ts +3 -0
- package/lib/__tests__/Details.types.test.js +28 -0
- package/lib/__tests__/Heading.test.js +63 -30
- package/lib/__tests__/Heading.types.test.d.ts +3 -0
- package/lib/__tests__/Heading.types.test.js +28 -0
- package/lib/drafts.d.ts +1 -0
- package/lib/drafts.js +13 -0
- package/lib/stories/ActionMenu2.stories.js +433 -0
- package/lib-esm/ActionList/Item.js +1 -1
- package/lib-esm/ActionList2/Divider.d.ts +3 -2
- package/lib-esm/ActionList2/Divider.js +8 -5
- package/lib-esm/ActionList2/Item.js +19 -5
- package/lib-esm/ActionList2/List.js +9 -1
- package/lib-esm/ActionList2/MenuContext.d.ts +10 -0
- package/lib-esm/ActionList2/MenuContext.js +3 -0
- package/lib-esm/ActionList2/Selection.js +12 -1
- package/lib-esm/ActionList2/index.d.ts +1 -2
- package/lib-esm/ActionMenu2.d.ts +313 -0
- package/lib-esm/ActionMenu2.js +67 -0
- package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -1
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -1
- package/lib-esm/Avatar.d.ts +1 -2
- package/lib-esm/Avatar.js +2 -2
- package/lib-esm/BranchName.d.ts +1 -2
- package/lib-esm/BranchName.js +2 -2
- package/lib-esm/Button/Button.d.ts +2 -2
- package/lib-esm/Button/ButtonClose.d.ts +2 -2
- package/lib-esm/Button/ButtonDanger.d.ts +2 -2
- package/lib-esm/Button/ButtonInvisible.d.ts +2 -2
- package/lib-esm/Button/ButtonOutline.d.ts +2 -2
- package/lib-esm/Button/ButtonPrimary.d.ts +2 -2
- package/lib-esm/CircleOcticon.d.ts +35 -35
- package/lib-esm/Details.d.ts +1 -2
- package/lib-esm/Details.js +1 -2
- package/lib-esm/Dialog.d.ts +37 -37
- package/lib-esm/Dropdown.d.ts +8 -72
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +6 -3
- package/lib-esm/FilterList.d.ts +1 -1
- package/lib-esm/Heading.d.ts +1 -2
- package/lib-esm/Heading.js +2 -6
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/ProgressBar.d.ts +16 -11
- package/lib-esm/ProgressBar.js +7 -11
- package/lib-esm/SelectMenu/SelectMenu.d.ts +11 -10
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/Spinner.d.ts +1 -2
- package/lib-esm/Spinner.js +1 -2
- package/lib-esm/TextInputWithTokens.d.ts +2 -1
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/__tests__/Avatar.test.js +4 -2
- package/lib-esm/__tests__/Avatar.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Avatar.types.test.js +16 -0
- package/lib-esm/__tests__/BranchName.types.test.d.ts +3 -0
- package/lib-esm/__tests__/BranchName.types.test.js +13 -0
- package/lib-esm/__tests__/Details.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Details.types.test.js +13 -0
- package/lib-esm/__tests__/Heading.test.js +62 -30
- package/lib-esm/__tests__/Heading.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Heading.types.test.js +13 -0
- package/lib-esm/drafts.d.ts +1 -0
- package/lib-esm/drafts.js +2 -1
- package/lib-esm/stories/ActionMenu2.stories.js +376 -0
- package/package-lock.json +321 -269
- package/package.json +11 -5
- package/script/component-status-project/build.ts +100 -0
- package/script/component-status-project/deploy.rb +142 -0
- package/src/ActionList/Item.tsx +1 -0
- package/src/ActionList2/Divider.tsx +13 -8
- package/src/ActionList2/Item.tsx +13 -3
- package/src/ActionList2/List.tsx +6 -2
- package/src/ActionList2/MenuContext.tsx +6 -0
- package/src/ActionList2/Selection.tsx +11 -1
- package/src/ActionMenu2.tsx +94 -0
- package/src/Avatar.tsx +2 -4
- package/src/BranchName.tsx +3 -3
- package/src/Details.tsx +1 -5
- package/src/Heading.tsx +2 -9
- package/src/ProgressBar.tsx +11 -10
- package/src/Spinner.tsx +1 -3
- package/src/__tests__/Avatar.test.tsx +1 -1
- package/src/__tests__/Avatar.types.test.tsx +11 -0
- package/src/__tests__/BranchName.types.test.tsx +11 -0
- package/src/__tests__/Details.types.test.tsx +11 -0
- package/src/__tests__/Heading.test.tsx +71 -25
- package/src/__tests__/Heading.types.test.tsx +11 -0
- package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +4 -0
- package/src/drafts.ts +1 -0
- package/src/stories/ActionMenu2.stories.tsx +551 -0
- package/stats.html +1 -1
- package/tsconfig.build.json +1 -1
- 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:
|
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"],
|
package/.github/workflows/ci.yml
CHANGED
@@ -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
package/.nvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
v16
|
package/CHANGELOG.md
CHANGED
@@ -1,10 +1,28 @@
|
|
1
1
|
# @primer/components
|
2
2
|
|
3
|
-
##
|
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
|
-
- [#
|
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
|
-
```
|
81
|
-
import
|
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
|
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
|
-
|
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
|
-
```
|
133
|
-
import {
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|