Commit 5fe8a00b authored by Jiachi Liu's avatar Jiachi Liu Committed by RobPruzan

[segment explorer] dropdown design for overrides

parent 8b675c9b
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
border-radius: 8px; border-radius: 8px;
font-size: 14px; font-size: 14px;
line-height: 1.4; line-height: 1.4;
min-width: 200px;
pointer-events: none; pointer-events: none;
} }
......
...@@ -14,11 +14,13 @@ interface TooltipProps { ...@@ -14,11 +14,13 @@ interface TooltipProps {
offset?: number offset?: number
bgcolor?: string bgcolor?: string
color?: string color?: string
className?: string
} }
export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>( export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
function Tooltip( function Tooltip(
{ {
className,
children, children,
title, title,
direction = 'top', direction = 'top',
...@@ -53,7 +55,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>( ...@@ -53,7 +55,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
} }
> >
<BaseTooltip.Popup <BaseTooltip.Popup
className="tooltip" className={cx('tooltip', className)}
style={ style={
{ {
backgroundColor: bgcolor, backgroundColor: bgcolor,
......
...@@ -22,6 +22,13 @@ export function SegmentsExplorer({ ...@@ -22,6 +22,13 @@ export function SegmentsExplorer({
export const SEGMENTS_EXPLORER_STYLES = ` export const SEGMENTS_EXPLORER_STYLES = `
[data-nextjs-segments-explorer] { [data-nextjs-segments-explorer] {
min-width: 768px;
margin: -16px; margin: -16px;
} }
@media (max-width: 768px) {
[data-nextjs-segments-explorer] {
min-width: 90vw;
}
}
` `
...@@ -84,14 +84,15 @@ export function useClickOutside( ...@@ -84,14 +84,15 @@ export function useClickOutside(
rootRef: React.RefObject<HTMLElement | null>, rootRef: React.RefObject<HTMLElement | null>,
triggerRef: React.RefObject<HTMLButtonElement | null>, triggerRef: React.RefObject<HTMLButtonElement | null>,
active: boolean, active: boolean,
close: () => void close: () => void,
ownerDocument?: Document
) { ) {
useEffect(() => { useEffect(() => {
if (!active) { if (!active) {
return return
} }
const ownerDocument = rootRef.current?.ownerDocument const ownerDocumentEl = ownerDocument || rootRef.current?.ownerDocument
function handleClickOutside(event: MouseEvent) { function handleClickOutside(event: MouseEvent) {
const target = event.target as HTMLElement const target = event.target as HTMLElement
...@@ -124,15 +125,15 @@ export function useClickOutside( ...@@ -124,15 +125,15 @@ export function useClickOutside(
} }
} }
ownerDocument?.addEventListener('mousedown', handleClickOutside) ownerDocumentEl?.addEventListener('mousedown', handleClickOutside)
ownerDocument?.addEventListener('keydown', handleKeyDown) ownerDocumentEl?.addEventListener('keydown', handleKeyDown)
return () => { return () => {
ownerDocument?.removeEventListener('mousedown', handleClickOutside) ownerDocumentEl?.removeEventListener('mousedown', handleClickOutside)
ownerDocument?.removeEventListener('keydown', handleKeyDown) ownerDocumentEl?.removeEventListener('keydown', handleKeyDown)
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [active]) }, [active, rootRef, triggerRef])
} }
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
......
import type { LoaderTree } from '../lib/app-dir-module' import type { LoaderTree } from '../lib/app-dir-module'
export const BUILTIN_PREFIX = '__next_builtin__'
export function normalizeConventionFilePath( export function normalizeConventionFilePath(
projectDir: string, projectDir: string,
conventionPath: string | undefined conventionPath: string | undefined
...@@ -22,12 +24,18 @@ export function normalizeConventionFilePath( ...@@ -22,12 +24,18 @@ export function normalizeConventionFilePath(
if (nextInternalPrefixRegex.test(relativePath)) { if (nextInternalPrefixRegex.test(relativePath)) {
relativePath = relativePath.replace(nextInternalPrefixRegex, '') relativePath = relativePath.replace(nextInternalPrefixRegex, '')
// Add a special prefix to let segment explorer know it's a built-in component // Add a special prefix to let segment explorer know it's a built-in component
relativePath = `__next_builtin__${relativePath}` relativePath = `${BUILTIN_PREFIX}${relativePath}`
} }
return relativePath return relativePath
} }
export function normalizeBoundaryFilename(filename: string) {
return filename
.replace(new RegExp(`^${BUILTIN_PREFIX}`), '')
.replace(/@boundary$/, '')
}
export function getConventionPathByType( export function getConventionPathByType(
tree: LoaderTree, tree: LoaderTree,
dir: string, dir: string,
......
'use client'
export default function Error() {
return <div>Error @bar</div>
}
import Link from 'next/link'
export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div>
<h2>Layout - /vercel/framework/blog</h2>
{children}
<Link href="/vercel/framework">To /vercel/framework</Link>
</div>
)
}
export default function Page() {
return <div>Page - /vercel/framework/blog</div>
}
import Link from 'next/link'
export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div>
<h1>Layout - /vercel/framework</h1>
{children}
<Link href="/vercel">To /vercel</Link>
</div>
)
}
export default function NotFound() {
return <div>Not Found - /vercel</div>
}
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