Unverified Commit d3ed546f authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

[devtool] fix scrollbar styling (#81814)

* The scrollbar styling was lost before while we enabling the draggable panel. Share that styles between all scrollable content
* Migrate the inline style to css and dynamic css into css variables, so we'll create less dynamic object during rendering.

<video src="https://github.com/user-attachments/assets/df63169f-4846-4c53-91b4-3ca0585dd76d" width="400">
parent afec9909
...@@ -87,6 +87,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({ ...@@ -87,6 +87,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({
ref={dialogRef} ref={dialogRef}
tabIndex={-1} tabIndex={-1}
data-nextjs-dialog data-nextjs-dialog
data-nextjs-scrollable-content
role={role} role={role}
aria-labelledby={ariaLabelledBy} aria-labelledby={ariaLabelledBy}
aria-describedby={ariaDescribedBy} aria-describedby={ariaDescribedBy}
......
...@@ -41,36 +41,6 @@ export const styles = css` ...@@ -41,36 +41,6 @@ export const styles = css`
outline: 0; outline: 0;
} }
[data-nextjs-dialog],
[data-nextjs-dialog] * {
&::-webkit-scrollbar {
width: 6px;
height: 6px;
border-radius: 0 0 1rem 1rem;
margin-bottom: 1rem;
}
&::-webkit-scrollbar-button {
display: none;
}
&::-webkit-scrollbar-track {
border-radius: 0 0 1rem 1rem;
background-color: var(--color-background-100);
}
&::-webkit-scrollbar-thumb {
border-radius: 1rem;
background-color: var(--color-gray-500);
}
}
/* Place overflow: hidden on this so we can break out from [data-nextjs-dialog] */
[data-nextjs-dialog-sizer] {
overflow: hidden;
border-radius: inherit;
}
[data-nextjs-dialog-backdrop] { [data-nextjs-dialog-backdrop] {
opacity: 0; opacity: 0;
transition: opacity var(--transition-duration) var(--timing-overlay); transition: opacity var(--transition-duration) var(--timing-overlay);
......
/* Panel content padding styles */
.panel-content {
padding: 16px;
padding-top: 8px;
overflow: hidden;
}
/* User preferences wrapper styles */
.user-preferences-wrapper {
padding: 20px;
padding-top: 8px;
overflow: hidden;
}
/* Panel route base styles */
.panel-route {
opacity: var(--panel-opacity);
transition: var(--panel-transition);
}
...@@ -29,6 +29,7 @@ import { UserPreferencesBody } from '../components/errors/dev-tools-indicator/de ...@@ -29,6 +29,7 @@ import { UserPreferencesBody } from '../components/errors/dev-tools-indicator/de
import { useHideShortcutStorage } from '../components/errors/dev-tools-indicator/dev-tools-info/preferences' import { useHideShortcutStorage } from '../components/errors/dev-tools-indicator/dev-tools-info/preferences'
import { useShortcuts } from '../hooks/use-shortcuts' import { useShortcuts } from '../hooks/use-shortcuts'
import { useUpdateAllPanelPositions } from '../components/devtools-indicator/devtools-indicator' import { useUpdateAllPanelPositions } from '../components/devtools-indicator/devtools-indicator'
import './panel-router.css'
const MenuPanel = () => { const MenuPanel = () => {
const { setPanel, setSelectedIndex } = usePanelRouterContext() const { setPanel, setSelectedIndex } = usePanelRouterContext()
...@@ -189,12 +190,7 @@ export const PanelRouter = () => { ...@@ -189,12 +190,7 @@ export const PanelRouter = () => {
/> />
} }
> >
<div <div className="panel-content">
style={{
padding: '16px',
paddingTop: '8px',
}}
>
<RouteInfoBody <RouteInfoBody
routerType={state.routerType} routerType={state.routerType}
isStaticRoute={state.staticIndicator} isStaticRoute={state.staticIndicator}
...@@ -246,12 +242,7 @@ export const PanelRouter = () => { ...@@ -246,12 +242,7 @@ export const PanelRouter = () => {
closeOnClickOutside closeOnClickOutside
header={<DevToolsHeader title="Try Turbopack" />} header={<DevToolsHeader title="Try Turbopack" />}
> >
<div <div className="panel-content">
style={{
padding: '16px',
paddingTop: '8px',
}}
>
<TurbopackInfoBody /> <TurbopackInfoBody />
<InfoFooter href="https://nextjs.org/docs/app/api-reference/turbopack" /> <InfoFooter href="https://nextjs.org/docs/app/api-reference/turbopack" />
</div> </div>
...@@ -288,12 +279,7 @@ const UserPreferencesWrapper = ({ ...@@ -288,12 +279,7 @@ const UserPreferencesWrapper = ({
const updateAllPanelPositions = useUpdateAllPanelPositions() const updateAllPanelPositions = useUpdateAllPanelPositions()
return ( return (
<div <div className="user-preferences-wrapper">
style={{
padding: '20px',
paddingTop: '8px',
}}
>
<UserPreferencesBody <UserPreferencesBody
position={state.devToolsPosition} position={state.devToolsPosition}
scale={state.scale} scale={state.scale}
...@@ -358,10 +344,13 @@ function PanelRoute({ ...@@ -358,10 +344,13 @@ function PanelRoute({
> >
<div <div
id="panel-route" id="panel-route"
style={{ className="panel-route"
opacity: rendered ? 1 : 0, style={
transition: `opacity ${MENU_DURATION_MS}ms ${MENU_CURVE}`, {
}} '--panel-opacity': rendered ? 1 : 0,
'--panel-transition': `opacity ${MENU_DURATION_MS}ms ${MENU_CURVE}`,
} as React.CSSProperties
}
> >
{children} {children}
</div> </div>
......
/* Panel container base styles with dynamic positioning and sizing */
.dynamic-panel-container {
position: fixed;
z-index: 2147483646;
outline: none;
top: var(--panel-top, auto);
bottom: var(--panel-bottom, auto);
left: var(--panel-left, auto);
right: var(--panel-right, auto);
width: var(--panel-width);
height: var(--panel-height);
min-width: var(--panel-min-width);
min-height: var(--panel-min-height);
max-width: var(--panel-max-width);
max-height: var(--panel-max-height);
}
/* Panel content container styles */
.panel-content-container {
position: relative;
width: 100%;
height: 100%;
border: 1px solid var(--color-gray-alpha-400);
border-radius: var(--rounded-xl);
background: var(--color-background-100);
display: flex;
flex-direction: column;
}
/* Draggable content area styles */
.draggable-content {
flex: 1;
overflow: auto;
}
...@@ -19,6 +19,7 @@ import { ...@@ -19,6 +19,7 @@ import {
STORE_KEY_SHARED_PANEL_SIZE, STORE_KEY_SHARED_PANEL_SIZE,
} from '../shared' } from '../shared'
import { getIndicatorOffset } from '../utils/indicator-metrics' import { getIndicatorOffset } from '../utils/indicator-metrics'
import './dynamic-panel.css'
function resolveCSSValue( function resolveCSSValue(
value: string | number, value: string | number,
...@@ -235,23 +236,30 @@ export function DynamicPanel({ ...@@ -235,23 +236,30 @@ export function DynamicPanel({
<div <div
tabIndex={-1} tabIndex={-1}
ref={resizeContainerRef} ref={resizeContainerRef}
style={{ className="dynamic-panel-container"
position: 'fixed', style={
zIndex: 2147483646, {
outline: 'none', '--panel-top': positionStyle.top,
...positionStyle, '--panel-bottom': positionStyle.bottom,
'--panel-left': positionStyle.left,
'--panel-right': positionStyle.right,
...(isResizable ...(isResizable
? { ? {
minWidth, '--panel-min-width': minWidth ? `${minWidth}px` : undefined,
minHeight, '--panel-min-height': minHeight
maxWidth, ? `${minHeight}px`
maxHeight, : undefined,
'--panel-max-width': maxWidth ? `${maxWidth}px` : undefined,
'--panel-max-height': maxHeight
? `${maxHeight}px`
: undefined,
} }
: { : {
height: panelSize ? panelSize.height : sizeConfig.height, '--panel-height': `${panelSize ? panelSize.height : sizeConfig.height}px`,
width: panelSize ? panelSize.width : sizeConfig.width, '--panel-width': `${panelSize ? panelSize.width : sizeConfig.width}px`,
}), }),
}} } as React.CSSProperties & Record<string, string | number | undefined>
}
> >
<DragProvider disabled={!draggable}> <DragProvider disabled={!draggable}>
<Draggable <Draggable
...@@ -283,20 +291,18 @@ export function DynamicPanel({ ...@@ -283,20 +291,18 @@ export function DynamicPanel({
<> <>
<div <div
{...containerProps} {...containerProps}
className={`panel-content-container ${containerProps?.className || ''}`}
style={{ style={{
position: 'relative',
width: '100%',
height: '100%',
border: '1px solid var(--color-gray-alpha-400)',
borderRadius: 'var(--rounded-xl)',
background: 'var(--color-background-100)',
display: 'flex',
flexDirection: 'column',
...containerProps?.style, ...containerProps?.style,
}} }}
> >
<DragHandle>{header}</DragHandle> <DragHandle>{header}</DragHandle>
<div style={{ flex: 1, overflow: 'auto' }}>{children}</div> <div
data-nextjs-scrollable-content
className="draggable-content"
>
{children}
</div>
</div> </div>
{isResizable && ( {isResizable && (
<> <>
......
...@@ -10,3 +10,34 @@ ...@@ -10,3 +10,34 @@
* { * {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
} }
/* global reset for draggable content scrollbar styles */
[data-nextjs-scrollable-content],
[data-nextjs-scrollable-content] * {
&::-webkit-scrollbar {
width: 6px;
height: 6px;
border-radius: 0 0 1rem 1rem;
margin-bottom: 1rem;
}
&::-webkit-scrollbar-button {
display: none;
}
&::-webkit-scrollbar-track {
border-radius: 0 0 1rem 1rem;
background-color: var(--color-background-100);
}
&::-webkit-scrollbar-thumb {
border-radius: 1rem;
background-color: var(--color-gray-500);
}
}
/* Place overflow: hidden on this so we can break out from [data-nextjs-dialog] */
[data-nextjs-scrollable-content] {
overflow: hidden;
border-radius: inherit;
}
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