Skip to content

Commit

Permalink
Polish error page styling (vercel#50916)
Browse files Browse the repository at this point in the history
Polish default client error page styling:

* shrink the `line-height` to `2em` for better mobile display
* remove `text-align: left` to let the text center properly

#### After vs Before
(both **app router** and **pages** default client error page)
<p>
<img width="300" alt="image" src="https://github.com/vercel/next.js/assets/4800338/de7260af-7046-4783-8f82-8ac5f39f25b7">
<img width="300" alt="image" src="https://github.com/vercel/next.js/assets/4800338/f4207809-f11f-448d-95ec-0a32b54f3562">
</p>


#### After
(both **app router** and **pages** default client error page)


Closes NEXT-1263
  • Loading branch information
huozhi authored and hydRAnger committed Jun 12, 2023
1 parent 5043340 commit 99636c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
9 changes: 3 additions & 6 deletions packages/next/src/client/components/error-boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ const styles = {
alignItems: 'center',
justifyContent: 'center',
},
desc: {
textAlign: 'left',
},
text: {
fontSize: '14px',
fontWeight: 400,
lineHeight: '3em',
margin: 0,
lineHeight: '28px',
margin: '0 8px',
},
} as const

Expand Down Expand Up @@ -108,7 +105,7 @@ export default function GlobalError({ error }: { error: any }) {
<head></head>
<body>
<div style={styles.error}>
<div style={styles.desc}>
<div>
<h2 style={styles.text}>
Application error: a client-side exception has occurred (see the
browser console for more information).
Expand Down
17 changes: 7 additions & 10 deletions packages/next/src/pages/_error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,24 @@ const styles: Record<string, React.CSSProperties> = {
alignItems: 'center',
justifyContent: 'center',
},

desc: {
display: 'inline-block',
textAlign: 'left',
lineHeight: '48px',
},

h1: {
display: 'inline-block',
margin: '0 20px 0 0',
paddingRight: 23,
fontSize: 24,
fontWeight: 500,
verticalAlign: 'top',
lineHeight: '49px',
},

h2: {
fontSize: 14,
fontWeight: 400,
lineHeight: '49px',
margin: 0,
lineHeight: '28px',
},
wrap: {
display: 'inline-block',
},
}

Expand Down Expand Up @@ -85,7 +82,7 @@ export default class Error<P = {}> extends React.Component<P & ErrorProps> {
: 'Application error: a client-side exception has occurred'}
</title>
</Head>
<div>
<div style={styles.desc}>
<style
dangerouslySetInnerHTML={{
/* CSS minified from
Expand Down Expand Up @@ -118,7 +115,7 @@ export default class Error<P = {}> extends React.Component<P & ErrorProps> {
{statusCode}
</h1>
) : null}
<div style={styles.desc}>
<div style={styles.wrap}>
<h2 style={styles.h2}>
{this.props.title || statusCode ? (
title
Expand Down

0 comments on commit 99636c4

Please sign in to comment.