Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion r/sheet.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions site/src/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,10 @@
"title": "Form around the sections",
"module": "sheet/form"
},
{
"title": "Back at the start of the footer",
"module": "sheet/footer-start"
},
{
"title": "Header and footer inside a view component",
"module": "sheet/wrapped-sections"
Expand Down
57 changes: 57 additions & 0 deletions site/src/examples/sheet/footer-start.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { useState } from "react";

import { Button } from "@infisical/cipher/ui/button";
import { Field } from "@infisical/cipher/ui/field";
import { Input } from "@infisical/cipher/ui/input";
import * as UI from "@infisical/cipher/ui/sheet";

export default function Example() {
const [step, setStep] = useState(1);
const [region, setRegion] = useState("us-east-1");
const [accessKey, setAccessKey] = useState("AKIAIOSFODNN7EXAMPLE");
return (
<div className="flex w-full min-w-0 flex-col items-start gap-6">
<UI.Sheet onOpenChange={(open) => open && setStep(1)}>
<UI.SheetTrigger asChild>
<Button variant="outline">Add AWS KMS</Button>
</UI.SheetTrigger>
<UI.SheetContent>
<UI.SheetHeader>
<UI.SheetTitle>{step === 1 ? "Choose a region" : "Add credentials"}</UI.SheetTitle>
</UI.SheetHeader>
<UI.SheetBody>
{step === 1 ? (
<Field key="region" label="Region">
<Input value={region} onChange={(event) => setRegion(event.target.value)} />
</Field>
) : (
<Field key="access-key" label="Access key ID">
<Input value={accessKey} onChange={(event) => setAccessKey(event.target.value)} />
</Field>
)}
</UI.SheetBody>
<UI.SheetFooter
start={
step > 1 && (
<Button variant="ghost" icon="chev-left" onClick={() => setStep(1)}>
Back
</Button>
)
}
>
<UI.SheetClose asChild>
<Button variant="outline">Cancel</Button>
</UI.SheetClose>
{step === 1 ? (
<Button onClick={() => setStep(2)}>Continue</Button>
) : (
<UI.SheetClose asChild>
<Button>Add</Button>
</UI.SheetClose>
)}
</UI.SheetFooter>
</UI.SheetContent>
</UI.Sheet>
</div>
);
}
20 changes: 18 additions & 2 deletions src/ui/sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -906,14 +906,30 @@ function SheetBody({
}
SheetBody.displayName = "SheetBody";

function SheetFooter({ className, ref, ...props }: React.ComponentProps<"div">) {
function SheetFooter({
className,
start,
children,
ref,
...props
}: React.ComponentProps<"div"> & {
/** Held at the start edge while the children stay at the end, such as Back in a multi-step sheet. */
start?: React.ReactNode;
}) {
return (
<div
ref={ref}
data-slot="sheet-footer"
className={cn("mt-auto flex flex-wrap items-center justify-end gap-2 p-4", className)}
{...props}
/>
>
{Boolean(start) && (
<div data-slot="sheet-footer-start" className="me-auto flex flex-wrap items-center gap-2">
{start}
</div>
)}
{children}
</div>
);
}
SheetFooter.displayName = "SheetFooter";
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading