Add document viewer to the compliance portal
Add a full-page viewer at /documents/:alias that resolves the aliased node, exports its watermarked bytes, and renders them: PDFs via react-pdf with page navigation and zoom, images inline, and a download fallback for other file types. Unauthorized visitors see a locked state. Wire the documents list "View" action to link into the viewer (fragments now select alias) and drop the previous open-in-new-tab helpers, since the viewer owns the export. Bound MainLayout to the viewport so the top bar and footer stay fixed and the page area scrolls on its own; the viewer then keeps its toolbar fixed while the PDF body scrolls, matching the design. Add the react-pdf dependency with the pdf.js worker bundled via Vite (for CSP safety) and a headless v2 Separator kit component for the toolbar. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
48
packages/ui/src/v2/Separator/Separator.stories.tsx
Normal file
48
packages/ui/src/v2/Separator/Separator.stories.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
import { Text } from "../typography/Text";
|
||||
|
||||
import { Separator } from "./Separator";
|
||||
|
||||
export default {
|
||||
title: "v2/Separator",
|
||||
component: Separator,
|
||||
};
|
||||
|
||||
export function Horizontal() {
|
||||
return (
|
||||
<div className="flex w-64 flex-col gap-3">
|
||||
<Text size={2}>Above</Text>
|
||||
<Separator />
|
||||
<Text size={2}>Below</Text>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function Vertical() {
|
||||
return (
|
||||
<div className="flex h-8 items-center gap-3">
|
||||
<Text size={2}>Left</Text>
|
||||
<Separator orientation="vertical" />
|
||||
<Text size={2}>Right</Text>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
42
packages/ui/src/v2/Separator/Separator.tsx
Normal file
42
packages/ui/src/v2/Separator/Separator.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
import { Separator as BaseSeparator } from "@base-ui/react/separator";
|
||||
import type { ComponentProps } from "react";
|
||||
|
||||
import { separator } from "./variants";
|
||||
|
||||
export type SeparatorProps = Omit<ComponentProps<typeof BaseSeparator>, "className"> & {
|
||||
className?: string;
|
||||
};
|
||||
|
||||
// A hairline rule (Radix "Separator"). Defaults to horizontal; pass
|
||||
// `orientation="vertical"` for inline dividers (e.g. toolbar groups).
|
||||
export function Separator(props: SeparatorProps) {
|
||||
const { orientation = "horizontal", className, ...rest } = props;
|
||||
|
||||
return (
|
||||
<BaseSeparator
|
||||
orientation={orientation}
|
||||
className={separator({ orientation, className })}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
36
packages/ui/src/v2/Separator/variants.ts
Normal file
36
packages/ui/src/v2/Separator/variants.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
import { tv } from "tailwind-variants/lite";
|
||||
|
||||
// Separator (Radix "Separator" over Base UI's Separator). A hairline rule that
|
||||
// stretches along the cross axis of its flex parent when vertical.
|
||||
export const separator = tv({
|
||||
base: "shrink-0 bg-sand-a3",
|
||||
variants: {
|
||||
orientation: {
|
||||
horizontal: "h-px w-full",
|
||||
vertical: "w-px self-stretch",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
orientation: "horizontal",
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user