forked from dubinc/dub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48122b3
commit aabb610
Showing
40 changed files
with
428 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
components/app/modals/add-edit-link-modal/comments-section.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Dispatch, SetStateAction, useEffect, useState } from "react"; | ||
import { type Link as LinkProps } from "@prisma/client"; | ||
import TextareaAutosize from "react-textarea-autosize"; | ||
import Switch from "#/ui/switch"; | ||
import { motion } from "framer-motion"; | ||
import { FADE_IN_ANIMATION_SETTINGS, HOME_DOMAIN } from "#/lib/constants"; | ||
import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip"; | ||
|
||
export default function CommentsSection({ | ||
props, | ||
data, | ||
setData, | ||
}: { | ||
props?: LinkProps; | ||
data: LinkProps; | ||
setData: Dispatch<SetStateAction<LinkProps>>; | ||
}) { | ||
const { comments } = data; | ||
const [enabled, setEnabled] = useState(!!comments); | ||
useEffect(() => { | ||
if (enabled) { | ||
// if enabling, add previous comments if exists | ||
setData({ | ||
...data, | ||
comments: props?.comments || comments, | ||
}); | ||
} else { | ||
// if disabling, remove comments | ||
setData({ ...data, comments: null }); | ||
} | ||
}, [enabled]); | ||
|
||
return ( | ||
<div className="border-b border-gray-200 pb-5"> | ||
<div className="flex items-center justify-between"> | ||
<div className="flex items-center justify-between space-x-2"> | ||
<h2 className="text-sm font-medium text-gray-900">Comments</h2> | ||
<InfoTooltip | ||
content={ | ||
<SimpleTooltipContent | ||
title="Use comments to add context to your short links – for you and your team." | ||
cta="Learn more." | ||
href={`${HOME_DOMAIN}/help/article/how-to-create-link#comments`} | ||
/> | ||
} | ||
/> | ||
</div> | ||
<Switch fn={() => setEnabled(!enabled)} checked={enabled} /> | ||
</div> | ||
{enabled && ( | ||
<motion.div className="mt-3" {...FADE_IN_ANIMATION_SETTINGS}> | ||
<TextareaAutosize | ||
name="comments" | ||
minRows={3} | ||
className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm" | ||
placeholder="Add comments" | ||
value={comments || ""} | ||
onChange={(e) => { | ||
setData({ ...data, comments: e.target.value }); | ||
}} | ||
/> | ||
</motion.div> | ||
)} | ||
</div> | ||
); | ||
} |
2 changes: 1 addition & 1 deletion
2
components/app/modals/add-edit-link-modal/expiration-section.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.