Skip to content

Commit 452cd4d

Browse files
committed
refactor(web): move table selector into endpoint URL bar
1 parent 7c142f2 commit 452cd4d

2 files changed

Lines changed: 94 additions & 88 deletions

File tree

apps/web/src/app/platform/subgraphs/[name]/url-section.tsx

Lines changed: 64 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -197,100 +197,76 @@ export function SubgraphUrlSection({ tables, apiKeyPrefix }: Props) {
197197
const pathBase = relativePath.slice(0, lastSlash + 1);
198198
const pathTable = relativePath.slice(lastSlash + 1);
199199

200-
const dropdown = (
201-
<div className="meta-dropdown-wrap" ref={dropRef}>
202-
<button
203-
type="button"
204-
className="overview-meta-btn"
205-
onClick={() => setOpen(!open)}
206-
onBlur={(e) => {
207-
if (!dropRef.current?.contains(e.relatedTarget as Node))
208-
setOpen(false);
209-
}}
210-
>
211-
<svg
212-
width="11"
213-
height="11"
214-
viewBox="0 0 16 16"
215-
fill="none"
216-
stroke="currentColor"
217-
strokeWidth="1.5"
218-
strokeLinecap="round"
219-
aria-hidden="true"
220-
>
221-
<rect x="2" y="3" width="12" height="10" rx="1" />
222-
<path d="M2 7h12" />
223-
<path d="M6 3v10" />
224-
</svg>
225-
<span
226-
style={{
227-
width: "1px",
228-
height: "10px",
229-
background: "var(--border)",
230-
display: "inline-block",
231-
flexShrink: 0,
232-
}}
233-
/>
234-
{selectedTable}
235-
<svg
236-
width="8"
237-
height="8"
238-
viewBox="0 0 16 16"
239-
fill="none"
240-
stroke="currentColor"
241-
strokeWidth="2"
242-
strokeLinecap="round"
243-
aria-hidden="true"
244-
>
245-
<path d="M4 6l4 4 4-4" />
246-
</svg>
247-
</button>
248-
{open && (
249-
<div className="meta-dropdown">
250-
{tableNames.map((name) => (
251-
<button
252-
key={name}
253-
type="button"
254-
className={`meta-dropdown-item${name === selectedTable ? " active" : ""}`}
255-
onMouseDown={(e) => {
256-
e.preventDefault();
257-
selectTable(name);
258-
}}
259-
>
260-
{name}
261-
{name === selectedTable && (
262-
<svg
263-
width="12"
264-
height="12"
265-
viewBox="0 0 16 16"
266-
fill="none"
267-
stroke="currentColor"
268-
strokeWidth="2"
269-
strokeLinecap="round"
270-
strokeLinejoin="round"
271-
aria-hidden="true"
272-
>
273-
<path d="M3 8.5l3.5 3.5 6.5-8" />
274-
</svg>
275-
)}
276-
</button>
277-
))}
278-
</div>
279-
)}
280-
</div>
281-
);
282-
283200
return (
284-
<DetailSection title={title} actions={dropdown}>
201+
<DetailSection title={title}>
285202
<div className="sg-api-columns">
286203
{/* Left: URL bar + query parameters */}
287204
<div className="sg-api-card">
288205
<div className="sg-api-url-bar">
289206
<span className="sg-api-method">GET</span>
290-
<span className="sg-api-url">
291-
{pathBase}
292-
<span className="table-segment">{pathTable}</span>
293-
</span>
207+
<div className="meta-dropdown-wrap sg-api-url-select" ref={dropRef}>
208+
<button
209+
type="button"
210+
className="sg-api-url-trigger"
211+
onClick={() => tableNames.length > 1 && setOpen(!open)}
212+
onBlur={(e) => {
213+
if (!dropRef.current?.contains(e.relatedTarget as Node))
214+
setOpen(false);
215+
}}
216+
>
217+
<span className="sg-api-url">
218+
{pathBase}
219+
<span className="table-segment">{pathTable}</span>
220+
</span>
221+
{tableNames.length > 1 && (
222+
<svg
223+
className="sg-api-url-chevron"
224+
width="10"
225+
height="10"
226+
viewBox="0 0 16 16"
227+
fill="none"
228+
stroke="currentColor"
229+
strokeWidth="2"
230+
strokeLinecap="round"
231+
aria-hidden="true"
232+
>
233+
<path d="M4 6l4 4 4-4" />
234+
</svg>
235+
)}
236+
</button>
237+
{open && (
238+
<div className="meta-dropdown">
239+
{tableNames.map((name) => (
240+
<button
241+
key={name}
242+
type="button"
243+
className={`meta-dropdown-item${name === selectedTable ? " active" : ""}`}
244+
onMouseDown={(e) => {
245+
e.preventDefault();
246+
selectTable(name);
247+
}}
248+
>
249+
{name}
250+
{name === selectedTable && (
251+
<svg
252+
width="12"
253+
height="12"
254+
viewBox="0 0 16 16"
255+
fill="none"
256+
stroke="currentColor"
257+
strokeWidth="2"
258+
strokeLinecap="round"
259+
strokeLinejoin="round"
260+
aria-hidden="true"
261+
>
262+
<path d="M3 8.5l3.5 3.5 6.5-8" />
263+
</svg>
264+
)}
265+
</button>
266+
))}
267+
</div>
268+
)}
269+
</div>
294270
<button
295271
type="button"
296272
className={`sg-api-copy-btn${copied ? " copied" : ""}`}

apps/web/src/styles/console.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,6 +2552,36 @@ body:has(.dash) .auth-bar {
25522552
background: var(--code-bg);
25532553
}
25542554

2555+
/* URL bar inline table selector */
2556+
.sg-api-url-select {
2557+
flex: 1;
2558+
min-width: 0;
2559+
}
2560+
.sg-api-url-trigger {
2561+
display: flex;
2562+
align-items: center;
2563+
gap: 6px;
2564+
background: none;
2565+
border: none;
2566+
padding: 0;
2567+
cursor: pointer;
2568+
min-width: 0;
2569+
}
2570+
.sg-api-url-trigger .sg-api-url {
2571+
overflow: hidden;
2572+
text-overflow: ellipsis;
2573+
white-space: nowrap;
2574+
}
2575+
.sg-api-url-chevron {
2576+
color: var(--accent);
2577+
flex-shrink: 0;
2578+
opacity: 0.6;
2579+
transition: opacity 0.15s;
2580+
}
2581+
.sg-api-url-trigger:hover .sg-api-url-chevron {
2582+
opacity: 1;
2583+
}
2584+
25552585
/* Query parameters list */
25562586
.sg-params-section {
25572587
padding: 16px 20px 8px;

0 commit comments

Comments
 (0)