mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-21 18:55:16 +02:00
add see more/less toggle on prompt cards for long content
This commit is contained in:
parent
bcb202dfe1
commit
a73bab89d9
2 changed files with 30 additions and 6 deletions
|
|
@ -12,6 +12,7 @@ export function CommunityPromptsContent() {
|
||||||
const [prompts, setPrompts] = useState<PublicPromptRead[]>([]);
|
const [prompts, setPrompts] = useState<PublicPromptRead[]>([]);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [copyingId, setCopyingId] = useState<number | null>(null);
|
const [copyingId, setCopyingId] = useState<number | null>(null);
|
||||||
|
const [expandedId, setExpandedId] = useState<number | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
promptsApiService
|
promptsApiService
|
||||||
|
|
@ -73,12 +74,23 @@ export function CommunityPromptsContent() {
|
||||||
<span className="rounded-full border px-2 py-0.5 text-[10px] text-muted-foreground">
|
<span className="rounded-full border px-2 py-0.5 text-[10px] text-muted-foreground">
|
||||||
{prompt.mode}
|
{prompt.mode}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
|
||||||
<p className="mt-1 text-xs text-muted-foreground line-clamp-2">{prompt.prompt}</p>
|
|
||||||
{prompt.author_name && (
|
{prompt.author_name && (
|
||||||
<p className="mt-1.5 text-[11px] text-muted-foreground/60">
|
<span className="text-[11px] text-muted-foreground/60">
|
||||||
by {prompt.author_name}
|
by {prompt.author_name}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<p className={`mt-1 text-xs text-muted-foreground ${expandedId === prompt.id ? "whitespace-pre-wrap" : "line-clamp-2"}`}>
|
||||||
|
{prompt.prompt}
|
||||||
</p>
|
</p>
|
||||||
|
{prompt.prompt.length > 100 && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setExpandedId(expandedId === prompt.id ? null : prompt.id)}
|
||||||
|
className="mt-1 text-[11px] text-primary hover:underline cursor-pointer"
|
||||||
|
>
|
||||||
|
{expandedId === prompt.id ? "See less" : "See more"}
|
||||||
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ export function PromptsContent() {
|
||||||
const [editingId, setEditingId] = useState<number | null>(null);
|
const [editingId, setEditingId] = useState<number | null>(null);
|
||||||
const [formData, setFormData] = useState<PromptFormData>(EMPTY_FORM);
|
const [formData, setFormData] = useState<PromptFormData>(EMPTY_FORM);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
|
const [expandedId, setExpandedId] = useState<number | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
promptsApiService
|
promptsApiService
|
||||||
|
|
@ -227,7 +228,18 @@ export function PromptsContent() {
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-1 text-xs text-muted-foreground line-clamp-2">{prompt.prompt}</p>
|
<p className={`mt-1 text-xs text-muted-foreground ${expandedId === prompt.id ? "whitespace-pre-wrap" : "line-clamp-2"}`}>
|
||||||
|
{prompt.prompt}
|
||||||
|
</p>
|
||||||
|
{prompt.prompt.length > 100 && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setExpandedId(expandedId === prompt.id ? null : prompt.id)}
|
||||||
|
className="mt-1 text-[11px] text-primary hover:underline cursor-pointer"
|
||||||
|
>
|
||||||
|
{expandedId === prompt.id ? "See less" : "See more"}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="hidden group-hover:flex items-center gap-1 shrink-0">
|
<div className="hidden group-hover:flex items-center gap-1 shrink-0">
|
||||||
<button
|
<button
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue