Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

style(frontend): tune dropzone frame and add scope-color overrides

andrewhuhhffc06558ae56
diff --git a/frontend/src/components/v3/generic/Empty/Empty.stories.tsx b/frontend/src/components/v3/generic/Empty/Empty.stories.tsx
index 489d413d56..ddf05c4860 100644
--- a/frontend/src/components/v3/generic/Empty/Empty.stories.tsx
+++ b/frontend/src/components/v3/generic/Empty/Empty.stories.tsx
@@ -29,11 +29,14 @@ import {
* so the empty state reads as visually distinct from its container.
*
* **`frame` prop** — an alternate, SVG-drawn frame for surfaces that want a more
- * pronounced dashed (or solid) boundary than the CSS border gives — e.g. a
- * drag-and-drop target. `stroke-dasharray` allows a longer dash/gap than
- * `border-style: dashed` supports, without losing the rounded corners the way
- * `border-image` would. Opt-in and independent from `className="border"`; existing
- * consumers are unaffected. Recolor with `frameClassName` (defaults to `text-border`).
+ * deliberate dashed (or solid) boundary than the CSS border gives — e.g. a
+ * drag-and-drop target. `stroke-dasharray` allows precise control over dash and
+ * gap length, something `border-style: dashed` doesn't offer, without losing the
+ * rounded corners the way `border-image` would. Opt-in and independent from
+ * `className="border"`; `frame="none"` consumers render byte-for-byte unchanged.
+ * Recolor with `frameClassName` (defaults to `text-border`). The framed variant
+ * also adds a small outer margin and a hover tint, since it's meant for
+ * interactive surfaces (see `FileDropzone`) rather than static empty states.
*/
const meta = {
title: "Generic/Empty",
@@ -241,18 +244,18 @@ export const InsideCard: Story = {
)
};
-export const WithSvgFrame: Story = {
- name: "Variant: SVG Frame (Dashed / Solid)",
+export const WithFrame: Story = {
+ name: "Variant: Frame (Dashed / Solid)",
parameters: {
docs: {
description: {
story:
- 'Pass `frame="dashed"` or `frame="solid"` for the SVG-drawn boundary — used by `FileDropzone` for its passive (dashed) and drag-active (solid, recolored via `frameClassName`) states. Prefer this over `className="border"` when the dash proportions need to stand out, such as an interactive drop target.'
+ 'Pass `frame="dashed"` or `frame="solid"` for an SVG-drawn frame — used by `FileDropzone` for its passive (dashed) and drag-active (solid, recolored via `frameClassName`) states. Prefer this over `className="border"` when the dash proportions need to stand out, such as an interactive drop target.'
}
}
},
render: () => (
- <div className="flex gap-4">
+ <div className="flex flex-wrap gap-4">
<Empty frame="dashed" className="w-72">
<EmptyHeader>
<EmptyMedia variant="icon">
diff --git a/frontend/src/components/v3/generic/Empty/Empty.tsx b/frontend/src/components/v3/generic/Empty/Empty.tsx
index 2a2669d16b..7289405604 100644
--- a/frontend/src/components/v3/generic/Empty/Empty.tsx
+++ b/frontend/src/components/v3/generic/Empty/Empty.tsx
@@ -3,17 +3,45 @@ import { cva, VariantProps } from "cva";
import { cn } from "../../utils";
type EmptyFrameProps = {
- // Draws the dashed/solid frame with an SVG rect instead of a CSS border.
- // CSS `border-style: dashed` has no dash-length control; `stroke-dasharray`
- // does, and unlike `border-image` it still respects the rounded corners.
- // Opt-in and off by default so existing `className="border"` consumers
- // (the CSS-border convention documented in this file's stories) render
- // unchanged — this is a distinct, additive frame for new call sites.
+ // SVG-drawn dashed/solid frame — `stroke-dasharray` controls dash proportions
+ // in a way `border-style: dashed` can't. Opt-in and independent from the
+ // `className="border"` CSS-border convention; frame="none" consumers are
+ // byte-for-byte unchanged (no wrapper, no hover, no extra padding).
frame?: "none" | "dashed" | "solid";
- // Merged onto the frame's default `text-border` (e.g. to recolor on drag-active)
+ // Stroke color via `currentColor` (e.g. `text-info` on drag-active)
frameClassName?: string;
};
+const FRAME = { stroke: 2, dash: "4 2", radius: 6 } as const;
+
+function EmptyFrameSvg({ dashed, className }: { dashed: boolean; className?: string }) {
+ const inset = FRAME.stroke / 2;
+
+ return (
+ <svg
+ aria-hidden="true"
+ className={cn(
+ "pointer-events-none absolute inset-0 size-full text-border transition-colors duration-75",
+ className
+ )}
+ >
+ <rect
+ x={inset}
+ y={inset}
+ rx={FRAME.radius}
+ fill="none"
+ stroke="currentColor"
+ strokeWidth={FRAME.stroke}
+ strokeDasharray={dashed ? FRAME.dash : undefined}
+ style={{
+ width: `calc(100% - ${FRAME.stroke}px)`,
+ height: `calc(100% - ${FRAME.stroke}px)`
+ }}
+ />
+ </svg>
+ );
+}
+
function Empty({
className,
frame = "none",
@@ -21,43 +49,27 @@ function Empty({
children,
...props
}: React.ComponentProps<"div"> & EmptyFrameProps) {
+ const hasFrame = frame !== "none";
+
const box = (
<div
data-slot="empty"
className={cn(
- "flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-md border-dashed border-border bg-container p-6 text-center text-balance text-foreground shadow-inner md:p-12",
- frame !== "none" && "relative",
+ "flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-md bg-container p-6 text-center text-balance text-foreground shadow-inner md:p-12",
+ frame === "none" && "border-dashed border-border",
+ hasFrame && "relative transition-colors duration-200 hover:bg-container-hover",
className
)}
{...props}
>
- {frame !== "none" && (
- <svg
- aria-hidden="true"
- className={cn(
- "pointer-events-none absolute inset-0 size-full text-border transition-colors duration-75",
- frameClassName
- )}
- >
- <rect
- x="1"
- y="1"
- rx="4"
- fill="none"
- stroke="currentColor"
- strokeWidth="2"
- strokeDasharray={frame === "dashed" ? "10 6" : undefined}
- style={{ width: "calc(100% - 2px)", height: "calc(100% - 2px)" }}
- />
- </svg>
- )}
+ {hasFrame && <EmptyFrameSvg dashed={frame === "dashed"} className={frameClassName} />}
{children}
</div>
);
// Only the SVG-framed variant gets outer breathing room — the plain CSS-border
// convention (className="border") keeps its existing flush layout untouched.
- if (frame === "none") return box;
+ if (!hasFrame) return box;
return <div className="p-0.5">{box}</div>;
}
diff --git a/frontend/src/components/v3/generic/FileDropzone/FileDropzone.stories.tsx b/frontend/src/components/v3/generic/FileDropzone/FileDropzone.stories.tsx
index 32f3b91990..6c4ed74eb7 100644
--- a/frontend/src/components/v3/generic/FileDropzone/FileDropzone.stories.tsx
+++ b/frontend/src/components/v3/generic/FileDropzone/FileDropzone.stories.tsx
@@ -19,6 +19,13 @@ import { FileDropzone } from "./FileDropzone";
* visible, size), and `onFileRemove` to expose a remove action on each row.
* Omit `files` when selection immediately advances to another step, as in the
* secrets import dialog.
+ *
+ * Colors default to the `info` tint. When the surface belongs to a specific
+ * scope (e.g. a project-level dialog), override `accentClassName`,
+ * `activeFrameClassName`, and `activeEmptyClassName` with that scope's color
+ * (`text-project`, `bg-project/10`, etc.) per the design system's scope-color
+ * convention. `emptyClassName` and `frameClassName` are open escape hatches
+ * for anything else.
*/
const meta = {
title: "Generic/FileDropzone",
@@ -122,6 +129,28 @@ export const WithFile: Story = {
}
};
+export const ScopedAccent: Story = {
+ name: "Variant: Scoped Accent",
+ parameters: {
+ docs: {
+ description: {
+ story:
+ "Override `accentClassName` / `activeFrameClassName` / `activeEmptyClassName` to match the surface's scope color instead of the `info` default — e.g. `text-project` for a project-settings dialog like the KMS backup upload."
+ }
+ }
+ },
+ render: (args) => (
+ <FileDropzone
+ {...args}
+ accept=".txt"
+ description=".infisical.txt backup file"
+ accentClassName="text-project"
+ activeFrameClassName="text-project"
+ activeEmptyClassName="bg-project/10"
+ />
+ )
+};
+
export const Disabled: Story = {
name: "Variant: Disabled",
parameters: {
diff --git a/frontend/src/components/v3/generic/FileDropzone/FileDropzone.tsx b/frontend/src/components/v3/generic/FileDropzone/FileDropzone.tsx
index f75543862c..07b7064156 100644
--- a/frontend/src/components/v3/generic/FileDropzone/FileDropzone.tsx
+++ b/frontend/src/components/v3/generic/FileDropzone/FileDropzone.tsx
@@ -35,7 +35,18 @@ type FileDropzoneProps = {
dropTitle?: ReactNode;
description?: ReactNode;
isDisabled?: boolean;
+ /** Layout/width on the outer dropzone wrapper */
className?: string;
+ /** Merged onto the inner `Empty` surface (background, padding, etc.) */
+ emptyClassName?: string;
+ /** SVG frame stroke at rest — forwarded to `Empty`'s `frameClassName` */
+ frameClassName?: string;
+ /** Frame stroke while dragging — defaults to `text-info` */
+ activeFrameClassName?: string;
+ /** Surface tint while dragging — defaults to `bg-info/10` */
+ activeEmptyClassName?: string;
+ /** Accent on the default "Choose file" label — defaults to `text-info` */
+ accentClassName?: string;
};
function FileDropzone({
@@ -48,7 +59,12 @@ function FileDropzone({
dropTitle,
description,
isDisabled,
- className
+ className,
+ emptyClassName,
+ frameClassName,
+ activeFrameClassName = "text-info",
+ activeEmptyClassName = "bg-info/10",
+ accentClassName = "text-info"
}: FileDropzoneProps) {
const [isDragActive, setIsDragActive] = useState(false);
@@ -83,10 +99,11 @@ function FileDropzone({
<div data-slot="file-dropzone" className={cn("flex min-w-0 flex-col gap-4", className)}>
<Empty
frame={isDragActive ? "solid" : "dashed"}
- frameClassName={isDragActive ? "text-info" : undefined}
+ frameClassName={cn(frameClassName, isDragActive && activeFrameClassName)}
className={cn(
- "cursor-pointer bg-transparent transition-colors duration-75",
- isDragActive && "bg-info/10",
+ "cursor-pointer bg-transparent",
+ emptyClassName,
+ isDragActive && activeEmptyClassName,
isDisabled && "pointer-events-none opacity-50"
)}
onDragEnter={handleDrag}
@@ -103,7 +120,7 @@ function FileDropzone({
? (dropTitle ?? `Drop your file${multiple ? "s" : ""} here`)
: (title ?? (
<>
- Drag & drop or <span className="text-info">Choose file</span> to upload
+ Drag & drop or <span className={accentClassName}>Choose file</span> to upload
</>
))}
</EmptyTitle>
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/EncryptionTab/EncryptionTab.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/EncryptionTab/EncryptionTab.tsx
index 9e033954d4..6e64ec0089 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/EncryptionTab/EncryptionTab.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/EncryptionTab/EncryptionTab.tsx
@@ -196,6 +196,9 @@ const LoadBackupModal = ({
accept=".txt"
description=".infisical.txt backup file"
files={backupFiles}
+ accentClassName="text-project"
+ activeFrameClassName="text-project"
+ activeEmptyClassName="bg-project/10"
onFilesSelect={(files) => {
const file = files[0];
parseFile(file);