Skip to content

Commit

Permalink
fix dev overlay version indicator style (#66278)
Browse files Browse the repository at this point in the history
Fix the Build Error indicator location, it should be located on the
top-right corner. Align the padding with

### Build Error


![image](https://github.com/vercel/next.js/assets/4800338/835506a5-bf29-4f3e-ae0e-091dc9a7b386)

### Runtime Error


![image](https://github.com/vercel/next.js/assets/4800338/2a61a933-58f2-471e-9d3f-84b3954b1460)
  • Loading branch information
huozhi authored May 28, 2024
1 parent 1415609 commit 1b36d76
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import React from 'react'
import type { VersionInfo } from '../../../../../../server/dev/parse-version-info'

export function VersionStalenessInfo(props: VersionInfo) {
if (!props) return null
const { staleness } = props
let { text, indicatorClass, title } = getStaleness(props)
export function VersionStalenessInfo({
versionInfo,
}: {
versionInfo: VersionInfo | undefined
}) {
if (!versionInfo) return null
const { staleness } = versionInfo
let { text, indicatorClass, title } = getStaleness(versionInfo)

if (!text) return null

return (
<small className="nextjs-container-build-error-version-status">
<span className="nextjs-container-build-error-version-status">
<span className={indicatorClass} />
<small data-nextjs-version-checker title={title}>
{text}
Expand All @@ -26,7 +29,7 @@ export function VersionStalenessInfo(props: VersionInfo) {
</a>
)}
{process.env.TURBOPACK ? ' (turbo)' : ''}
</small>
</span>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const styles = css`
text-align: right;
}
.nextjs-container-build-error-version-status small {
margin-left: var(--size-gap);
font-size: var(--size-font-small);
}
.nextjs-container-build-error-version-status a {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export const BuildError: React.FC<BuildErrorProps> = function BuildError({
<DialogContent>
<DialogHeader className="nextjs-container-errors-header">
<h1 id="nextjs__container_errors_label">{'Build Error'}</h1>
<VersionStalenessInfo versionInfo={versionInfo} />
<p
id="nextjs__container_errors_desc"
className="nextjs__container_errors_desc"
>
Failed to compile
</p>
{versionInfo ? <VersionStalenessInfo {...versionInfo} /> : null}
</DialogHeader>
<DialogBody className="nextjs-container-errors-body">
<Terminal content={message} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export function Errors({
{' error'}
{readyErrors.length < 2 ? '' : 's'}
</small>
{versionInfo ? <VersionStalenessInfo {...versionInfo} /> : null}
<VersionStalenessInfo versionInfo={versionInfo} />
</LeftRightDialogHeader>
<h1 id="nextjs__container_errors_label">
{isServerError ? 'Server Error' : 'Unhandled Runtime Error'}
Expand Down Expand Up @@ -323,6 +323,9 @@ export function Errors({
}

export const styles = css`
.nextjs-container-errors-header {
position: relative;
}
.nextjs-container-errors-header > h1 {
font-size: var(--size-font-big);
line-height: var(--size-font-bigger);
Expand Down Expand Up @@ -406,4 +409,10 @@ export const styles = css`
.nextjs-toast-errors-hide-button:hover {
opacity: 1;
}
.nextjs-container-errors-header
> .nextjs-container-build-error-version-status {
position: absolute;
top: 0;
right: 0;
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export const RootLayoutMissingTagsError: React.FC<RootLayoutMissingTagsErrorProp
>
<DialogContent>
<DialogHeader className="nextjs-container-errors-header">
<VersionStalenessInfo versionInfo={versionInfo} />
<h3 id="nextjs__container_errors_label">
Missing required html tags
</h3>
{versionInfo ? <VersionStalenessInfo {...versionInfo} /> : null}
<p
id="nextjs__container_errors_desc"
className="nextjs__container_errors_desc"
Expand Down

0 comments on commit 1b36d76

Please sign in to comment.