Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function CsvGrid({ filename, text }: { filename: string; text: string }) {
already scales, so a second scale factor inside it would only be a
way to disagree with the rest of the app. */}
<ViewerToolbar>
<span className="px-1 text-xs whitespace-nowrap text-muted-foreground tabular-nums">
<span className="px-1.5 text-xs whitespace-nowrap text-muted-foreground tabular-nums">
{rows.length.toLocaleString()} {rows.length === 1 ? "row" : "rows"}
</span>
<ViewerToolbarSpacer />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,9 @@ export function ViewerRailToggle({
}

/**
* The row of document controls beneath the file viewer's own header. Sized in
* the same idiom as that header so the two read as one piece of chrome.
* The row of document controls beneath the file viewer's own header. Same
* height as that header (`h-10` in both) and no rule between them, so the two
* read as one band of chrome.
*
* Groups are spaced apart rather than ruled apart: the zoom stepper is a single
* bounded control and the rest are ghost buttons, so gaps alone carry the
Expand All @@ -244,7 +245,11 @@ export function ViewerRailToggle({
*/
export function ViewerToolbar({ children }: { children: ReactNode }) {
return (
<div className="@container/viewer-toolbar flex h-10 shrink-0 items-center gap-3 border-t border-border/60 px-2">
// `data-viewer-toolbar` is the hook `viewer-chrome-stroke` selects on.
<div
className="@container/viewer-toolbar flex h-10 shrink-0 items-center gap-3 px-2 pb-3 viewer-chrome-stroke"
data-viewer-toolbar
>
{children}
</div>
);
Expand Down Expand Up @@ -287,6 +292,9 @@ export function ViewerZoomControl({
<ZoomStepperControl
canZoomIn={zoom < max}
canZoomOut={zoom > min}
// Leading the row, the stepper's own box edge is what has to land on the
// filename's column, not a glyph inset like the ghost buttons have.
className="first:ml-1.5"
onZoomIn={() => {
onZoomChange(steppedZoom({ direction: "in", factor: zoom, max, min }));
}}
Expand All @@ -301,6 +309,7 @@ export function ViewerZoomControl({
min={min}
onFit={onFit}
onSelect={onZoomChange}
showCaret={false}
zoom={zoom}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export function XlsxViewer({
allowResizeInReadOnly
className="absolute inset-0"
controller={controller}
rounded={false}
showDefaultToolbar={false}
/>
)}
Expand Down
6 changes: 4 additions & 2 deletions apps/studio/src/client/components/file-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,13 @@ export function FileViewer({

return (
<div className={fileViewerClassName}>
<div className="@container flex min-w-0 shrink-0 items-center gap-2 px-4 py-3">
{/* `h-10 px-2` matches `ViewerToolbar`, which some viewers render right
below this, so the two rows read as one band. */}
<div className="@container flex h-10 min-w-0 shrink-0 items-center gap-2 px-2 viewer-chrome-stroke">
{/* The trigger is the filename, not the space it sits in: as a flex
item it shrinks to the text it holds, so the tooltip is anchored
under the name rather than under the middle of a header-wide box. */}
<div className="flex min-w-0 flex-1">
<div className="flex min-w-0 flex-1 pl-1.5">
<Tooltip>
<TooltipTrigger asChild>
<span className="min-w-0 truncate text-xs font-medium">
Expand Down
9 changes: 7 additions & 2 deletions apps/studio/src/client/components/zoom-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function ZoomLevelMenu({
nested = false,
onFit,
onSelect,
showCaret = true,
zoom,
}: {
compact?: boolean;
Expand All @@ -57,6 +58,7 @@ export function ZoomLevelMenu({
nested?: boolean;
onFit?: () => void;
onSelect: (zoom: number) => void;
showCaret?: boolean;
zoom: number;
}) {
const levels = (
Expand Down Expand Up @@ -110,14 +112,14 @@ export function ZoomLevelMenu({
<DropdownMenu>
<DropdownMenuTrigger
className={cn(
"flex items-center gap-1 px-2 font-medium tabular-nums",
"flex items-center justify-center gap-1 px-2 font-medium tabular-nums",
zoomStepperSegmentClassName,
"data-[state=open]:bg-secondary dark:data-[state=open]:bg-gray-600",
compact ? "min-w-10 text-xs" : "min-w-12 text-sm",
)}
>
{Math.round(zoom * 100)}%
<CaretDownIcon className="size-3" />
{showCaret && <CaretDownIcon className="size-3" />}
</DropdownMenuTrigger>
<DropdownMenuContent align="start" className="min-w-32">
{levels}
Expand Down Expand Up @@ -184,6 +186,7 @@ export function ZoomStepper() {
export function ZoomStepperControl({
canZoomIn = true,
canZoomOut = true,
className,
onReset,
onZoomIn,
onZoomOut,
Expand All @@ -193,6 +196,7 @@ export function ZoomStepperControl({
}: {
canZoomIn?: boolean;
canZoomOut?: boolean;
className?: string;
onReset?: () => void;
onZoomIn: () => void;
onZoomOut: () => void;
Expand All @@ -207,6 +211,7 @@ export function ZoomStepperControl({
className={cn(
"flex items-stretch divide-x divide-border overflow-hidden bg-card button-sheen text-card-foreground shadow-sm dark:bg-gray-700 dark:text-foreground dark:shadow-sm",
compact ? "h-7 rounded-md" : "h-9 rounded-lg",
className,
)}
>
<button
Expand Down
18 changes: 18 additions & 0 deletions apps/studio/src/client/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,24 @@ body {
box-shadow: inset 0 0px 4px var(--tw-inset-shadow-color, rgb(0 0 0 / 0.05));
}

/* Hairline closing the file viewer's chrome band, inset so it costs no height.
* Goes on every chrome row; a row followed by a document toolbar isn't the last
* one, so it drops the stroke and lets that row close the band instead. */
@utility viewer-chrome-stroke {
/* Only the color is themed, so the rule below stays the only one setting
`box-shadow` and wins in both themes. */
--viewer-chrome-stroke-color: rgb(0 0 0 / 0.05);
box-shadow: inset 0 -1px 0 0 var(--viewer-chrome-stroke-color);

:is(.dark *) & {
--viewer-chrome-stroke-color: rgb(255 255 255 / 0.05);
}

&:has(+ * [data-viewer-toolbar]) {
box-shadow: none;
}
}

/* Very subtle top-to-bottom sheen layered over a button's background color:
* lightens the top edge and darkens the bottom edge a touch, giving a soft
* physical depth. Works in both themes since it's a translucent overlay, and
Expand Down