Skip to content

Commit 8b0b36f

Browse files
Update Primer React to v38 (#72)
1 parent b75584e commit 8b0b36f

File tree

15 files changed

+297
-402
lines changed

15 files changed

+297
-402
lines changed

package-lock.json

Lines changed: 179 additions & 328 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@changesets/cli": "2.27.12",
3131
"@github/prettier-config": "^0.0.6",
3232
"@oddbird/popover-polyfill": "^0.5.2",
33-
"@primer/react": "37.18.0",
33+
"@primer/react": "38.0.0",
3434
"@primer/react-brand": "0.54.0",
3535
"@types/node": "20.19.4",
3636
"@typescript-eslint/parser": "8.29.0",

packages/site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"devDependencies": {
3232
"@github/prettier-config": "^0.0.6",
33-
"@primer/react": "37.11.2",
33+
"@primer/react": "38.0.0",
3434
"@primer/react-brand": "0.54.0",
3535
"@types/node": "20.19.4"
3636
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.Caption {
2+
margin-top: var(--base-size-8);
3+
margin-bottom: var(--base-size-12);
4+
font-size: var(--brand-text-size-100);
5+
color: var(--brand-color-text-default);
6+
}

packages/theme/components/content/caption/Caption.test.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
11
import React from 'react'
22
import {describe, it, expect} from 'vitest'
3-
import {renderWithPrimerThemeProviders} from '../../../test/utils'
3+
import {render} from '@testing-library/react'
44
import {Caption} from './Caption'
55

66
describe('Caption', () => {
77
it('renders children correctly', () => {
8-
const {getByText} = renderWithPrimerThemeProviders(<Caption>Test caption</Caption>)
8+
const {getByText} = render(<Caption>Test caption</Caption>)
99
const el = getByText('Test caption')
1010
expect(el).toBeInTheDocument()
1111
})
1212

1313
it('renders as a span element', () => {
14-
const {getByText} = renderWithPrimerThemeProviders(<Caption>Styled caption</Caption>)
14+
const {getByText} = render(<Caption>Styled caption</Caption>)
1515
const el = getByText('Styled caption')
1616

1717
// Check if it's rendered as a span
1818
expect(el.tagName).toBe('SPAN')
1919
})
2020

2121
it('passes through additional props', () => {
22-
const {getByTestId} = renderWithPrimerThemeProviders(
23-
<Caption data-testid="custom-caption">Caption with props</Caption>,
24-
)
22+
const {getByTestId} = render(<Caption data-testid="custom-caption">Caption with props</Caption>)
2523
const el = getByTestId('custom-caption')
2624
expect(el).toBeInTheDocument()
2725
expect(el).toHaveTextContent('Caption with props')
2826
})
2927

3028
it('handles empty children', () => {
31-
const {getByText} = renderWithPrimerThemeProviders(<Caption></Caption>)
29+
const {getByText} = render(<Caption></Caption>)
3230
// Should render an empty span element
3331
const el = getByText('', {selector: 'span'})
3432
expect(el).toBeInTheDocument()
3533
})
3634

3735
it('handles multiple children', () => {
38-
const {getByText} = renderWithPrimerThemeProviders(
36+
const {getByText} = render(
3937
<Caption>
4038
First part <strong>bold part</strong> last part
4139
</Caption>,
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import React, {PropsWithChildren} from 'react'
2-
import {Text} from '@primer/react'
2+
import styles from './Caption.module.css'
33

44
export function Caption(props: PropsWithChildren) {
5-
return <Text as="span" {...props} sx={{mt: 2, mb: 3, fontSize: 1, color: 'var(--brand-color-text-default)'}} />
5+
const {children, ...rest} = props
6+
return (
7+
<span className={styles.Caption} {...rest}>
8+
{children}
9+
</span>
10+
)
611
}

packages/theme/components/content/dos-and-donts/DosAndDonts.module.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
color: var(--base-color-scale-white-0);
4040
}
4141

42+
.header {
43+
color: var(--fgColor-onEmphasis, var(--color-fg-on-emphasis));
44+
}
45+
4246
.content {
4347
display: flex;
4448
flex-direction: column;
@@ -55,6 +59,6 @@
5559

5660
.indentedContent {
5761
margin: 0;
58-
border-left: 4px solid;
62+
border-left: 4px solid var(--brand-color-border-default);
5963
padding-left: 1rem;
6064
}

packages/theme/components/content/dos-and-donts/DosAndDonts.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import {Box} from '@primer/react'
32
import clsx from 'clsx'
43
import styles from './DosAndDonts.module.css'
54

@@ -39,22 +38,11 @@ type DoDontBaseProps = {
3938
export function DoDontBase({children, title, indented, className, ...rest}: React.PropsWithChildren<DoDontBaseProps>) {
4039
return (
4140
<div className={clsx(`exclude-from-prose`, styles.doDontBase, className)} {...rest}>
42-
<Box
43-
className={styles.header}
44-
sx={{
45-
color: 'var(--fgColor-onEmphasis, var(--color-fg-on-emphasis))',
46-
}}
47-
>
41+
<div className={styles.header}>
4842
<span className={styles.headerText}>{title}</span>
49-
</Box>
43+
</div>
5044
<div className={styles.content}>
51-
{indented ? (
52-
<blockquote className={styles.indentedContent} style={{borderLeftColor: 'var(--brand-color-border-default)'}}>
53-
{children}
54-
</blockquote>
55-
) : (
56-
children
57-
)}
45+
{indented ? <blockquote className={styles.indentedContent}>{children}</blockquote> : children}
5846
</div>
5947
</div>
6048
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.DrawerOverlay {
2+
position: fixed;
3+
inset: 0;
4+
background: rgba(0, 0, 0, 0.5);
5+
z-index: 1;
6+
}
7+
8+
.DrawerPanel {
9+
position: fixed;
10+
top: 0;
11+
right: 0;
12+
bottom: 0;
13+
width: 300px;
14+
background: var(--brand-color-canvas-default, var(--color-canvas-default));
15+
z-index: 1;
16+
display: flex;
17+
flex-direction: column;
18+
}
19+

packages/theme/components/layout/nav-drawer/Drawer.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {PropsWithChildren} from 'react'
2-
import {Box} from '@primer/react'
32
import {AnimatePresence, motion} from 'framer-motion'
43
import {FocusOn} from 'react-focus-on'
4+
import styles from './Drawer.module.css'
55

66
type Drawer = {
77
isOpen: boolean
@@ -22,29 +22,26 @@ export function Drawer({isOpen, onDismiss, children}: PropsWithChildren<Drawer>)
2222
tabIndex={0}
2323
>
2424
<FocusOn returnFocus={true} onEscapeKey={() => onDismiss()}>
25-
<Box
25+
<motion.div
2626
key="overlay"
27-
as={motion.div}
27+
className={styles.DrawerOverlay}
2828
initial={{opacity: 0}}
2929
animate={{opacity: 1}}
3030
exit={{opacity: 0}}
3131
transition={{type: 'tween'}}
3232
onClick={() => onDismiss()}
33-
sx={{top: 0, right: 0, bottom: 0, left: 0, bg: 'rgba(0, 0, 0, 0.5)', position: 'fixed', zIndex: 1}}
3433
/>
3534

36-
<Box
35+
<motion.div
3736
key="drawer"
38-
as={motion.div}
37+
className={styles.DrawerPanel}
3938
initial={{x: '100%'}}
4039
animate={{x: 0}}
4140
exit={{x: '100%'}}
4241
transition={{type: 'tween', duration: 0.2}}
43-
style={{zIndex: 1}}
44-
sx={{width: 300, top: 0, right: 0, bottom: 0, bg: 'gray.0', position: 'fixed'}}
4542
>
4643
{children}
47-
</Box>
44+
</motion.div>
4845
</FocusOn>
4946
</div>
5047
) : null}

0 commit comments

Comments
 (0)