mirror of
https://github.com/Tony0410/quietthanks.git
synced 2026-05-25 05:41:38 +08:00
Streamline save button and add calendar view with search
- Remove redundant Save button, keep only Save & New - Add calendar view to timeline showing days with entries - Add search functionality with highlighted matches - Add date filtering by clicking calendar days - Show results count when filtering Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,9 +8,27 @@ import type { EntryWithTags } from "@/lib/types";
|
||||
|
||||
interface EntryRowProps {
|
||||
entry: EntryWithTags;
|
||||
searchQuery?: string;
|
||||
}
|
||||
|
||||
export function EntryRow({ entry }: EntryRowProps) {
|
||||
function highlightText(text: string, query: string): React.ReactNode {
|
||||
if (!query.trim()) return text;
|
||||
|
||||
const regex = new RegExp(`(${query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi");
|
||||
const parts = text.split(regex);
|
||||
|
||||
return parts.map((part, i) =>
|
||||
regex.test(part) ? (
|
||||
<mark key={i} className="bg-accent/30 text-foreground rounded px-0.5">
|
||||
{part}
|
||||
</mark>
|
||||
) : (
|
||||
part
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function EntryRow({ entry, searchQuery = "" }: EntryRowProps) {
|
||||
// Truncate text to one line preview
|
||||
const preview = entry.text.length > 80 ? entry.text.slice(0, 80) + "..." : entry.text;
|
||||
|
||||
@@ -31,10 +49,12 @@ export function EntryRow({ entry }: EntryRowProps) {
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<p className="text-foreground truncate">{preview}</p>
|
||||
<p className="text-foreground truncate">
|
||||
{highlightText(preview, searchQuery)}
|
||||
</p>
|
||||
{entry.tags.length > 0 && (
|
||||
<div className="mt-2">
|
||||
<TagChips tags={entry.tags} />
|
||||
<TagChips tags={entry.tags} highlightQuery={searchQuery} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user