mirror of
https://github.com/Alvin-Zilverstand/Twitter-X-Media-Batch-Downloader.git
synced 2026-11-25 07:44:00 +01:00
v4.3
This commit is contained in:
1 parent
2f51a118e4
commit
de402efe6b
20 files changed
+1554
-488
No files matched your search
@@ -34,7 +34,7 @@ import {
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Trash2, FileInput, FileOutput, Pencil, Tag, Shuffle, X, XCircle, Download, StopCircle, Globe, Lock, Bookmark, Heart, Image, Images, Video, Film, FileText, Filter, AlertCircle, MoreVertical, FileBraces, CloudBackup, Search, LayoutGrid, Grid3X3, List, ArrowUpDown, ArrowUp, FolderOpen } from "lucide-react";
|
||||
import { Trash2, FileInput, FileOutput, Pencil, Tag, Shuffle, X, XCircle, Download, StopCircle, Globe, Lock, Bookmark, Heart, Image, Images, Video, Film, FileText, Filter, AlertCircle, MoreVertical, FileBraces, CloudBackup, Search, LayoutGrid, Grid3X3, List, ArrowUpDown, ArrowUp, FolderOpen, Users, MessageSquare } from "lucide-react";
|
||||
import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
||||
import { getSettings } from "@/lib/settings";
|
||||
import { openExternal } from "@/lib/utils";
|
||||
@@ -123,7 +123,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
const [filterMediaType, setFilterMediaType] = useState<string>("all");
|
||||
const [accountViewMode, setAccountViewMode] = useState<"public" | "private">("public");
|
||||
const [searchQuery, setSearchQuery] = useState<string>("");
|
||||
const [sortOrder, setSortOrder] = useState<"newest" | "oldest">("newest");
|
||||
const [sortOrder, setSortOrder] = useState<"newest" | "oldest" | "username-asc" | "username-desc" | "followers-high" | "followers-low" | "posts-high" | "posts-low" | "media-high" | "media-low">("newest");
|
||||
const [gridView, setGridView] = useState<"large" | "small" | "list">("list");
|
||||
const [editingAccount, setEditingAccount] = useState<AccountListItem | null>(null);
|
||||
const [editGroupName, setEditGroupName] = useState("");
|
||||
@@ -255,10 +255,36 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
return true;
|
||||
})
|
||||
.sort((a, b) => {
|
||||
// Sort by last_fetched date
|
||||
const dateA = new Date(a.last_fetched).getTime();
|
||||
const dateB = new Date(b.last_fetched).getTime();
|
||||
return sortOrder === "newest" ? dateB - dateA : dateA - dateB;
|
||||
switch (sortOrder) {
|
||||
case "newest": {
|
||||
const dateA = new Date(a.last_fetched).getTime();
|
||||
const dateB = new Date(b.last_fetched).getTime();
|
||||
return dateB - dateA;
|
||||
}
|
||||
case "oldest": {
|
||||
const dateA = new Date(a.last_fetched).getTime();
|
||||
const dateB = new Date(b.last_fetched).getTime();
|
||||
return dateA - dateB;
|
||||
}
|
||||
case "username-asc":
|
||||
return a.username.toLowerCase().localeCompare(b.username.toLowerCase());
|
||||
case "username-desc":
|
||||
return b.username.toLowerCase().localeCompare(a.username.toLowerCase());
|
||||
case "followers-high":
|
||||
return (b.followers_count || 0) - (a.followers_count || 0);
|
||||
case "followers-low":
|
||||
return (a.followers_count || 0) - (b.followers_count || 0);
|
||||
case "posts-high":
|
||||
return (b.statuses_count || 0) - (a.statuses_count || 0);
|
||||
case "posts-low":
|
||||
return (a.statuses_count || 0) - (b.statuses_count || 0);
|
||||
case "media-high":
|
||||
return (b.total_media || 0) - (a.total_media || 0);
|
||||
case "media-low":
|
||||
return (a.total_media || 0) - (b.total_media || 0);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
// Intersection Observer for lazy loading
|
||||
@@ -949,113 +975,129 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
|
||||
{/* Row 2: Sort, Filters, View Toggle */}
|
||||
<div className="flex items-center gap-2 pb-2">
|
||||
{/* Sort Order */}
|
||||
<Select value={sortOrder} onValueChange={(v) => setSortOrder(v as "newest" | "oldest")}>
|
||||
<SelectTrigger className="w-auto">
|
||||
<ArrowUpDown className="h-4 w-4 mr-2" />
|
||||
<SelectValue placeholder="Sort" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="newest">Newest</SelectItem>
|
||||
<SelectItem value="oldest">Oldest</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{/* Sort Order - only for public accounts */}
|
||||
{accountViewMode === "public" && (
|
||||
<Select value={sortOrder} onValueChange={(v) => setSortOrder(v as typeof sortOrder)}>
|
||||
<SelectTrigger className="w-auto">
|
||||
<ArrowUpDown className="h-4 w-4 mr-2" />
|
||||
<SelectValue placeholder="Sort" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="newest">Newest</SelectItem>
|
||||
<SelectItem value="oldest">Oldest</SelectItem>
|
||||
<SelectItem value="username-asc">Username (A-Z)</SelectItem>
|
||||
<SelectItem value="username-desc">Username (Z-A)</SelectItem>
|
||||
<SelectItem value="followers-high">Followers (High-Low)</SelectItem>
|
||||
<SelectItem value="followers-low">Followers (Low-High)</SelectItem>
|
||||
<SelectItem value="posts-high">Posts (High-Low)</SelectItem>
|
||||
<SelectItem value="posts-low">Posts (Low-High)</SelectItem>
|
||||
<SelectItem value="media-high">Media Count (High-Low)</SelectItem>
|
||||
<SelectItem value="media-low">Media Count (Low-High)</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
|
||||
{/* Media Type Filter */}
|
||||
<Select value={filterMediaType} onValueChange={setFilterMediaType}>
|
||||
<SelectTrigger className="w-auto">
|
||||
<Filter className="h-4 w-4 mr-2" />
|
||||
<SelectValue placeholder="Filter by type" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">
|
||||
<span className="flex items-center gap-2">All Types</span>
|
||||
</SelectItem>
|
||||
<SelectItem value="all-media">
|
||||
<span className="flex items-center gap-2">
|
||||
<Images className="h-4 w-4 text-indigo-500" />
|
||||
All Media
|
||||
</span>
|
||||
</SelectItem>
|
||||
<SelectItem value="image">
|
||||
<span className="flex items-center gap-2">
|
||||
<Image className="h-4 w-4 text-blue-500" />
|
||||
Images
|
||||
</span>
|
||||
</SelectItem>
|
||||
<SelectItem value="video">
|
||||
<span className="flex items-center gap-2">
|
||||
<Video className="h-4 w-4 text-purple-500" />
|
||||
Videos
|
||||
</span>
|
||||
</SelectItem>
|
||||
<SelectItem value="gif">
|
||||
<span className="flex items-center gap-2">
|
||||
<Film className="h-4 w-4 text-green-500" />
|
||||
GIFs
|
||||
</span>
|
||||
</SelectItem>
|
||||
<SelectItem value="text">
|
||||
<span className="flex items-center gap-2">
|
||||
<FileText className="h-4 w-4 text-orange-500" />
|
||||
Text
|
||||
</span>
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
{/* Group Filter */}
|
||||
<Select value={filterGroup} onValueChange={setFilterGroup} disabled={groups.length === 0}>
|
||||
<SelectTrigger className="w-auto">
|
||||
<Tag className="h-4 w-4 mr-2" />
|
||||
<SelectValue placeholder="Filter by group" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">All Groups</SelectItem>
|
||||
<SelectItem value="ungrouped">Ungrouped</SelectItem>
|
||||
{groups.map((group) => (
|
||||
<SelectItem key={group.name} value={group.name}>
|
||||
{/* Media Type Filter - only for public accounts */}
|
||||
{accountViewMode === "public" && (
|
||||
<Select value={filterMediaType} onValueChange={setFilterMediaType}>
|
||||
<SelectTrigger className="w-auto">
|
||||
<Filter className="h-4 w-4 mr-2" />
|
||||
<SelectValue placeholder="Filter by type" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">
|
||||
<span className="flex items-center gap-2">All Types</span>
|
||||
</SelectItem>
|
||||
<SelectItem value="all-media">
|
||||
<span className="flex items-center gap-2">
|
||||
<span
|
||||
className="w-3 h-3 rounded-full"
|
||||
style={{ backgroundColor: group.color }}
|
||||
/>
|
||||
{group.name}
|
||||
<Images className="h-4 w-4 text-indigo-500" />
|
||||
All Media
|
||||
</span>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<SelectItem value="image">
|
||||
<span className="flex items-center gap-2">
|
||||
<Image className="h-4 w-4 text-blue-500" />
|
||||
Images
|
||||
</span>
|
||||
</SelectItem>
|
||||
<SelectItem value="video">
|
||||
<span className="flex items-center gap-2">
|
||||
<Video className="h-4 w-4 text-purple-500" />
|
||||
Videos
|
||||
</span>
|
||||
</SelectItem>
|
||||
<SelectItem value="gif">
|
||||
<span className="flex items-center gap-2">
|
||||
<Film className="h-4 w-4 text-green-500" />
|
||||
GIFs
|
||||
</span>
|
||||
</SelectItem>
|
||||
<SelectItem value="text">
|
||||
<span className="flex items-center gap-2">
|
||||
<FileText className="h-4 w-4 text-orange-500" />
|
||||
Text
|
||||
</span>
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
|
||||
{/* Group Filter - only for public accounts */}
|
||||
{accountViewMode === "public" && (
|
||||
<Select value={filterGroup} onValueChange={setFilterGroup} disabled={groups.length === 0}>
|
||||
<SelectTrigger className="w-auto">
|
||||
<Tag className="h-4 w-4 mr-2" />
|
||||
<SelectValue placeholder="Filter by group" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">All Groups</SelectItem>
|
||||
<SelectItem value="ungrouped">Ungrouped</SelectItem>
|
||||
{groups.map((group) => (
|
||||
<SelectItem key={group.name} value={group.name}>
|
||||
<span className="flex items-center gap-2">
|
||||
<span
|
||||
className="w-3 h-3 rounded-full"
|
||||
style={{ backgroundColor: group.color }}
|
||||
/>
|
||||
{group.name}
|
||||
</span>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
|
||||
<div className="flex-1" />
|
||||
|
||||
{/* Grid View Toggle */}
|
||||
<div className="flex items-center border rounded-md">
|
||||
<Button
|
||||
variant={gridView === "large" ? "secondary" : "ghost"}
|
||||
size="icon"
|
||||
className="h-9 w-9 rounded-r-none"
|
||||
onClick={() => setGridView("large")}
|
||||
>
|
||||
<LayoutGrid className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
variant={gridView === "small" ? "secondary" : "ghost"}
|
||||
size="icon"
|
||||
className="h-9 w-9 rounded-none border-x"
|
||||
onClick={() => setGridView("small")}
|
||||
>
|
||||
<Grid3X3 className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
variant={gridView === "list" ? "secondary" : "ghost"}
|
||||
size="icon"
|
||||
className="h-9 w-9 rounded-l-none"
|
||||
onClick={() => setGridView("list")}
|
||||
>
|
||||
<List className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
{/* Grid View Toggle - only for public accounts */}
|
||||
{accountViewMode === "public" && (
|
||||
<div className="flex items-center border rounded-md">
|
||||
<Button
|
||||
variant={gridView === "large" ? "secondary" : "ghost"}
|
||||
size="icon"
|
||||
className="h-9 w-9 rounded-r-none"
|
||||
onClick={() => setGridView("large")}
|
||||
>
|
||||
<LayoutGrid className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
variant={gridView === "small" ? "secondary" : "ghost"}
|
||||
size="icon"
|
||||
className="h-9 w-9 rounded-none border-x"
|
||||
onClick={() => setGridView("small")}
|
||||
>
|
||||
<Grid3X3 className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
variant={gridView === "list" ? "secondary" : "ghost"}
|
||||
size="icon"
|
||||
className="h-9 w-9 rounded-l-none"
|
||||
onClick={() => setGridView("list")}
|
||||
>
|
||||
<List className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Bulk Download Progress */}
|
||||
@@ -1146,7 +1188,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
</button>
|
||||
)}
|
||||
<div className="text-sm text-muted-foreground mt-1">
|
||||
{formatNumberWithComma(account.total_media)}
|
||||
{formatNumberWithComma(account.total_media)} media
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-1">
|
||||
@@ -1186,10 +1228,12 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={() => handleEditGroup(account)}>
|
||||
<Pencil className="h-4 w-4 mr-2" />
|
||||
Edit Group
|
||||
</DropdownMenuItem>
|
||||
{!isPrivateAccount(account.username) && (
|
||||
<DropdownMenuItem onClick={() => handleEditGroup(account)}>
|
||||
<Pencil className="h-4 w-4 mr-2" />
|
||||
Edit Group
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem
|
||||
onClick={async () => {
|
||||
const settings = getSettings();
|
||||
@@ -1308,7 +1352,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
</button>
|
||||
)}
|
||||
<div className="text-xs text-muted-foreground">
|
||||
{formatNumberWithComma(account.total_media)}
|
||||
{formatNumberWithComma(account.total_media)} media
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-1">
|
||||
@@ -1348,10 +1392,12 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={() => handleEditGroup(account)}>
|
||||
<Pencil className="h-4 w-4 mr-2" />
|
||||
Edit Group
|
||||
</DropdownMenuItem>
|
||||
{!isPrivateAccount(account.username) && (
|
||||
<DropdownMenuItem onClick={() => handleEditGroup(account)}>
|
||||
<Pencil className="h-4 w-4 mr-2" />
|
||||
Edit Group
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem
|
||||
onClick={async () => {
|
||||
const settings = getSettings();
|
||||
@@ -1435,7 +1481,23 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="truncate">{account.name}</span>
|
||||
<span className="text-muted-foreground">({formatNumberWithComma(account.total_media)})</span>
|
||||
{/* Stats Badges: Followers, Posts, Media */}
|
||||
{!isPrivateAccount(account.username) && (account.followers_count > 0 || account.statuses_count > 0) && (
|
||||
<>
|
||||
<Badge variant="secondary" className="text-xs flex items-center gap-1">
|
||||
<Users className="h-3 w-3" />
|
||||
{formatNumberWithComma(account.followers_count)}
|
||||
</Badge>
|
||||
<Badge variant="secondary" className="text-xs flex items-center gap-1">
|
||||
<MessageSquare className="h-3 w-3" />
|
||||
{formatNumberWithComma(account.statuses_count)}
|
||||
</Badge>
|
||||
</>
|
||||
)}
|
||||
<Badge variant="secondary" className="text-xs flex items-center gap-1">
|
||||
<Images className="h-3 w-3" />
|
||||
{formatNumberWithComma(account.total_media)}
|
||||
</Badge>
|
||||
{/* Media Type Badge */}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
@@ -1544,10 +1606,12 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
|
||||
<TooltipContent>More Options</TooltipContent>
|
||||
</Tooltip>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={() => handleEditGroup(account)}>
|
||||
<Pencil className="h-4 w-4 mr-2" />
|
||||
Edit Group
|
||||
</DropdownMenuItem>
|
||||
{!isPrivateAccount(account.username) && (
|
||||
<DropdownMenuItem onClick={() => handleEditGroup(account)}>
|
||||
<Pencil className="h-4 w-4 mr-2" />
|
||||
Edit Group
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem
|
||||
onClick={async () => {
|
||||
const settings = getSettings();
|
||||
|
||||
@@ -741,7 +741,7 @@ export function MediaList({
|
||||
</span>
|
||||
<span className="flex items-center gap-1">
|
||||
<MessageSquare className="h-3.5 w-3.5" />
|
||||
{formatNumber(accountInfo.statuses_count)} tweets
|
||||
{formatNumber(accountInfo.statuses_count)} posts
|
||||
</span>
|
||||
{accountInfo.date && (
|
||||
<span className="flex items-center gap-1">
|
||||
|
||||
@@ -49,6 +49,7 @@ import { Settings as SettingsIcon } from "lucide-react";
|
||||
import { FetchHistory } from "@/components/FetchHistory";
|
||||
import type { HistoryItem } from "@/components/FetchHistory";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { getSettings, updateSettings, type FetchMode as SettingsFetchMode, type MediaType as SettingsMediaType } from "@/lib/settings";
|
||||
|
||||
export type FetchMode = "public" | "private";
|
||||
export type PrivateType = "bookmarks" | "likes";
|
||||
@@ -148,8 +149,8 @@ export function SearchBar({
|
||||
const [useDateRange, setUseDateRange] = useState(false);
|
||||
const [startDate, setStartDate] = useState("");
|
||||
const [endDate, setEndDate] = useState("");
|
||||
const [mediaType, setMediaType] = useState("all");
|
||||
const [retweets, setRetweets] = useState(false);
|
||||
const [mediaType, setMediaType] = useState<SettingsMediaType>(getSettings().mediaType);
|
||||
const [retweets, setRetweets] = useState(getSettings().includeRetweets);
|
||||
const [mode, setMode] = useState<FetchMode>(externalMode || "public");
|
||||
const [privateType, setPrivateType] = useState<PrivateType>(externalPrivateType || "bookmarks");
|
||||
|
||||
@@ -167,6 +168,7 @@ export function SearchBar({
|
||||
}, [externalPrivateType]);
|
||||
const [showAuthInput, setShowAuthInput] = useState(false);
|
||||
const [showAdvanced, setShowAdvanced] = useState(false);
|
||||
const [currentFetchMode, setCurrentFetchMode] = useState<SettingsFetchMode>(getSettings().fetchMode);
|
||||
|
||||
// Separate auth tokens for public and private modes
|
||||
const [publicAuthToken, setPublicAuthToken] = useState("");
|
||||
@@ -413,11 +415,11 @@ export function SearchBar({
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>Clear resume data</TooltipContent>
|
||||
<TooltipContent>Clear Resume</TooltipContent>
|
||||
</Tooltip>
|
||||
<Button variant="secondary" onClick={handleResume} disabled={!hasAuthToken}>
|
||||
<RotateCcw className="h-4 w-4" />
|
||||
Resume ({resumeInfo.mediaCount})
|
||||
Resume ({resumeInfo.mediaCount.toLocaleString()})
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
@@ -606,13 +608,35 @@ export function SearchBar({
|
||||
{showAdvanced && (
|
||||
<div className="p-3 border rounded-lg bg-muted/30 space-y-3">
|
||||
{/* Options Row */}
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="flex items-center gap-4 flex-wrap">
|
||||
{/* Fetch Mode */}
|
||||
<div className="flex items-center gap-2">
|
||||
<Label htmlFor="fetch-mode" className="text-sm">
|
||||
Fetch Mode
|
||||
</Label>
|
||||
<Select value={currentFetchMode} onValueChange={(value: SettingsFetchMode) => {
|
||||
updateSettings({ fetchMode: value });
|
||||
setCurrentFetchMode(value);
|
||||
}}>
|
||||
<SelectTrigger id="fetch-mode" className="w-auto h-8 bg-background">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="batch">Batch</SelectItem>
|
||||
<SelectItem value="single">Single</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* Media Type */}
|
||||
<div className="flex items-center gap-2">
|
||||
<Label htmlFor="media-type" className="text-sm">
|
||||
Media Type
|
||||
</Label>
|
||||
<Select value={mediaType} onValueChange={setMediaType}>
|
||||
<Select value={mediaType} onValueChange={(value: SettingsMediaType) => {
|
||||
updateSettings({ mediaType: value });
|
||||
setMediaType(value);
|
||||
}}>
|
||||
<SelectTrigger id="media-type" className="w-auto h-8 bg-background">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
@@ -631,7 +655,11 @@ export function SearchBar({
|
||||
<Checkbox
|
||||
id="retweets"
|
||||
checked={retweets}
|
||||
onCheckedChange={(checked) => setRetweets(checked as boolean)}
|
||||
onCheckedChange={(checked) => {
|
||||
const value = checked as boolean;
|
||||
updateSettings({ includeRetweets: value });
|
||||
setRetweets(value);
|
||||
}}
|
||||
className="bg-background"
|
||||
/>
|
||||
<Label htmlFor="retweets" className="text-sm cursor-pointer">
|
||||
|
||||
@@ -11,6 +11,14 @@ import {
|
||||
} from "@/components/ui/select";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { FolderOpen, Save, RotateCcw, Info, Download, Check } from "lucide-react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { getSettings, getSettingsWithDefaults, saveSettings, resetToDefaultSettings, applyThemeMode, applyFont, FONT_OPTIONS, type Settings as SettingsType, type FontFamily, type GifQuality, type GifResolution } from "@/lib/settings";
|
||||
@@ -26,6 +34,7 @@ export function SettingsPage() {
|
||||
const [downloadingFFmpeg, setDownloadingFFmpeg] = useState(false);
|
||||
const [exiftoolInstalled, setExiftoolInstalled] = useState(false);
|
||||
const [downloadingExifTool, setDownloadingExifTool] = useState(false);
|
||||
const [showResetConfirm, setShowResetConfirm] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
applyThemeMode(savedSettings.themeMode);
|
||||
@@ -80,6 +89,7 @@ export function SettingsPage() {
|
||||
applyThemeMode(defaultSettings.themeMode);
|
||||
applyTheme(defaultSettings.theme);
|
||||
applyFont(defaultSettings.fontFamily);
|
||||
setShowResetConfirm(false);
|
||||
toast.success("Settings reset to default");
|
||||
};
|
||||
|
||||
@@ -418,12 +428,13 @@ export function SettingsPage() {
|
||||
className="w-[20%]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex gap-2 justify-between pt-4 border-t">
|
||||
<Button variant="outline" onClick={handleReset} className="gap-1.5">
|
||||
<Button variant="outline" onClick={() => setShowResetConfirm(true)} className="gap-1.5">
|
||||
<RotateCcw className="h-4 w-4" />
|
||||
Reset to Default
|
||||
</Button>
|
||||
@@ -432,6 +443,22 @@ export function SettingsPage() {
|
||||
Save Changes
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Reset Confirmation Dialog */}
|
||||
<Dialog open={showResetConfirm} onOpenChange={setShowResetConfirm}>
|
||||
<DialogContent className="max-w-md [&>button]:hidden">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Reset to Default?</DialogTitle>
|
||||
<DialogDescription>
|
||||
This will reset all settings to their default values. Your custom configurations will be lost.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => setShowResetConfirm(false)}>Cancel</Button>
|
||||
<Button onClick={handleReset}>Reset</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,10 @@
|
||||
import { Home, Settings, Bug, Database, LayoutGrid, Coffee, Github } from "lucide-react";
|
||||
import { HomeIcon } from "@/components/ui/home";
|
||||
import { SettingsIcon } from "@/components/ui/settings";
|
||||
import { ArchiveIcon } from "@/components/ui/archive";
|
||||
import { TerminalIcon } from "@/components/ui/terminal";
|
||||
import { GithubIcon } from "@/components/ui/github";
|
||||
import { BlocksIcon } from "@/components/ui/blocks";
|
||||
import { CoffeeIcon } from "@/components/ui/coffee";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
@@ -15,33 +21,76 @@ interface SidebarProps {
|
||||
}
|
||||
|
||||
export function Sidebar({ currentPage, onPageChange }: SidebarProps) {
|
||||
const navItems = [
|
||||
{ id: "main" as PageType, icon: Home, label: "Home" },
|
||||
{ id: "settings" as PageType, icon: Settings, label: "Settings" },
|
||||
{ id: "database" as PageType, icon: Database, label: "Saved Accounts" },
|
||||
{ id: "debug" as PageType, icon: Bug, label: "Debug Logs" },
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="fixed left-0 top-0 h-full w-14 bg-card border-r border-border flex flex-col items-center py-14 z-30">
|
||||
<div className="flex flex-col gap-2 flex-1">
|
||||
{navItems.map((item) => (
|
||||
<Tooltip key={item.id} delayDuration={0}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant={currentPage === item.id ? "secondary" : "ghost"}
|
||||
size="icon"
|
||||
className="h-10 w-10"
|
||||
onClick={() => onPageChange(item.id)}
|
||||
>
|
||||
<item.icon className="h-5 w-5" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">
|
||||
<p>{item.label}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
))}
|
||||
{/* Home */}
|
||||
<Tooltip delayDuration={0}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant={currentPage === "main" ? "secondary" : "ghost"}
|
||||
size="icon"
|
||||
className="h-10 w-10"
|
||||
onClick={() => onPageChange("main")}
|
||||
>
|
||||
<HomeIcon size={20} />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">
|
||||
<p>Home</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
|
||||
{/* Settings */}
|
||||
<Tooltip delayDuration={0}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant={currentPage === "settings" ? "secondary" : "ghost"}
|
||||
size="icon"
|
||||
className="h-10 w-10"
|
||||
onClick={() => onPageChange("settings")}
|
||||
>
|
||||
<SettingsIcon size={20} />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">
|
||||
<p>Settings</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
|
||||
{/* Database - using animated archive icon */}
|
||||
<Tooltip delayDuration={0}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant={currentPage === "database" ? "secondary" : "ghost"}
|
||||
size="icon"
|
||||
className="h-10 w-10"
|
||||
onClick={() => onPageChange("database")}
|
||||
>
|
||||
<ArchiveIcon size={20} />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">
|
||||
<p>Saved Accounts</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
|
||||
{/* Debug - using animated terminal icon */}
|
||||
<Tooltip delayDuration={0}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant={currentPage === "debug" ? "secondary" : "ghost"}
|
||||
size="icon"
|
||||
className="h-10 w-10"
|
||||
onClick={() => onPageChange("debug")}
|
||||
>
|
||||
<TerminalIcon size={20} />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">
|
||||
<p>Debug Logs</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
{/* Bottom icons */}
|
||||
@@ -54,7 +103,7 @@ export function Sidebar({ currentPage, onPageChange }: SidebarProps) {
|
||||
className="h-10 w-10"
|
||||
onClick={() => openExternal("https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/issues")}
|
||||
>
|
||||
<Github className="h-5 w-5" />
|
||||
<GithubIcon size={20} />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">
|
||||
@@ -69,7 +118,7 @@ export function Sidebar({ currentPage, onPageChange }: SidebarProps) {
|
||||
className="h-10 w-10"
|
||||
onClick={() => openExternal("https://exyezed.cc/")}
|
||||
>
|
||||
<LayoutGrid className="h-5 w-5" />
|
||||
<BlocksIcon size={20} />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">
|
||||
@@ -84,7 +133,7 @@ export function Sidebar({ currentPage, onPageChange }: SidebarProps) {
|
||||
className="h-10 w-10"
|
||||
onClick={() => openExternal("https://ko-fi.com/afkarxyz")}
|
||||
>
|
||||
<Coffee className="h-5 w-5" />
|
||||
<CoffeeIcon size={20} />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
'use client';
|
||||
|
||||
import type { Variants } from 'motion/react';
|
||||
import type { HTMLAttributes } from 'react';
|
||||
import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
||||
import { motion, useAnimation } from 'motion/react';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export interface ArchiveIconHandle {
|
||||
startAnimation: () => void;
|
||||
stopAnimation: () => void;
|
||||
}
|
||||
|
||||
interface ArchiveIconProps extends HTMLAttributes<HTMLDivElement> {
|
||||
size?: number;
|
||||
}
|
||||
|
||||
const RECT_VARIANTS: Variants = {
|
||||
normal: {
|
||||
translateY: 0,
|
||||
transition: {
|
||||
duration: 0.2,
|
||||
type: 'spring',
|
||||
stiffness: 200,
|
||||
damping: 25,
|
||||
},
|
||||
},
|
||||
animate: {
|
||||
translateY: -1.5,
|
||||
transition: {
|
||||
duration: 0.2,
|
||||
type: 'spring',
|
||||
stiffness: 200,
|
||||
damping: 25,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const PATH_VARIANTS: Variants = {
|
||||
normal: { d: 'M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8' },
|
||||
animate: { d: 'M4 11v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V11' },
|
||||
};
|
||||
|
||||
const SECONDARY_PATH_VARIANTS: Variants = {
|
||||
normal: { d: 'M10 12h4' },
|
||||
animate: { d: 'M10 15h4' },
|
||||
};
|
||||
|
||||
const ArchiveIcon = forwardRef<ArchiveIconHandle, ArchiveIconProps>(
|
||||
({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {
|
||||
const controls = useAnimation();
|
||||
const isControlledRef = useRef(false);
|
||||
|
||||
useImperativeHandle(ref, () => {
|
||||
isControlledRef.current = true;
|
||||
|
||||
return {
|
||||
startAnimation: () => controls.start('animate'),
|
||||
stopAnimation: () => controls.start('normal'),
|
||||
};
|
||||
});
|
||||
|
||||
const handleMouseEnter = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('animate');
|
||||
} else {
|
||||
onMouseEnter?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseEnter]
|
||||
);
|
||||
|
||||
const handleMouseLeave = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('normal');
|
||||
} else {
|
||||
onMouseLeave?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseLeave]
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(className)}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
{...props}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<motion.rect
|
||||
width="20"
|
||||
height="5"
|
||||
x="2"
|
||||
y="3"
|
||||
rx="1"
|
||||
initial="normal"
|
||||
animate={controls}
|
||||
variants={RECT_VARIANTS}
|
||||
/>
|
||||
<motion.path
|
||||
d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"
|
||||
variants={PATH_VARIANTS}
|
||||
animate={controls}
|
||||
/>
|
||||
<motion.path
|
||||
d="M10 12h4"
|
||||
variants={SECONDARY_PATH_VARIANTS}
|
||||
animate={controls}
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ArchiveIcon.displayName = 'ArchiveIcon';
|
||||
|
||||
export { ArchiveIcon };
|
||||
@@ -0,0 +1,92 @@
|
||||
'use client';
|
||||
|
||||
import type { Variants } from 'motion/react';
|
||||
import type { HTMLAttributes } from 'react';
|
||||
import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
||||
import { motion, useAnimation } from 'motion/react';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export interface BlocksIconHandle {
|
||||
startAnimation: () => void;
|
||||
stopAnimation: () => void;
|
||||
}
|
||||
|
||||
interface BlocksIconProps extends HTMLAttributes<HTMLDivElement> {
|
||||
size?: number;
|
||||
}
|
||||
|
||||
const VARIANTS: Variants = {
|
||||
normal: { translateX: 0, translateY: 0 },
|
||||
animate: { translateX: -4, translateY: 4 },
|
||||
};
|
||||
|
||||
const BlocksIcon = forwardRef<BlocksIconHandle, BlocksIconProps>(
|
||||
({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {
|
||||
const controls = useAnimation();
|
||||
const isControlledRef = useRef(false);
|
||||
|
||||
useImperativeHandle(ref, () => {
|
||||
isControlledRef.current = true;
|
||||
|
||||
return {
|
||||
startAnimation: () => controls.start('animate'),
|
||||
stopAnimation: () => controls.start('normal'),
|
||||
};
|
||||
});
|
||||
|
||||
const handleMouseEnter = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('animate');
|
||||
} else {
|
||||
onMouseEnter?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseEnter]
|
||||
);
|
||||
|
||||
const handleMouseLeave = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('normal');
|
||||
} else {
|
||||
onMouseLeave?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseLeave]
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(className)}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
{...props}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<path d="M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3" />
|
||||
<motion.path
|
||||
d="M14 3h7v7h-7z"
|
||||
variants={VARIANTS}
|
||||
animate={controls}
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
BlocksIcon.displayName = 'BlocksIcon';
|
||||
|
||||
export { BlocksIcon };
|
||||
@@ -0,0 +1,118 @@
|
||||
'use client';
|
||||
|
||||
import type { Variants } from 'motion/react';
|
||||
import type { HTMLAttributes } from 'react';
|
||||
import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
||||
import { motion, useAnimation } from 'motion/react';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export interface CoffeeIconHandle {
|
||||
startAnimation: () => void;
|
||||
stopAnimation: () => void;
|
||||
}
|
||||
|
||||
interface CoffeeIconProps extends HTMLAttributes<HTMLDivElement> {
|
||||
size?: number;
|
||||
}
|
||||
|
||||
const PATH_VARIANTS: Variants = {
|
||||
normal: {
|
||||
y: 0,
|
||||
opacity: 1,
|
||||
},
|
||||
animate: (custom: number) => ({
|
||||
y: -3,
|
||||
opacity: [0, 1, 0],
|
||||
transition: {
|
||||
repeat: Infinity,
|
||||
duration: 1.5,
|
||||
ease: 'easeInOut',
|
||||
delay: 0.2 * custom,
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const CoffeeIcon = forwardRef<CoffeeIconHandle, CoffeeIconProps>(
|
||||
({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {
|
||||
const controls = useAnimation();
|
||||
const isControlledRef = useRef(false);
|
||||
|
||||
useImperativeHandle(ref, () => {
|
||||
isControlledRef.current = true;
|
||||
|
||||
return {
|
||||
startAnimation: () => controls.start('animate'),
|
||||
stopAnimation: () => controls.start('normal'),
|
||||
};
|
||||
});
|
||||
|
||||
const handleMouseEnter = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('animate');
|
||||
} else {
|
||||
onMouseEnter?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseEnter]
|
||||
);
|
||||
|
||||
const handleMouseLeave = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('normal');
|
||||
} else {
|
||||
onMouseLeave?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseLeave]
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(className)}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
{...props}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
style={{ overflow: 'visible' }}
|
||||
>
|
||||
<motion.path
|
||||
d="M10 2v2"
|
||||
animate={controls}
|
||||
variants={PATH_VARIANTS}
|
||||
custom={0.2}
|
||||
/>
|
||||
<motion.path
|
||||
d="M14 2v2"
|
||||
animate={controls}
|
||||
variants={PATH_VARIANTS}
|
||||
custom={0.4}
|
||||
/>
|
||||
<motion.path
|
||||
d="M6 2v2"
|
||||
animate={controls}
|
||||
variants={PATH_VARIANTS}
|
||||
custom={0}
|
||||
/>
|
||||
<path d="M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1" />
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
CoffeeIcon.displayName = 'CoffeeIcon';
|
||||
|
||||
export { CoffeeIcon };
|
||||
@@ -0,0 +1,149 @@
|
||||
'use client';
|
||||
|
||||
import type { Variants } from 'motion/react';
|
||||
import type { HTMLAttributes } from 'react';
|
||||
import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
||||
import { motion, useAnimation } from 'motion/react';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export interface GithubIconHandle {
|
||||
startAnimation: () => void;
|
||||
stopAnimation: () => void;
|
||||
}
|
||||
|
||||
interface GithubIconProps extends HTMLAttributes<HTMLDivElement> {
|
||||
size?: number;
|
||||
}
|
||||
|
||||
const BODY_VARIANTS: Variants = {
|
||||
normal: {
|
||||
opacity: 1,
|
||||
pathLength: 1,
|
||||
scale: 1,
|
||||
transition: {
|
||||
duration: 0.3,
|
||||
},
|
||||
},
|
||||
animate: {
|
||||
opacity: [0, 1],
|
||||
pathLength: [0, 1],
|
||||
scale: [0.9, 1],
|
||||
transition: {
|
||||
duration: 0.4,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const TAIL_VARIANTS: Variants = {
|
||||
normal: {
|
||||
pathLength: 1,
|
||||
rotate: 0,
|
||||
transition: {
|
||||
duration: 0.3,
|
||||
},
|
||||
},
|
||||
draw: {
|
||||
pathLength: [0, 1],
|
||||
rotate: 0,
|
||||
transition: {
|
||||
duration: 0.5,
|
||||
},
|
||||
},
|
||||
wag: {
|
||||
pathLength: 1,
|
||||
rotate: [0, -15, 15, -10, 10, -5, 5],
|
||||
transition: {
|
||||
duration: 2.5,
|
||||
ease: 'easeInOut',
|
||||
repeat: Infinity,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const GithubIcon = forwardRef<GithubIconHandle, GithubIconProps>(
|
||||
({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {
|
||||
const bodyControls = useAnimation();
|
||||
const tailControls = useAnimation();
|
||||
const isControlledRef = useRef(false);
|
||||
|
||||
useImperativeHandle(ref, () => {
|
||||
isControlledRef.current = true;
|
||||
|
||||
return {
|
||||
startAnimation: async () => {
|
||||
bodyControls.start('animate');
|
||||
await tailControls.start('draw');
|
||||
tailControls.start('wag');
|
||||
},
|
||||
stopAnimation: () => {
|
||||
bodyControls.start('normal');
|
||||
tailControls.start('normal');
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const handleMouseEnter = useCallback(
|
||||
async (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
bodyControls.start('animate');
|
||||
await tailControls.start('draw');
|
||||
tailControls.start('wag');
|
||||
} else {
|
||||
onMouseEnter?.(e);
|
||||
}
|
||||
},
|
||||
[bodyControls, onMouseEnter, tailControls]
|
||||
);
|
||||
|
||||
const handleMouseLeave = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
bodyControls.start('normal');
|
||||
tailControls.start('normal');
|
||||
} else {
|
||||
onMouseLeave?.(e);
|
||||
}
|
||||
},
|
||||
[bodyControls, tailControls, onMouseLeave]
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(className)}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
{...props}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<motion.path
|
||||
variants={BODY_VARIANTS}
|
||||
initial="normal"
|
||||
animate={bodyControls}
|
||||
d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"
|
||||
/>
|
||||
<motion.path
|
||||
variants={TAIL_VARIANTS}
|
||||
initial="normal"
|
||||
animate={tailControls}
|
||||
d="M9 18c-4.51 2-5-2-7-2"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
GithubIcon.displayName = 'GithubIcon';
|
||||
|
||||
export { GithubIcon };
|
||||
@@ -0,0 +1,103 @@
|
||||
'use client';
|
||||
|
||||
import type { Transition, Variants } from 'motion/react';
|
||||
import type { HTMLAttributes } from 'react';
|
||||
import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
||||
import { motion, useAnimation } from 'motion/react';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export interface HomeIconHandle {
|
||||
startAnimation: () => void;
|
||||
stopAnimation: () => void;
|
||||
}
|
||||
|
||||
interface HomeIconProps extends HTMLAttributes<HTMLDivElement> {
|
||||
size?: number;
|
||||
}
|
||||
|
||||
const DEFAULT_TRANSITION: Transition = {
|
||||
duration: 0.6,
|
||||
opacity: { duration: 0.2 },
|
||||
};
|
||||
|
||||
const PATH_VARIANTS: Variants = {
|
||||
normal: {
|
||||
pathLength: 1,
|
||||
opacity: 1,
|
||||
},
|
||||
animate: {
|
||||
opacity: [0, 1],
|
||||
pathLength: [0, 1],
|
||||
},
|
||||
};
|
||||
|
||||
const HomeIcon = forwardRef<HomeIconHandle, HomeIconProps>(
|
||||
({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {
|
||||
const controls = useAnimation();
|
||||
const isControlledRef = useRef(false);
|
||||
|
||||
useImperativeHandle(ref, () => {
|
||||
isControlledRef.current = true;
|
||||
|
||||
return {
|
||||
startAnimation: () => controls.start('animate'),
|
||||
stopAnimation: () => controls.start('normal'),
|
||||
};
|
||||
});
|
||||
|
||||
const handleMouseEnter = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('animate');
|
||||
} else {
|
||||
onMouseEnter?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseEnter]
|
||||
);
|
||||
|
||||
const handleMouseLeave = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('normal');
|
||||
} else {
|
||||
onMouseLeave?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseLeave]
|
||||
);
|
||||
return (
|
||||
<div
|
||||
className={cn(className)}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
{...props}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
|
||||
<motion.path
|
||||
d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"
|
||||
variants={PATH_VARIANTS}
|
||||
transition={DEFAULT_TRANSITION}
|
||||
animate={controls}
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
HomeIcon.displayName = 'HomeIcon';
|
||||
|
||||
export { HomeIcon };
|
||||
@@ -0,0 +1,92 @@
|
||||
'use client';
|
||||
|
||||
import type { HTMLAttributes } from 'react';
|
||||
import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
||||
import { motion, useAnimation } from 'motion/react';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export interface SettingsIconHandle {
|
||||
startAnimation: () => void;
|
||||
stopAnimation: () => void;
|
||||
}
|
||||
|
||||
interface SettingsIconProps extends HTMLAttributes<HTMLDivElement> {
|
||||
size?: number;
|
||||
}
|
||||
|
||||
const SettingsIcon = forwardRef<SettingsIconHandle, SettingsIconProps>(
|
||||
({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {
|
||||
const controls = useAnimation();
|
||||
const isControlledRef = useRef(false);
|
||||
|
||||
useImperativeHandle(ref, () => {
|
||||
isControlledRef.current = true;
|
||||
|
||||
return {
|
||||
startAnimation: () => controls.start('animate'),
|
||||
stopAnimation: () => controls.start('normal'),
|
||||
};
|
||||
});
|
||||
|
||||
const handleMouseEnter = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('animate');
|
||||
} else {
|
||||
onMouseEnter?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseEnter]
|
||||
);
|
||||
|
||||
const handleMouseLeave = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('normal');
|
||||
} else {
|
||||
onMouseLeave?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseLeave]
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(className)}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
{...props}
|
||||
>
|
||||
<motion.svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
transition={{ type: 'spring', stiffness: 50, damping: 10 }}
|
||||
variants={{
|
||||
normal: {
|
||||
rotate: 0,
|
||||
},
|
||||
animate: {
|
||||
rotate: 180,
|
||||
},
|
||||
}}
|
||||
animate={controls}
|
||||
>
|
||||
<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</motion.svg>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
SettingsIcon.displayName = 'SettingsIcon';
|
||||
|
||||
export { SettingsIcon };
|
||||
@@ -0,0 +1,103 @@
|
||||
'use client';
|
||||
|
||||
import type { Variants } from 'motion/react';
|
||||
import type { HTMLAttributes } from 'react';
|
||||
import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
||||
import { motion, useAnimation } from 'motion/react';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export interface TerminalIconHandle {
|
||||
startAnimation: () => void;
|
||||
stopAnimation: () => void;
|
||||
}
|
||||
|
||||
interface TerminalIconProps extends HTMLAttributes<HTMLDivElement> {
|
||||
size?: number;
|
||||
}
|
||||
|
||||
const LINE_VARIANTS: Variants = {
|
||||
normal: { opacity: 1 },
|
||||
animate: {
|
||||
opacity: [1, 0, 1],
|
||||
transition: {
|
||||
duration: 0.8,
|
||||
repeat: Infinity,
|
||||
ease: 'linear',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const TerminalIcon = forwardRef<TerminalIconHandle, TerminalIconProps>(
|
||||
({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {
|
||||
const controls = useAnimation();
|
||||
const isControlledRef = useRef(false);
|
||||
|
||||
useImperativeHandle(ref, () => {
|
||||
isControlledRef.current = true;
|
||||
|
||||
return {
|
||||
startAnimation: () => controls.start('animate'),
|
||||
stopAnimation: () => controls.start('normal'),
|
||||
};
|
||||
});
|
||||
|
||||
const handleMouseEnter = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('animate');
|
||||
} else {
|
||||
onMouseEnter?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseEnter]
|
||||
);
|
||||
|
||||
const handleMouseLeave = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!isControlledRef.current) {
|
||||
controls.start('normal');
|
||||
} else {
|
||||
onMouseLeave?.(e);
|
||||
}
|
||||
},
|
||||
[controls, onMouseLeave]
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(className)}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
{...props}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<polyline points="4 17 10 11 4 5" />
|
||||
<motion.line
|
||||
x1="12"
|
||||
x2="20"
|
||||
y1="19"
|
||||
y2="19"
|
||||
variants={LINE_VARIANTS}
|
||||
animate={controls}
|
||||
initial="normal"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
TerminalIcon.displayName = 'TerminalIcon';
|
||||
|
||||
export { TerminalIcon };
|
||||
Reference in new issue
Block a user