-
Notifications
You must be signed in to change notification settings - Fork 35
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
Showing
5 changed files
with
69 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Prompt for testing | ||
|
||
Imagine you wake up one morning to find yourself in a bustling marketplace in a fantastical city you've never seen before. Write a concise paragraph description of your surroundings, capturing the sights, sounds, and smells that overwhelm your senses. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"use client"; | ||
|
||
import { ChevronUpIcon, DotsHorizontalIcon } from "@radix-ui/react-icons"; | ||
import * as React from "react"; | ||
import { useEffect } from "react"; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
import { | ||
Collapsible, | ||
CollapsibleContent, | ||
CollapsibleTrigger, | ||
} from "@/components/ui/collapsible"; | ||
|
||
interface IProps { | ||
text: string; | ||
maxChars: number; | ||
} | ||
|
||
export function CollapsibleText({ text, maxChars }: IProps) { | ||
const [isOpen, setIsOpen] = React.useState(false); | ||
const isTextLong = text.length > maxChars; | ||
const displayText = | ||
isTextLong && !isOpen ? text.substring(0, maxChars) : text; | ||
|
||
useEffect(() => { | ||
isTextLong && !isOpen ? text.substring(0, maxChars) : text; | ||
}, [isOpen]); | ||
|
||
return ( | ||
<Collapsible open={isOpen} onOpenChange={setIsOpen} className="space-y-2"> | ||
<div className="my-1 flex justify-stretch"> | ||
<div className="text-sm font-semibold">{displayText}</div> | ||
|
||
{isTextLong && ( | ||
<CollapsibleTrigger asChild> | ||
<Button variant="ghost" size="sm"> | ||
{isOpen ? ( | ||
<ChevronUpIcon className="mr-1 h-4 w-4" /> | ||
) : ( | ||
<DotsHorizontalIcon className="mr-1 h-4 w-4" /> | ||
)} | ||
<span className="sr-only">Toggle Expand/Collapse</span> | ||
</Button> | ||
</CollapsibleTrigger> | ||
)} | ||
</div> | ||
|
||
<CollapsibleContent className="space-y-2"></CollapsibleContent> | ||
</Collapsible> | ||
); | ||
} |
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