diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/ErrorPagination/styles.ts b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/ErrorPagination/styles.ts deleted file mode 100644 index 0ecfa01d62987..0000000000000 --- a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/ErrorPagination/styles.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { noop as css } from '../../../helpers/noop-template' - -const styles = css` - [data-nextjs-dialog-left-right] { - display: flex; - flex-direction: row; - align-content: center; - align-items: center; - justify-content: space-between; - } - [data-nextjs-dialog-left-right] > nav { - flex: 1; - display: flex; - align-items: center; - margin-right: var(--size-gap); - } - [data-nextjs-dialog-left-right] > nav > button { - display: inline-flex; - align-items: center; - justify-content: center; - - width: calc(var(--size-gap-double) + var(--size-gap)); - height: calc(var(--size-gap-double) + var(--size-gap)); - font-size: 0; - border: none; - background-color: rgba(255, 85, 85, 0.1); - color: var(--color-ansi-red); - cursor: pointer; - transition: background-color 0.25s ease; - } - [data-nextjs-dialog-left-right] > nav > button > svg { - width: auto; - height: calc(var(--size-gap) + var(--size-gap-half)); - } - [data-nextjs-dialog-left-right] > nav > button:hover { - background-color: rgba(255, 85, 85, 0.2); - } - [data-nextjs-dialog-left-right] > nav > button:disabled { - background-color: rgba(255, 85, 85, 0.1); - color: rgba(255, 85, 85, 0.4); - cursor: not-allowed; - } - - [data-nextjs-dialog-left-right] > nav > button:first-of-type { - border-radius: var(--size-gap-half) 0 0 var(--size-gap-half); - margin-right: 1px; - } - [data-nextjs-dialog-left-right] > nav > button:last-of-type { - border-radius: 0 var(--size-gap-half) var(--size-gap-half) 0; - } - - [data-nextjs-dialog-left-right] > button:last-of-type { - border: 0; - padding: 0; - - background-color: transparent; - appearance: none; - - opacity: 0.4; - transition: opacity 0.25s ease; - - color: var(--color-font); - } - [data-nextjs-dialog-left-right] > button:last-of-type:hover { - opacity: 0.7; - } -` - -export { styles } diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-floating-header/error-overlay-floating-header.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-floating-header/error-overlay-floating-header.tsx index bc2e48f6411fc..99074949000f3 100644 --- a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-floating-header/error-overlay-floating-header.tsx +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-floating-header/error-overlay-floating-header.tsx @@ -1,7 +1,7 @@ import type { ReadyRuntimeError } from '../../../helpers/get-error-by-type' import type { VersionInfo } from '../../../../../../../../server/dev/parse-version-info' -import { ErrorPagination } from '../ErrorPagination/ErrorPagination' +import { ErrorOverlayPagination } from '../error-overlay-pagination/error-overlay-pagination' import { VersionStalenessInfo } from '../../VersionStalenessInfo' import { noop as css } from '../../../helpers/noop-template' @@ -21,7 +21,7 @@ export function ErrorOverlayFloatingHeader({ return (
{/* TODO: better passing data instead of nullish coalescing */} - {})} @@ -39,7 +39,7 @@ export const styles = css` width: 100%; position: absolute; - transform: translateY(-32px); + transform: translateY(-42px); outline: none; diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/ErrorPagination/ErrorPagination.stories.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-pagination/error-overlay-pagination.stories.tsx similarity index 61% rename from packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/ErrorPagination/ErrorPagination.stories.tsx rename to packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-pagination/error-overlay-pagination.stories.tsx index b1e73f08ab78b..8cbdeb6a3ce14 100644 --- a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/ErrorPagination/ErrorPagination.stories.tsx +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-pagination/error-overlay-pagination.stories.tsx @@ -1,11 +1,11 @@ import type { Meta, StoryObj } from '@storybook/react' -import { ErrorPagination } from './ErrorPagination' +import { ErrorOverlayPagination } from './error-overlay-pagination' import { withShadowPortal } from '../../../storybook/with-shadow-portal' import { useState } from 'react' -const meta: Meta = { - title: 'ErrorPagination', - component: ErrorPagination, +const meta: Meta = { + title: 'ErrorOverlayPagination', + component: ErrorOverlayPagination, parameters: { layout: 'centered', }, @@ -13,7 +13,7 @@ const meta: Meta = { } export default meta -type Story = StoryObj +type Story = StoryObj // Mock errors for stories const mockErrors = [ @@ -38,10 +38,10 @@ const mockErrors = [ ] export const SingleError: Story = { - render: function ErrorPaginationStory() { + render: function ErrorOverlayPaginationStory() { const [activeIdx, setActiveIdx] = useState(0) return ( - + ) + }, +} diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/ErrorPagination/ErrorPagination.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-pagination/error-overlay-pagination.tsx similarity index 57% rename from packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/ErrorPagination/ErrorPagination.tsx rename to packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-pagination/error-overlay-pagination.tsx index 4b7400259e05f..0349b9c0f26e0 100644 --- a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/ErrorPagination/ErrorPagination.tsx +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-pagination/error-overlay-pagination.tsx @@ -1,5 +1,7 @@ import type { ReadyRuntimeError } from '../../../helpers/get-error-by-type' + import { useCallback, useEffect, useRef, useState } from 'react' +import { noop as css } from '../../../helpers/noop-template' import { LeftArrow } from '../../../icons/LeftArrow' import { RightArrow } from '../../../icons/RightArrow' @@ -9,7 +11,7 @@ type ErrorPaginationProps = { onActiveIndexChange: (index: number) => void } -export function ErrorPagination({ +export function ErrorOverlayPagination({ readyErrors, activeIdx, onActiveIndexChange, @@ -114,35 +116,99 @@ export function ErrorPagination({ }, [nav, activeIdx, readyErrors.length]) return ( -
- -
+ +
+ {activeIdx + 1}/ + + {readyErrors.length} + +
+ + + )} + ) } + +export const styles = css` + .error-overlay-pagination { + display: flex; + justify-content: center; + align-items: center; + + padding: 4px; + gap: 8px; + background: var(--color-background-100); + box-shadow: var(--shadow-sm); + + border: 1px solid var(--color-gray-400); + border-radius: var(--rounded-full); + } + + .error-overlay-pagination-count { + color: var(--color-gray-900); + text-align: center; + font-size: var(--size-font-small); + font-weight: 500; + line-height: 16px; + } + + .error-overlay-pagination-button { + display: flex; + justify-content: center; + align-items: center; + + padding: 4px; + background: var(--color-gray-300); + + border: none; + border-radius: var(--rounded-full); + + &:focus { + outline: none; + } + + &:not(:disabled):active { + background: var(--color-gray-500); + } + + &:disabled { + opacity: 0.5; + cursor: not-allowed; + } + } + + .error-overlay-pagination-button-icon { + color: var(--color-gray-1000); + } +` diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/icons/LeftArrow.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/icons/LeftArrow.tsx index 8a9160063d411..f26d7c870984f 100644 --- a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/icons/LeftArrow.tsx +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/icons/LeftArrow.tsx @@ -1,13 +1,25 @@ -export function LeftArrow({ title }: { title: string }) { +export function LeftArrow({ + title, + className, +}: { + title?: string + className?: string +}) { return ( - + {title} ) diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/icons/RightArrow.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/icons/RightArrow.tsx index d2aaebccb4259..dbdaa8bda49d2 100644 --- a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/icons/RightArrow.tsx +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/icons/RightArrow.tsx @@ -1,13 +1,25 @@ -export function RightArrow({ title }: { title: string }) { +export function RightArrow({ + title, + className, +}: { + title?: string + className?: string +}) { return ( - + {title} ) diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/styles/ComponentStyles.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/styles/ComponentStyles.tsx index a767fae5310f0..035f4e3e37aea 100644 --- a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/styles/ComponentStyles.tsx +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/styles/ComponentStyles.tsx @@ -2,7 +2,7 @@ import { styles as codeFrame } from '../components/CodeFrame/styles' import { styles as dialog } from '../components/Dialog' import { styles as errorLayout } from '../components/Errors/error-overlay-layout/error-overlay-layout' import { styles as bottomStacks } from '../components/Errors/error-overlay-bottom-stacks/error-overlay-bottom-stacks' -import { styles as pagination } from '../components/Errors/ErrorPagination/styles' +import { styles as pagination } from '../components/Errors/error-overlay-pagination/error-overlay-pagination' import { styles as overlay } from '../components/Overlay/styles' import { styles as footer } from '../components/Errors/error-overlay-footer/styles' import { styles as terminal } from '../components/Terminal/styles'