-
Notifications
You must be signed in to change notification settings - Fork 27.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dev-overlay] feat: dev indicator menu route info popover (#76153)
### What? This PR added a menu item's specific info popover for Route. https://github.com/user-attachments/assets/63a3df65-f367-471a-a33a-30a7c6377485 | Static | Dynamic | |--------|--------| |  |  | Closes NDX-815 Closes NDX-849
- Loading branch information
1 parent
5b2de1b
commit 0c946eb
Showing
5 changed files
with
166 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
...experimental/internal/components/errors/dev-tools-indicator/dev-tools-info/route-info.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { DevToolsInfo } from './dev-tools-info' | ||
import { noop as css } from '../../../../helpers/noop-template' | ||
|
||
function StaticRouteContent() { | ||
return ( | ||
<article className="dev-tools-info-article"> | ||
<p className="dev-tools-info-paragraph"> | ||
The path{' '} | ||
<code className="dev-tools-info-code">{window.location.pathname}</code>{' '} | ||
is marked as "static" since it will be prerendered during the build | ||
time. | ||
</p> | ||
<p className="dev-tools-info-paragraph"> | ||
With Static Rendering, routes are rendered at build time, or in the | ||
background after{' '} | ||
<a | ||
className="dev-tools-info-link" | ||
href="https://nextjs.org/docs/app/building-your-application/data-fetching/incremental-static-regeneration" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
data revalidation | ||
</a> | ||
. | ||
</p> | ||
<p className="dev-tools-info-paragraph"> | ||
Static rendering is useful when a route has data that is not | ||
personalized to the user and can be known at build time, such as a | ||
static blog post or a product page. | ||
</p> | ||
</article> | ||
) | ||
} | ||
|
||
function DynamicRouteContent() { | ||
return ( | ||
<article className="dev-tools-info-article"> | ||
<p className="dev-tools-info-paragraph"> | ||
The path{' '} | ||
<code className="dev-tools-info-code">{window.location.pathname}</code>{' '} | ||
is marked as "dynamic" since it will be rendered for each user at{' '} | ||
<strong>request time</strong>. | ||
</p> | ||
<p className="dev-tools-info-paragraph"> | ||
Dynamic rendering is useful when a route has data that is personalized | ||
to the user or has information that can only be known at request time, | ||
such as cookies or the URL's search params. | ||
</p> | ||
<p className="dev-tools-info-paragraph"> | ||
During rendering, if a{' '} | ||
<a | ||
className="dev-tools-info-link" | ||
href="https://nextjs.org/docs/app/building-your-application/rendering/server-components#dynamic-apis" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Dynamic API | ||
</a>{' '} | ||
or a{' '} | ||
<a | ||
className="dev-tools-info-link" | ||
href="https://nextjs.org/docs/app/api-reference/functions/fetch" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
fetch | ||
</a>{' '} | ||
option of{' '} | ||
<code className="dev-tools-info-code">{`{ cache: 'no-store' }`}</code>{' '} | ||
is discovered, Next.js will switch to dynamically rendering the whole | ||
route. | ||
</p> | ||
</article> | ||
) | ||
} | ||
|
||
export function RouteInfo({ | ||
routeType, | ||
isOpen, | ||
setIsOpen, | ||
setPreviousOpen, | ||
...props | ||
}: { | ||
routeType: 'Static' | 'Dynamic' | ||
isOpen: boolean | ||
setIsOpen: (isOpen: boolean) => void | ||
setPreviousOpen: (isOpen: boolean) => void | ||
style?: React.CSSProperties | ||
ref?: React.RefObject<HTMLElement | null> | ||
}) { | ||
const isStaticRoute = routeType === 'Static' | ||
const learnMoreLink = isStaticRoute | ||
? 'https://nextjs.org/docs/app/building-your-application/rendering/server-components#static-rendering-default' | ||
: 'https://nextjs.org/docs/app/building-your-application/rendering/server-components#dynamic-rendering' | ||
return ( | ||
<DevToolsInfo | ||
{...props} | ||
title={`${routeType} Route`} | ||
learnMoreLink={learnMoreLink} | ||
setIsOpen={setIsOpen} | ||
setPreviousOpen={setPreviousOpen} | ||
> | ||
{isStaticRoute ? <StaticRouteContent /> : <DynamicRouteContent />} | ||
</DevToolsInfo> | ||
) | ||
} | ||
|
||
export const DEV_TOOLS_INFO_ROUTE_INFO_STYLES = css` | ||
.dev-tools-info-link { | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters