Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
},
"dependencies": {
"@primer/react": "38.0.0",
"@primer/styled-react": "0.2.0",
"next": "^15.2.3",
"react": "18.3.1",
"react-dom": "18.3.1",
"styled-components": "5.x",
"typescript": "^5.9.2"
},
"devDependencies": {
Expand Down
5 changes: 0 additions & 5 deletions examples/nextjs/src/app/global.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
@import '@primer/primitives/dist/css/primitives.css';
@import '@primer/primitives/dist/css/functional/themes/light.css';
@import '@primer/primitives/dist/css/functional/themes/dark.css';
Comment on lines 1 to 3
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the body styles (color and background-color) appears intentional since these are now handled by the BaseStyles component in layout.tsx. However, there's no comment explaining this dependency. Consider adding a comment in this file explaining that body styles are managed by the BaseStyles component to prevent confusion if someone tries to add them back.

See below for a potential fix:

@ -1,3 +1,8 @@
/* 
 * Note: Body styles for `color` and `background-color` are intentionally omitted here.
 * These are managed by the BaseStyles component in layout.tsx.
 * Do not add body color/background-color styles in this file.
 */

Copilot uses AI. Check for mistakes.

body {
color: var(--fgColor-default);
background-color: var(--bgColor-default);
}
Comment on lines -5 to -8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need these on body since BaseStyles only adds them to the root of that component, right? Or is that not the case anymore 👀

Copy link
Member Author

@siddharthkp siddharthkp Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure these styles never worked because the variables are not defined if data-color-mode is not present on <html> or <body> 🙃

BaseStyles only adds them to the root of that component

That is still correct

Eventually, it would make sense for us to offer a way to have ThemeProvider set data-color-mode on <html> instead on the div rendered by ThemeProvider or BaseStyles

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair 😂 lol, those attributes definitely need to be there 😰

11 changes: 4 additions & 7 deletions examples/nextjs/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './global.css'
import {ThemeProvider, BaseStyles} from '@primer/styled-react'
import {StyledComponentsRegistry} from './registry'
import {ThemeProvider, BaseStyles} from '@primer/react'

export const metadata = {
title: 'Next.js',
Expand All @@ -13,11 +12,9 @@ export default function RootLayout({children}: {children: React.ReactNode}) {
// that cause hydration mismatch errors
<html lang="en" suppressHydrationWarning>
<body>
<StyledComponentsRegistry>
<ThemeProvider>
<BaseStyles>{children}</BaseStyles>
</ThemeProvider>
</StyledComponentsRegistry>
<ThemeProvider colorMode="auto">
<BaseStyles style={{backgroundColor: 'var(--bgColor-default)', height: '100vh'}}>{children}</BaseStyles>
</ThemeProvider>
</body>
</html>
)
Expand Down
40 changes: 2 additions & 38 deletions examples/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
'use client'

import {Button, Stack} from '@primer/react'
import {useTheme} from '@primer/styled-react'
import styled from 'styled-components'

const StyledDiv = styled.div(({theme}) => {
return {
padding: theme.space[5],
backgroundColor: theme.colors.btn.primary.bg,
}
})

const ThemeUser = () => {
const {theme} = useTheme()
return (
<div
style={{
padding: theme?.space[5],
backgroundColor: theme?.colors.btn.primary.bg,
}}
>
Hello world
</div>
)
}
import {Button} from '@primer/react'

export default function IndexPage() {
return (
<Stack direction="horizontal">
<Button variant="primary" style={{padding: 'var(--base-size-32)'}}>
Hello world
</Button>
<div style={{padding: 'var(--base-size-32)', backgroundColor: 'var(--button-primary-bgColor-rest)'}}>
Hello world
</div>
<StyledDiv>Hello world</StyledDiv>
<ThemeUser />
</Stack>
)
return <Button>Hello world</Button>
}
25 changes: 0 additions & 25 deletions examples/nextjs/src/app/registry.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading