move bookmarks to lump

This commit is contained in:
Nate 2025-03-21 22:37:24 -07:00
parent fb86531fee
commit 3b006df094
3 changed files with 17 additions and 36 deletions

View file

@ -1,21 +1,16 @@
import { BookmarkIcon, ChatBubbleLeftIcon } from "@heroicons/react/24/outline";
import { BookmarkIcon as BookmarkIconSolid } from "@heroicons/react/24/solid";
import { ChatBubbleLeftIcon } from "@heroicons/react/24/outline";
import { SlashCommandDescription } from "core";
import { useState } from "react";
import { defaultBorderRadius, GhostButton, vscInputBackground } from "..";
import { defaultBorderRadius, vscInputBackground } from "..";
interface ConversationStarterCardProps {
command: SlashCommandDescription;
onClick: (command: SlashCommandDescription) => void;
onBookmark: (command: SlashCommandDescription) => void;
isBookmarked: boolean;
}
export function ConversationStarterCard({
command,
onClick,
onBookmark,
isBookmarked = false,
}: ConversationStarterCardProps) {
const [isHovered, setIsHovered] = useState(false);
@ -40,24 +35,6 @@ export function ConversationStarterCard({
<div className="font-medium">{command.name}</div>
<div className="text-lightgray text-sm">{command.description}</div>
</div>
<div className="flex items-center">
<GhostButton
onClick={(e) => {
e.stopPropagation();
onBookmark(command);
}}
aria-label={
isBookmarked ? "Remove bookmarked prompt" : "Bookmark prompt"
}
className={isHovered || isBookmarked ? "opacity-100" : "opacity-0"}
>
{isBookmarked ? (
<BookmarkIconSolid className="h-4 w-4" />
) : (
<BookmarkIcon className="h-4 w-4" />
)}
</GhostButton>
</div>
</div>
</div>
);

View file

@ -9,8 +9,7 @@ const NUM_CARDS_TO_RENDER = 3;
export function ConversationStarterCards() {
const dispatch = useAppDispatch();
const { cmdsSortedByBookmark, bookmarkStatuses, toggleBookmark } =
useBookmarkedSlashCommands();
const { cmdsSortedByBookmark } = useBookmarkedSlashCommands();
function onClick(command: SlashCommandDescription) {
if (command.prompt) {
@ -31,8 +30,6 @@ export function ConversationStarterCards() {
key={command.name + i}
command={command}
onClick={onClick}
onBookmark={() => toggleBookmark(command)}
isBookmarked={bookmarkStatuses[command.name]}
/>
))}
</div>

View file

@ -1,17 +1,21 @@
import { BookmarkIcon as BookmarkOutline } from "@heroicons/react/24/outline";
import { BookmarkIcon as BookmarkSolid } from "@heroicons/react/24/solid";
import { useState } from "react";
import { useAppSelector } from "../../../../redux/hooks";
import { getFontSize } from "../../../../util";
import { useBookmarkedSlashCommands } from "../../../ConversationStarters/useBookmarkedSlashCommands";
interface PromptRowProps {
command: string;
description: string;
isBookmarked: boolean;
setIsBookmarked: (isBookmarked: boolean) => void;
}
function PromptRow({ command, description }: PromptRowProps) {
const [isBookmarked, setIsBookmarked] = useState(false);
function PromptRow({
command,
description,
isBookmarked,
setIsBookmarked,
}: PromptRowProps) {
return (
<div
className="flex items-center justify-between"
@ -38,15 +42,18 @@ function PromptRow({ command, description }: PromptRowProps) {
}
export function PromptsSection() {
const prompts = useAppSelector((store) => store.config.config.slashCommands);
const { cmdsSortedByBookmark, bookmarkStatuses, toggleBookmark } =
useBookmarkedSlashCommands();
return (
<div className="flex flex-col gap-1 pr-2">
{prompts?.map((prompt) => (
{cmdsSortedByBookmark?.map((prompt, i) => (
<PromptRow
key={prompt.name}
command={prompt.name}
description={prompt.description}
isBookmarked={bookmarkStatuses[prompt.name]}
setIsBookmarked={() => toggleBookmark(prompt)}
/>
))}
</div>