@primer/gatsby-theme-doctocat 4.2.0 → 4.2.2

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @primer/gatsby-theme-doctocat
2
2
 
3
+ ## 4.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`da5c046`](https://github.com/primer/doctocat/commit/da5c04600843876e6b905fa439d8cd8ee73bdf91) [#501](https://github.com/primer/doctocat/pull/501) Thanks [@josepmartins](https://github.com/josepmartins)! - Adjust accessibilty labels content
8
+
9
+ ## 4.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`6c4da9e`](https://github.com/primer/doctocat/commit/6c4da9e5787862460972b2af75a27e5909093a05) [#498](https://github.com/primer/doctocat/pull/498) Thanks [@colebemis](https://github.com/colebemis)! - Fix live examples disappearing on hard reload
14
+
3
15
  ## 4.2.0
4
16
 
5
17
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/gatsby-theme-doctocat",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -70,7 +70,6 @@
70
70
  "react-addons-text-content": "^0.0.4",
71
71
  "react-element-to-jsx-string": "^14.0.3",
72
72
  "react-focus-on": "^3.3.0",
73
- "react-frame-component": "^5.2.1",
74
73
  "react-helmet": "^6.1.0",
75
74
  "react-live": "^2.1.2",
76
75
  "react-measure": "^2.3.0",
@@ -0,0 +1,39 @@
1
+ import {Label, StyledOcticon} from '@primer/react'
2
+ import {AccessibilityInsetIcon} from '@primer/octicons-react'
3
+ import React from 'react'
4
+
5
+ function AccessibilityLabel({a11yReviewed, size, short}) {
6
+ return (
7
+ <>
8
+ {a11yReviewed ? (
9
+ <Label
10
+ size={size}
11
+ sx={{
12
+ display: 'flex',
13
+ alignItems: 'center',
14
+ gap: 1,
15
+ backgroundColor: 'done.subtle',
16
+ fontWeight: 'normal',
17
+ borderColor: 'transparent'
18
+ }}
19
+ >
20
+ <StyledOcticon icon={AccessibilityInsetIcon} sx={{fill: 'done.fg'}} />
21
+ {short ? 'Reviewed' : 'Reviewed for accessibility'}
22
+ </Label>
23
+ ) : (
24
+ <Label
25
+ size={size}
26
+ sx={{
27
+ backgroundColor: 'neutral.subtle',
28
+ fontWeight: 'normal',
29
+ borderColor: 'transparent'
30
+ }}
31
+ >
32
+ {short ? 'Not reviewed' : 'Not reviewed for accessibility'}
33
+ </Label>
34
+ )}
35
+ </>
36
+ )
37
+ }
38
+
39
+ export default AccessibilityLabel
@@ -1,20 +1,24 @@
1
1
  import React from 'react'
2
- import FrameComponent, {FrameContextConsumer} from 'react-frame-component'
2
+ import ReactDOM from 'react-dom'
3
3
  import {StyleSheetManager} from 'styled-components'
4
4
  import Measure from 'react-measure'
5
5
 
6
6
  function Frame({children}) {
7
7
  const [height, setHeight] = React.useState('auto')
8
+ const [iframeRef, setIframeRef] = React.useState(null)
9
+ const contentDocument = iframeRef ? iframeRef.contentWindow.document : null
10
+
8
11
  return (
9
- <FrameComponent style={{width: '100%', border: 0, borderRadius: 6, height}}>
10
- <FrameContextConsumer>
11
- {({document}) => {
12
- // By default, styled-components injects styles in the head of the page.
13
- // However, styles from the page's head don't apply inside iframes.
14
- // We're using StyleSheetManager to make styled-components inject styles
15
- // into the head of the iframe instead.
16
- return (
17
- <StyleSheetManager target={document.head}>
12
+ // eslint-disable-next-line jsx-a11y/iframe-has-title
13
+ <iframe ref={setIframeRef} style={{width: '100%', border: 0, borderRadius: 6, height}}>
14
+ {
15
+ // By default, styled-components injects styles in the head of the page.
16
+ // However, styles from the page's head don't apply inside iframes.
17
+ // We're using StyleSheetManager to make styled-components inject styles
18
+ // into the head of the iframe instead.
19
+ contentDocument !== null &&
20
+ ReactDOM.createPortal(
21
+ <StyleSheetManager target={contentDocument.head}>
18
22
  <Measure
19
23
  // iframes don't adjust to the height of their content by default.
20
24
  // We're using Measure to calculate the size of the content
@@ -24,11 +28,11 @@ function Frame({children}) {
24
28
  >
25
29
  {({measureRef}) => <div ref={measureRef}>{children}</div>}
26
30
  </Measure>
27
- </StyleSheetManager>
31
+ </StyleSheetManager>,
32
+ contentDocument.body
28
33
  )
29
- }}
30
- </FrameContextConsumer>
31
- </FrameComponent>
34
+ }
35
+ </iframe>
32
36
  )
33
37
  }
34
38
 
@@ -1,6 +1,5 @@
1
1
  import componentMetadata from '@primer/component-metadata'
2
- import {Box, Heading, Text, Label, StyledOcticon} from '@primer/react'
3
- import {AccessibilityInsetIcon} from '@primer/octicons-react'
2
+ import {Box, Heading, Text} from '@primer/react'
4
3
  import React from 'react'
5
4
  import Head from './head'
6
5
  import Header, {HEADER_HEIGHT} from './header'
@@ -10,6 +9,7 @@ import SourceLink from './source-link'
10
9
  import RailsLink from './rails-link'
11
10
  import ReactLink from './react-link'
12
11
  import StatusLabel from './status-label'
12
+ import AccessibilityLabel from './accessibility-label'
13
13
  import LookbookLink from './lookbook-link'
14
14
  import StorybookLink from './storybook-link'
15
15
  import FigmaLink from './figma-link'
@@ -81,11 +81,9 @@ function Layout({children, pageContext}) {
81
81
  </Box>
82
82
  ) : null}
83
83
  <Box sx={{width: '100%', maxWidth: '960px'}}>
84
- <Box sx={{mb: 7}}>
84
+ <Box sx={{mb: 4}}>
85
85
  <Box sx={{alignItems: 'center', display: 'flex'}}>
86
- <Heading as="h1" sx={{mb: 2}}>
87
- {title}
88
- </Heading>{' '}
86
+ <Heading as="h1">{title}</Heading>{' '}
89
87
  </Box>
90
88
  {description ? <Box sx={{fontSize: 3, mb: 3}}>{description}</Box> : null}
91
89
  <Box
@@ -93,43 +91,32 @@ function Layout({children, pageContext}) {
93
91
  display: 'flex',
94
92
  flexWrap: 'wrap',
95
93
  columnGap: 3,
94
+ mb: 7,
95
+ mt: 2,
96
96
  rowGap: 3,
97
97
  alignItems: 'center',
98
98
  fontSize: 1
99
99
  }}
100
100
  >
101
101
  {status ? (
102
- <Box as={'ul'} sx={{display: 'flex', gap: 1, alignItems: 'center', m: 0, p: 0, paddingInline: 0}}>
103
- <StatusLabel size="large" status={status} />
104
- {a11yReviewed ? (
105
- <Label
106
- as={'li'}
107
- size="large"
108
- sx={{
109
- display: 'flex',
110
- alignItems: 'center',
111
- gap: 1,
112
- backgroundColor: 'done.subtle',
113
- fontWeight: 'normal',
114
- borderColor: 'transparent'
115
- }}
116
- >
117
- <StyledOcticon icon={AccessibilityInsetIcon} sx={{fill: 'done.fg'}} />
118
- Reviewed by accessibility team
119
- </Label>
120
- ) : (
121
- <Label
122
- size="large"
123
- as={'li'}
124
- sx={{
125
- backgroundColor: 'neutral.subtle',
126
- fontWeight: 'normal',
127
- borderColor: 'transparent'
128
- }}
129
- >
130
- Review pending by accessibility team
131
- </Label>
132
- )}
102
+ <Box
103
+ as={'ul'}
104
+ sx={{
105
+ display: 'flex',
106
+ gap: 1,
107
+ alignItems: 'center',
108
+ m: 0,
109
+ p: 0,
110
+ paddingInline: 0,
111
+ listStyle: 'none'
112
+ }}
113
+ >
114
+ <li>
115
+ <StatusLabel size="large" status={status} />
116
+ </li>
117
+ <li>
118
+ <AccessibilityLabel size="large" a11yReviewed={a11yReviewed} />
119
+ </li>
133
120
  </Box>
134
121
  ) : null}
135
122
  {source || storybook || lookbook || figma || rails || react ? (
@@ -28,7 +28,6 @@ function StatusLabel({status, size}) {
28
28
 
29
29
  return (
30
30
  <Label
31
- as={'li'}
32
31
  size={size || 'small'}
33
32
  sx={{
34
33
  display: 'inline-flex',