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