Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: hide advanced link options in accordion

Marc Seitza8587eda9e28
diff --git a/components/links/link-sheet/email-authentication-section.tsx b/components/links/link-sheet/email-authentication-section.tsx
index ebe90ff3..3eaeb167 100644
--- a/components/links/link-sheet/email-authentication-section.tsx
+++ b/components/links/link-sheet/email-authentication-section.tsx
@@ -11,7 +11,7 @@ export default function EmailAuthenticationSection({
setData: Dispatch<SetStateAction<DEFAULT_LINK_TYPE>>;
}) {
const { emailProtected, emailAuthenticated } = data;
- const [enabled, setEnabled] = useState<boolean>(true);
+ const [enabled, setEnabled] = useState<boolean>(emailAuthenticated);
useEffect(() => {
setEnabled(emailAuthenticated);
@@ -39,7 +39,7 @@ export default function EmailAuthenticationSection({
enabled ? "text-foreground" : "text-muted-foreground",
)}
>
- Require email authentication to view
+ Require email verification
</h2>
</div>
<Switch
diff --git a/components/links/link-sheet/email-protection-section.tsx b/components/links/link-sheet/email-protection-section.tsx
index d02bfd12..f6f34eba 100644
--- a/components/links/link-sheet/email-protection-section.tsx
+++ b/components/links/link-sheet/email-protection-section.tsx
@@ -10,8 +10,8 @@ export default function EmailProtectionSection({
data: DEFAULT_LINK_TYPE;
setData: Dispatch<SetStateAction<DEFAULT_LINK_TYPE>>;
}) {
- const { emailProtected, emailAuthenticated } = data;
- const [enabled, setEnabled] = useState<boolean>(true);
+ const { emailProtected } = data;
+ const [enabled, setEnabled] = useState<boolean>(emailProtected);
useEffect(() => {
setEnabled(emailProtected);
diff --git a/components/links/link-sheet/index.tsx b/components/links/link-sheet/index.tsx
index 0fe0cffc..310ba9f3 100644
--- a/components/links/link-sheet/index.tsx
+++ b/components/links/link-sheet/index.tsx
@@ -29,6 +29,7 @@ import OGSection from "./og-section";
import { ScrollArea } from "@/components/ui/scroll-area";
import AllowListSection from "./allow-list-section";
import DenyListSection from "./deny-list-section";
+import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion";
export const DEFAULT_LINK_PROPS = {
id: null,
@@ -215,22 +216,34 @@ export default function LinkSheet({
<Separator className="bg-muted-foreground absolute" />
<div className="relative mx-auto">
<span className="px-2 bg-background text-muted-foreground text-sm">
- Optional
+ Link Options
</span>
</div>
</div>
<div>
<EmailProtectionSection {...{ data, setData }} />
- <EmailAuthenticationSection {...{ data, setData }} />
- <AllowListSection {...{ data, setData }} />
- <DenyListSection {...{ data, setData }} />
+ <AllowNotificationSection {...{ data, setData }} />
<AllowDownloadSection {...{ data, setData }} />
- <PasswordSection {...{ data, setData }} />
<ExpirationSection {...{ data, setData }} />
- <OGSection {...{ data, setData }} />
- <AllowNotificationSection {...{ data, setData }} />
- <FeedbackSection {...{ data, setData }} />
+
+ <Accordion type="single" collapsible>
+ <AccordionItem value="item-1" className="border-none">
+ <AccordionTrigger className="py-0 rounded-lg space-x-2">
+ <span className="text-sm font-medium leading-6 text-foreground">
+ Advanced Link Access Options
+ </span>
+ </AccordionTrigger>
+ <AccordionContent className="first:pt-5">
+ <EmailAuthenticationSection {...{ data, setData }} />
+ <AllowListSection {...{ data, setData }} />
+ <DenyListSection {...{ data, setData }} />
+ <PasswordSection {...{ data, setData }} />
+ <OGSection {...{ data, setData }} />
+ <FeedbackSection {...{ data, setData }} />
+ </AccordionContent>
+ </AccordionItem>
+ </Accordion>
</div>
</div>
</div>
diff --git a/components/ui/accordion.tsx b/components/ui/accordion.tsx
new file mode 100644
index 00000000..e6a723d0
--- /dev/null
+++ b/components/ui/accordion.tsx
@@ -0,0 +1,56 @@
+import * as React from "react"
+import * as AccordionPrimitive from "@radix-ui/react-accordion"
+import { ChevronDown } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const Accordion = AccordionPrimitive.Root
+
+const AccordionItem = React.forwardRef<
+ React.ElementRef<typeof AccordionPrimitive.Item>,
+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
+>(({ className, ...props }, ref) => (
+ <AccordionPrimitive.Item
+ ref={ref}
+ className={cn("border-b", className)}
+ {...props}
+ />
+))
+AccordionItem.displayName = "AccordionItem"
+
+const AccordionTrigger = React.forwardRef<
+ React.ElementRef<typeof AccordionPrimitive.Trigger>,
+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
+>(({ className, children, ...props }, ref) => (
+ <AccordionPrimitive.Header className="flex">
+ <AccordionPrimitive.Trigger
+ ref={ref}
+ className={cn(
+ "flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
+ </AccordionPrimitive.Trigger>
+ </AccordionPrimitive.Header>
+))
+AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName
+
+const AccordionContent = React.forwardRef<
+ React.ElementRef<typeof AccordionPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
+>(({ className, children, ...props }, ref) => (
+ <AccordionPrimitive.Content
+ ref={ref}
+ className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
+ {...props}
+ >
+ <div className={cn("pb-4 pt-0", className)}>{children}</div>
+ </AccordionPrimitive.Content>
+))
+
+AccordionContent.displayName = AccordionPrimitive.Content.displayName
+
+export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
diff --git a/package-lock.json b/package-lock.json
index 35432819..5a6f5faf 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -15,6 +15,7 @@
"@jitsu/js": "^1.8.2",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^5.9.1",
+ "@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-collapsible": "^1.0.3",
@@ -1406,6 +1407,37 @@
"@babel/runtime": "^7.13.10"
}
},
+ "node_modules/@radix-ui/react-accordion": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-accordion/-/react-accordion-1.1.2.tgz",
+ "integrity": "sha512-fDG7jcoNKVjSK6yfmuAs0EnPDro0WMXIhMtXdTBWqEioVW206ku+4Lw07e+13lUkFkpoEQ2PdeMIAGpdqEAmDg==",
+ "dependencies": {
+ "@babel/runtime": "^7.13.10",
+ "@radix-ui/primitive": "1.0.1",
+ "@radix-ui/react-collapsible": "1.0.3",
+ "@radix-ui/react-collection": "1.0.3",
+ "@radix-ui/react-compose-refs": "1.0.1",
+ "@radix-ui/react-context": "1.0.1",
+ "@radix-ui/react-direction": "1.0.1",
+ "@radix-ui/react-id": "1.0.1",
+ "@radix-ui/react-primitive": "1.0.3",
+ "@radix-ui/react-use-controllable-state": "1.0.1"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0",
+ "react-dom": "^16.8 || ^17.0 || ^18.0"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-arrow": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.0.3.tgz",
diff --git a/package.json b/package.json
index 42c35e12..210fe554 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,7 @@
"@jitsu/js": "^1.8.2",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^5.9.1",
+ "@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-collapsible": "^1.0.3",
diff --git a/tailwind.config.js b/tailwind.config.js
index 43e4bc72..70a68495 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -169,11 +169,21 @@ module.exports = {
opacity: "0",
},
},
+ "accordion-down": {
+ from: { height: "0" },
+ to: { height: "var(--radix-accordion-content-height)" },
+ },
+ "accordion-up": {
+ from: { height: "var(--radix-accordion-content-height)" },
+ to: { height: "0" },
+ },
},
animation: {
gauge_fadeIn: "gauge_fadeIn 1s ease forwards",
gauge_fill: "gauge_fill 1s ease forwards",
flyEmoji: "flyEmoji 1s forwards",
+ "accordion-down": "accordion-down 0.2s ease-out",
+ "accordion-up": "accordion-up 0.2s ease-out",
},
},
},