Unverified Commit 49c26c7b authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

[dev-overlay] fix: bottom stack count (#76375)

### Why?

The error overlay's bottom stack count was wrong.

### Before


https://github.com/user-attachments/assets/24f09416-38a9-4b47-8a59-269e9855f851

### After


https://github.com/user-attachments/assets/9f0dff66-e40c-4e68-afda-d149d1b8d895

Closes NDX-827

---------
Co-authored-by: 's avatarZack Tanner <1939140+ztanner@users.noreply.github.com>
parent 801e06ff
export function ErrorOverlayBottomStack({ export function ErrorOverlayBottomStack({
count, errorCount,
activeIdx, activeIdx,
}: { }: {
count: number errorCount: number
activeIdx: number activeIdx: number
}) { }) {
let stackCount = '0' // If there are more than 2 errors to navigate, the stack count should remain at 2.
const stackCount = Math.min(errorCount - activeIdx - 1, 2)
if (count > 1) {
stackCount = '1'
}
if (count > 2) {
stackCount = '2'
}
if (activeIdx === 1) {
stackCount = '1'
}
if (activeIdx > 1) {
stackCount = '0'
}
return ( return (
<div aria-hidden className="error-overlay-bottom-stack"> <div aria-hidden className="error-overlay-bottom-stack">
<div className="stack" data-stack-count={stackCount}> <div
<div className="layer layer1">1</div> className="error-overlay-bottom-stack-stack"
<div className="layer layer2">2</div> data-stack-count={stackCount}
>
<div className="error-overlay-bottom-stack-layer error-overlay-bottom-stack-layer-1">
1
</div>
<div className="error-overlay-bottom-stack-layer error-overlay-bottom-stack-layer-2">
2
</div>
</div> </div>
</div> </div>
) )
} }
export const styles = ` export const styles = `
.layer { .error-overlay-bottom-stack-layer {
width: 100%; width: 100%;
height: var(--stack-layer-height); height: var(--stack-layer-height);
position: relative; position: relative;
...@@ -46,11 +37,11 @@ export const styles = ` ...@@ -46,11 +37,11 @@ export const styles = `
box-shadow 350ms var(--timing-swift); box-shadow 350ms var(--timing-swift);
} }
.layer1 { .error-overlay-bottom-stack-layer-1 {
width: calc(100% - var(--size-6)); width: calc(100% - var(--size-6));
} }
.layer2 { .error-overlay-bottom-stack-layer-2 {
width: calc(100% - var(--size-12)); width: calc(100% - var(--size-12));
z-index: -1; z-index: -1;
} }
...@@ -63,7 +54,7 @@ export const styles = ` ...@@ -63,7 +54,7 @@ export const styles = `
overflow: visible; overflow: visible;
} }
.stack { .error-overlay-bottom-stack-stack {
--stack-layer-height: 44px; --stack-layer-height: 44px;
--stack-layer-height-half: calc(var(--stack-layer-height) / 2); --stack-layer-height-half: calc(var(--stack-layer-height) / 2);
--stack-layer-trim: 13px; --stack-layer-trim: 13px;
...@@ -79,7 +70,7 @@ export const styles = ` ...@@ -79,7 +70,7 @@ export const styles = `
z-index: -1; z-index: -1;
max-width: var(--next-dialog-max-width); max-width: var(--next-dialog-max-width);
.layer { .error-overlay-bottom-stack-layer {
grid-area: 1 / 1; grid-area: 1 / 1;
/* Hide */ /* Hide */
translate: 0 calc(var(--stack-layer-height) * -1); translate: 0 calc(var(--stack-layer-height) * -1);
...@@ -87,32 +78,32 @@ export const styles = ` ...@@ -87,32 +78,32 @@ export const styles = `
&[data-stack-count='1'], &[data-stack-count='1'],
&[data-stack-count='2'] { &[data-stack-count='2'] {
.layer1 { .error-overlay-bottom-stack-layer-1 {
translate: 0 translate: 0
calc(var(--stack-layer-height-half) * -1 - var(--stack-layer-trim)); calc(var(--stack-layer-height-half) * -1 - var(--stack-layer-trim));
} }
} }
&[data-stack-count='2'] { &[data-stack-count='2'] {
.layer2 { .error-overlay-bottom-stack-layer-2 {
translate: 0 calc(var(--stack-layer-trim) * -1 * 2); translate: 0 calc(var(--stack-layer-trim) * -1 * 2);
} }
} }
/* Only the bottom stack should have the shadow */ /* Only the bottom stack should have the shadow */
&[data-stack-count='1'] .layer1 { &[data-stack-count='1'] .error-overlay-bottom-stack-layer-1 {
box-shadow: var(--shadow); box-shadow: var(--shadow);
} }
&[data-stack-count='2'] { &[data-stack-count='2'] {
.layer2 { .error-overlay-bottom-stack-layer-2 {
box-shadow: var(--shadow); box-shadow: var(--shadow);
} }
} }
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
.layer { .error-overlay-bottom-stack-layer {
border-color: var(--color-gray-400); border-color: var(--color-gray-400);
} }
} }
......
...@@ -121,7 +121,7 @@ export function ErrorOverlayLayout({ ...@@ -121,7 +121,7 @@ export function ErrorOverlayLayout({
</DialogFooter> </DialogFooter>
)} )}
<ErrorOverlayBottomStack <ErrorOverlayBottomStack
count={runtimeErrors?.length ?? 0} errorCount={runtimeErrors?.length ?? 0}
activeIdx={activeIdx ?? 0} activeIdx={activeIdx ?? 0}
/> />
</ErrorOverlayDialog> </ErrorOverlayDialog>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment