Skip to content

Commit

Permalink
feat: DevToolsIndicator (#74679)
Browse files Browse the repository at this point in the history
Adding a `DevToolsIndicator` to the bottom left corner of the screen,
replacing the old `ErrorIndicator` and `StaticIndicator`. This PR brings
us 80% of the way to our goal. The remaining tasks are marked with
TODOs.



https://github.com/user-attachments/assets/40061638-7184-4051-85ec-ec6e80ca5102
  • Loading branch information
gaojude authored Jan 9, 2025
1 parent 3d23109 commit f612720
Show file tree
Hide file tree
Showing 10 changed files with 641 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import React from 'react'
import { ShadowPortal } from '../internal/components/ShadowPortal'
import { BuildError } from '../internal/container/BuildError'
import { Errors } from '../internal/container/Errors'
import { StaticIndicator } from '../internal/container/StaticIndicator'
import { Base } from '../internal/styles/Base'
import { ComponentStyles } from '../internal/styles/ComponentStyles'
import { CssReset } from '../internal/styles/CssReset'
Expand Down Expand Up @@ -37,7 +36,7 @@ export default class ReactDevOverlay extends React.PureComponent<
}

render() {
const { state, children, dispatcher } = this.props
const { state, children } = this.props
const { isReactError } = this.state

const hasBuildError = state.buildError != null
Expand Down Expand Up @@ -73,6 +72,7 @@ export default class ReactDevOverlay extends React.PureComponent<
<>
{hasRuntimeErrors ? (
<Errors
isTurbopackEnabled={!!process.env.TURBOPACK}
isAppDir={true}
initialDisplayState={
isReactError ? 'fullscreen' : 'minimized'
Expand All @@ -83,10 +83,6 @@ export default class ReactDevOverlay extends React.PureComponent<
debugInfo={debugInfo}
/>
) : null}

{hasStaticIndicator && (
<StaticIndicator dispatcher={dispatcher} />
)}
</>
)}
</ShadowPortal>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import type { Meta, StoryObj } from '@storybook/react'
import { ErrorIndicator } from './ErrorIndicator'
import { DevToolsIndicator } from './dev-tools-indicator'
import { withShadowPortal } from '../../../storybook/with-shadow-portal'
import type { VersionInfo } from '../../../../../../../../server/dev/parse-version-info'

const meta: Meta<typeof ErrorIndicator> = {
title: 'ErrorIndicator',
component: ErrorIndicator,
const meta: Meta<typeof DevToolsIndicator> = {
title: 'DevToolsIndicator',
component: DevToolsIndicator,
parameters: {
layout: 'centered',
},
decorators: [withShadowPortal],
}

export default meta
type Story = StoryObj<typeof ErrorIndicator>
type Story = StoryObj<typeof DevToolsIndicator>

// Mock version info for stories
const mockVersionInfo: VersionInfo = {
installed: '15.1.2',
staleness: 'stale-major',
}

// Mock error for stories
const mockError = {
Expand Down Expand Up @@ -42,6 +49,7 @@ export const SingleError: Story = {
readyErrors: [mockError],
fullscreen: () => console.log('Fullscreen clicked'),
hide: () => console.log('Hide clicked'),
versionInfo: mockVersionInfo,
},
}

Expand All @@ -51,6 +59,7 @@ export const MultipleErrors: Story = {
readyErrors: [mockError, { ...mockError, id: 2 }, { ...mockError, id: 3 }],
fullscreen: () => console.log('Fullscreen clicked'),
hide: () => console.log('Hide clicked'),
versionInfo: mockVersionInfo,
},
}

Expand All @@ -60,5 +69,6 @@ export const WithStaticIndicator: Story = {
readyErrors: [mockError],
fullscreen: () => console.log('Fullscreen clicked'),
hide: () => console.log('Hide clicked'),
versionInfo: mockVersionInfo,
},
}
Loading

0 comments on commit f612720

Please sign in to comment.