@primer/components 32.1.1-rc.b4502a34 → 33.0.0-rc.9f3670b7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -1
- package/contributor-docs/CONTRIBUTING.md +14 -58
- package/dist/browser.esm.js +104 -108
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +104 -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/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 +11 -0
- package/lib/ActionList2/index.d.ts +1 -2
- package/lib/ActionMenu2.d.ts +310 -0
- package/lib/ActionMenu2.js +91 -0
- 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/Details.d.ts +1 -2
- package/lib/Details.js +1 -3
- package/lib/Dropdown.d.ts +2 -66
- package/lib/Heading.d.ts +1 -2
- package/lib/Heading.js +1 -6
- package/lib/ProgressBar.d.ts +16 -11
- package/lib/ProgressBar.js +6 -10
- package/lib/Spinner.d.ts +1 -2
- package/lib/Spinner.js +1 -3
- 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/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 +9 -0
- package/lib-esm/ActionList2/index.d.ts +1 -2
- package/lib-esm/ActionMenu2.d.ts +310 -0
- package/lib-esm/ActionMenu2.js +67 -0
- 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/Details.d.ts +1 -2
- package/lib-esm/Details.js +1 -2
- package/lib-esm/Dropdown.d.ts +2 -66
- package/lib-esm/Heading.d.ts +1 -2
- package/lib-esm/Heading.js +2 -6
- package/lib-esm/ProgressBar.d.ts +16 -11
- package/lib-esm/ProgressBar.js +7 -11
- package/lib-esm/Spinner.d.ts +1 -2
- package/lib-esm/Spinner.js +1 -2
- 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.json +1 -1
- 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 +9 -0
- 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/drafts.ts +1 -0
- package/src/stories/ActionMenu2.stories.tsx +551 -0
- package/stats.html +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,20 @@
|
|
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
|
|
@@ -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
|