@primer/components 32.1.1-rc.b4502a34 → 33.0.0-rc.b495ba4a

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/dist/browser.esm.js +104 -108
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +104 -108
  5. package/dist/browser.umd.js.map +1 -1
  6. package/docs/content/BranchName.md +6 -5
  7. package/docs/content/Details.md +4 -8
  8. package/docs/content/Heading.md +5 -10
  9. package/docs/content/Label.md +6 -7
  10. package/docs/content/ProgressBar.mdx +7 -6
  11. package/docs/content/Text.md +0 -6
  12. package/docs/content/status.mdx +1 -1
  13. package/docs/content/system-props.mdx +1 -1
  14. package/docs/src/@primer/gatsby-theme-doctocat/nav.yml +1 -1
  15. package/lib/Avatar.d.ts +1 -2
  16. package/lib/Avatar.js +1 -1
  17. package/lib/BranchName.d.ts +1 -2
  18. package/lib/BranchName.js +1 -1
  19. package/lib/Details.d.ts +1 -2
  20. package/lib/Details.js +1 -3
  21. package/lib/Dropdown.d.ts +2 -66
  22. package/lib/Heading.d.ts +1 -2
  23. package/lib/Heading.js +1 -6
  24. package/lib/ProgressBar.d.ts +16 -11
  25. package/lib/ProgressBar.js +6 -10
  26. package/lib/Spinner.d.ts +1 -2
  27. package/lib/Spinner.js +1 -3
  28. package/lib/__tests__/Avatar.test.js +4 -2
  29. package/lib/__tests__/Avatar.types.test.d.ts +3 -0
  30. package/lib/__tests__/Avatar.types.test.js +31 -0
  31. package/lib/__tests__/BranchName.types.test.d.ts +3 -0
  32. package/lib/__tests__/BranchName.types.test.js +28 -0
  33. package/lib/__tests__/Details.types.test.d.ts +3 -0
  34. package/lib/__tests__/Details.types.test.js +28 -0
  35. package/lib/__tests__/Heading.test.js +63 -30
  36. package/lib/__tests__/Heading.types.test.d.ts +3 -0
  37. package/lib/__tests__/Heading.types.test.js +28 -0
  38. package/lib-esm/Avatar.d.ts +1 -2
  39. package/lib-esm/Avatar.js +2 -2
  40. package/lib-esm/BranchName.d.ts +1 -2
  41. package/lib-esm/BranchName.js +2 -2
  42. package/lib-esm/Details.d.ts +1 -2
  43. package/lib-esm/Details.js +1 -2
  44. package/lib-esm/Dropdown.d.ts +2 -66
  45. package/lib-esm/Heading.d.ts +1 -2
  46. package/lib-esm/Heading.js +2 -6
  47. package/lib-esm/ProgressBar.d.ts +16 -11
  48. package/lib-esm/ProgressBar.js +7 -11
  49. package/lib-esm/Spinner.d.ts +1 -2
  50. package/lib-esm/Spinner.js +1 -2
  51. package/lib-esm/__tests__/Avatar.test.js +4 -2
  52. package/lib-esm/__tests__/Avatar.types.test.d.ts +3 -0
  53. package/lib-esm/__tests__/Avatar.types.test.js +16 -0
  54. package/lib-esm/__tests__/BranchName.types.test.d.ts +3 -0
  55. package/lib-esm/__tests__/BranchName.types.test.js +13 -0
  56. package/lib-esm/__tests__/Details.types.test.d.ts +3 -0
  57. package/lib-esm/__tests__/Details.types.test.js +13 -0
  58. package/lib-esm/__tests__/Heading.test.js +62 -30
  59. package/lib-esm/__tests__/Heading.types.test.d.ts +3 -0
  60. package/lib-esm/__tests__/Heading.types.test.js +13 -0
  61. package/package.json +1 -1
  62. package/src/Avatar.tsx +2 -4
  63. package/src/BranchName.tsx +3 -3
  64. package/src/Details.tsx +1 -5
  65. package/src/Heading.tsx +2 -9
  66. package/src/ProgressBar.tsx +11 -10
  67. package/src/Spinner.tsx +1 -3
  68. package/src/__tests__/Avatar.test.tsx +1 -1
  69. package/src/__tests__/Avatar.types.test.tsx +11 -0
  70. package/src/__tests__/BranchName.types.test.tsx +11 -0
  71. package/src/__tests__/Details.types.test.tsx +11 -0
  72. package/src/__tests__/Heading.test.tsx +71 -25
  73. package/src/__tests__/Heading.types.test.tsx +11 -0
  74. package/stats.html +1 -1
@@ -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
  const theme = {
9
10
  breakpoints: ['400px', '640px', '960px', '1280px'],
@@ -46,54 +47,85 @@ describe('Heading', () => {
46
47
  cleanup();
47
48
  });
48
49
  it('respects fontWeight', () => {
49
- expect(render( /*#__PURE__*/React.createElement(Heading, {
50
- fontWeight: "bold",
50
+ expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
51
51
  theme: theme
52
- }))).toHaveStyleRule('font-weight', theme.fontWeights.bold);
53
- expect(render( /*#__PURE__*/React.createElement(Heading, {
54
- fontWeight: "normal",
52
+ }, /*#__PURE__*/React.createElement(Heading, {
53
+ sx: {
54
+ fontWeight: 'bold'
55
+ }
56
+ })))).toHaveStyleRule('font-weight', theme.fontWeights.bold);
57
+ expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
55
58
  theme: theme
56
- }))).toHaveStyleRule('font-weight', theme.fontWeights.normal);
57
- expect(render( /*#__PURE__*/React.createElement(Heading, {
58
- fontWeight: "semibold",
59
+ }, /*#__PURE__*/React.createElement(Heading, {
60
+ sx: {
61
+ fontWeight: 'normal'
62
+ }
63
+ })))).toHaveStyleRule('font-weight', theme.fontWeights.normal);
64
+ expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
59
65
  theme: theme
60
- }))).toHaveStyleRule('font-weight', theme.fontWeights.semibold);
61
- expect(render( /*#__PURE__*/React.createElement(Heading, {
62
- fontWeight: "light",
66
+ }, /*#__PURE__*/React.createElement(Heading, {
67
+ sx: {
68
+ fontWeight: 'semibold'
69
+ }
70
+ })))).toHaveStyleRule('font-weight', theme.fontWeights.semibold);
71
+ expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
63
72
  theme: theme
64
- }))).toHaveStyleRule('font-weight', theme.fontWeights.light);
73
+ }, /*#__PURE__*/React.createElement(Heading, {
74
+ sx: {
75
+ fontWeight: 'light'
76
+ }
77
+ })))).toHaveStyleRule('font-weight', theme.fontWeights.light);
65
78
  });
66
79
  it('respects lineHeight', () => {
67
- expect(render( /*#__PURE__*/React.createElement(Heading, {
68
- lineHeight: "normal",
80
+ expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
69
81
  theme: theme
70
- }))).toHaveStyleRule('line-height', String(theme.lineHeights.normal));
71
- expect(render( /*#__PURE__*/React.createElement(Heading, {
72
- lineHeight: "condensed",
82
+ }, /*#__PURE__*/React.createElement(Heading, {
83
+ sx: {
84
+ lineHeight: 'normal'
85
+ }
86
+ })))).toHaveStyleRule('line-height', String(theme.lineHeights.normal));
87
+ expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
73
88
  theme: theme
74
- }))).toHaveStyleRule('line-height', String(theme.lineHeights.condensed));
75
- expect(render( /*#__PURE__*/React.createElement(Heading, {
76
- lineHeight: "condensedUltra",
89
+ }, /*#__PURE__*/React.createElement(Heading, {
90
+ sx: {
91
+ lineHeight: 'condensed'
92
+ }
93
+ })))).toHaveStyleRule('line-height', String(theme.lineHeights.condensed));
94
+ expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
77
95
  theme: theme
78
- }))).toHaveStyleRule('line-height', String(theme.lineHeights.condensedUltra));
96
+ }, /*#__PURE__*/React.createElement(Heading, {
97
+ sx: {
98
+ lineHeight: 'condensedUltra'
99
+ }
100
+ })))).toHaveStyleRule('line-height', String(theme.lineHeights.condensedUltra));
79
101
  });
80
102
  it('respects fontFamily="mono"', () => {
81
- expect(render( /*#__PURE__*/React.createElement(Heading, {
82
- fontFamily: "mono",
103
+ expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
83
104
  theme: theme
84
- }))).toHaveStyleRule('font-family', theme.fonts.mono);
105
+ }, /*#__PURE__*/React.createElement(Heading, {
106
+ sx: {
107
+ fontFamily: 'mono'
108
+ }
109
+ })))).toHaveStyleRule('font-family', theme.fonts.mono);
85
110
  });
86
111
  it('renders fontSize', () => {
87
112
  for (const fontSize of theme.fontSizes) {
88
- expect(render( /*#__PURE__*/React.createElement(Heading, {
89
- fontSize: fontSize,
113
+ expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
90
114
  theme: theme
91
- }))).toHaveStyleRule('font-size', `${fontSize}`);
115
+ }, /*#__PURE__*/React.createElement(Heading, {
116
+ sx: {
117
+ fontSize
118
+ }
119
+ })))).toHaveStyleRule('font-size', `${fontSize}`);
92
120
  }
93
121
  });
94
122
  it('respects the "fontStyle" prop', () => {
95
- expect(render( /*#__PURE__*/React.createElement(Heading, {
96
- fontStyle: "italic"
97
- }))).toHaveStyleRule('font-style', 'italic');
123
+ expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
124
+ theme: theme
125
+ }, /*#__PURE__*/React.createElement(Heading, {
126
+ sx: {
127
+ fontStyle: 'italic'
128
+ }
129
+ })))).toHaveStyleRule('font-style', 'italic');
98
130
  });
99
131
  });
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare function shouldAcceptCallWithNoProps(): JSX.Element;
3
+ export declare function shouldNotAcceptSystemProps(): JSX.Element;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import Heading from '../Heading';
3
+ export function shouldAcceptCallWithNoProps() {
4
+ return /*#__PURE__*/React.createElement(Heading, null);
5
+ }
6
+ shouldAcceptCallWithNoProps.displayName = "shouldAcceptCallWithNoProps";
7
+ export function shouldNotAcceptSystemProps() {
8
+ // @ts-expect-error system props should not be accepted
9
+ return /*#__PURE__*/React.createElement(Heading, {
10
+ backgroundColor: "thistle"
11
+ });
12
+ }
13
+ shouldNotAcceptSystemProps.displayName = "shouldNotAcceptSystemProps";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/components",
3
- "version": "32.1.1-rc.b4502a34",
3
+ "version": "33.0.0-rc.b495ba4a",
4
4
  "description": "Primer react components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
package/src/Avatar.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import styled from 'styled-components'
2
- import {COMMON, get, SystemCommonProps} from './constants'
2
+ import {get} from './constants'
3
3
  import sx, {SxProp} from './sx'
4
4
  import {ComponentProps} from './utils/types'
5
5
 
@@ -12,8 +12,7 @@ type StyledAvatarProps = {
12
12
  src: string
13
13
  /** Provide alt text when the Avatar is used without the user's name next to it. */
14
14
  alt?: string
15
- } & SystemCommonProps &
16
- SxProp
15
+ } & SxProp
17
16
 
18
17
  function getBorderRadius({size, square}: StyledAvatarProps) {
19
18
  if (square) {
@@ -32,7 +31,6 @@ const Avatar = styled.img.attrs<StyledAvatarProps>(props => ({
32
31
  line-height: ${get('lineHeights.condensedUltra')};
33
32
  vertical-align: middle;
34
33
  border-radius: ${props => getBorderRadius(props)};
35
- ${COMMON};
36
34
  ${sx}
37
35
  `
38
36
 
@@ -1,9 +1,9 @@
1
1
  import styled from 'styled-components'
2
- import {COMMON, get, SystemCommonProps} from './constants'
2
+ import {get} from './constants'
3
3
  import sx, {SxProp} from './sx'
4
4
  import {ComponentProps} from './utils/types'
5
5
 
6
- const BranchName = styled.a<SystemCommonProps & SxProp>`
6
+ const BranchName = styled.a<SxProp>`
7
7
  display: inline-block;
8
8
  padding: 2px 6px;
9
9
  font-size: ${get('fontSizes.0')};
@@ -11,7 +11,7 @@ const BranchName = styled.a<SystemCommonProps & SxProp>`
11
11
  color: ${get('colors.fg.muted')};
12
12
  background-color: ${get('colors.accent.subtle')};
13
13
  border-radius: ${get('radii.2')};
14
- ${COMMON};
14
+
15
15
  ${sx};
16
16
  `
17
17
 
package/src/Details.tsx CHANGED
@@ -1,11 +1,8 @@
1
1
  import styled from 'styled-components'
2
- import {COMMON, SystemCommonProps} from './constants'
3
2
  import sx, {SxProp} from './sx'
4
3
  import {ComponentProps} from './utils/types'
5
4
 
6
- type StyledDetailsProps = SystemCommonProps & SxProp
7
-
8
- const Details = styled.details<StyledDetailsProps>`
5
+ const Details = styled.details<SxProp>`
9
6
  & > summary {
10
7
  list-style: none;
11
8
  }
@@ -13,7 +10,6 @@ const Details = styled.details<StyledDetailsProps>`
13
10
  display: none;
14
11
  }
15
12
 
16
- ${COMMON}
17
13
  ${sx};
18
14
  `
19
15
 
package/src/Heading.tsx CHANGED
@@ -1,21 +1,14 @@
1
1
  import styled from 'styled-components'
2
- import {COMMON, get, SystemCommonProps, SystemTypographyProps, TYPOGRAPHY} from './constants'
2
+ import {get} from './constants'
3
3
  import sx, {SxProp} from './sx'
4
- import theme from './theme'
5
4
  import {ComponentProps} from './utils/types'
6
5
 
7
- const Heading = styled.h2<SystemTypographyProps & SystemCommonProps & SxProp>`
6
+ const Heading = styled.h2<SxProp>`
8
7
  font-weight: ${get('fontWeights.bold')};
9
8
  font-size: ${get('fontSizes.5')};
10
9
  margin: 0;
11
- ${TYPOGRAPHY};
12
- ${COMMON};
13
10
  ${sx};
14
11
  `
15
12
 
16
- Heading.defaultProps = {
17
- theme
18
- }
19
-
20
13
  export type HeadingProps = ComponentProps<typeof Heading>
21
14
  export default Heading
@@ -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
+ }