Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/chat-bot/messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"chat-expired-error": "Der Chat ist abgelaufen.",
"empty-response-error": "Antwort konnte nicht generiert werden",
"new-chat": "Neuer Chat",
"favorite": "Favorit",
"favorite-add": "Als Favorit markieren",
"favorite-remove": "Favorit entfernen",
"favorite-error": "Der Favorit konnte nicht gespeichert werden.",
"stop": "Stop",
"copy": "Kopieren",
Expand Down
41 changes: 24 additions & 17 deletions apps/chat-bot/src/components/common/favorite-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { HeartStraightIcon } from '@phosphor-icons/react';
import { Button } from '@ui/components/button';
import { Tooltip, TooltipContent, TooltipTrigger } from '@ui/components/tooltip';
import { useTranslations } from 'next-intl';
import { useState } from 'react';

Expand Down Expand Up @@ -33,22 +34,28 @@ export function FavoriteButton({
}

return (
<Button
type="button"
variant="ghost"
size="icon-round"
className={cn(className)}
aria-label={t('favorite')}
aria-pressed={isFavorite}
disabled={isPending || disabled}
onClick={handleClick}
data-testid="favorite-button"
>
<HeartStraightIcon
aria-hidden="true"
className="size-6 text-primary"
weight={isFavorite ? 'fill' : 'regular'}
/>
</Button>
<Tooltip>
<TooltipTrigger asChild disableKeyboardToggle>
<Button
type="button"
variant="ghost"
size="icon-round"
className={cn(className)}
// Constant name: with aria-pressed the state is announced separately.
aria-label={t('favorite-add')}
aria-pressed={isFavorite}
disabled={isPending || disabled}
onClick={handleClick}
data-testid="favorite-button"
>
<HeartStraightIcon
aria-hidden="true"
className="size-6 text-primary"
weight={isFavorite ? 'fill' : 'regular'}
/>
</Button>
</TooltipTrigger>
<TooltipContent>{t(isFavorite ? 'favorite-remove' : 'favorite-add')}</TooltipContent>
</Tooltip>
);
}
Loading