Modernize frontend and centralize branding

This commit is contained in:
wfalkowski committed 2026-10-18 20:35:12 +00:00
1 parent bc4542d0fb
commit 2d61d80550
55 files changed
+1901 -14446

No files matched your search

+292
View File
@@ -0,0 +1,292 @@
import React, { useState, useEffect, useCallback } from 'react';
import {
Search,
Filter,
Download,
Package,
Calendar
} from "lucide-react";
import { useNavigate } from 'react-router-dom';
import { colors } from '../../theme/colors';
import { Dropdown } from '../../components/dashboardPrimitives';
import { API_BASE_URL } from '../../config/api';
const PluginStore = () => {
const [plugins, setPlugins] = useState([]);
const [loading, setLoading] = useState(false);
const [searchQuery, setSearchQuery] = useState('');
const [selectedGameVersion, setSelectedGameVersion] = useState('');
const [currentPage, setCurrentPage] = useState(0);
const [totalResults, setTotalResults] = useState(0);
const [error, setError] = useState('');
const navigate = useNavigate();
// ... (colors object)
const gameVersions = [
// ...
];
const searchPlugins = useCallback(async (query = '', page = 0) => {
setLoading(true);
setError('');
try {
const params = new URLSearchParams({
query: query || '',
limit: '20',
offset: (page * 20).toString(),
project_type: 'plugin'
});
if (selectedGameVersion) {
params.append('game_versions', selectedGameVersion);
}
const response = await fetch(`${API_BASE_URL}/api/modrinth/search?${params.toString()}`);
if (!response.ok) {
throw new Error('Failed to search plugins');
}
const data = await response.json();
setPlugins(data.hits || []);
setTotalResults(data.total_hits || 0);
} catch (err) {
setError(err.message);
console.error('Error searching plugins:', err);
} finally {
setLoading(false);
}
}, [selectedGameVersion]);
useEffect(() => {
searchPlugins(searchQuery, currentPage);
}, [searchPlugins, searchQuery, currentPage]);
const handleSearch = (e) => {
e.preventDefault();
setCurrentPage(0);
searchPlugins(searchQuery, 0);
};
const handlePluginClick = (pluginId) => {
navigate(`/plugins/${pluginId}`);
};
const formatDate = (dateString) => {
if (!dateString) return 'Unknown';
const date = new Date(dateString);
return date.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' });
};
const truncateDescription = (text, maxLength = 150) => {
if (!text) return 'No description available';
if (text.length <= maxLength) return text;
return text.substring(0, maxLength) + '...';
};
return (
<div className="min-h-app antialiased" style={{ backgroundColor: colors.background }}>
<div className="max-w-7xl mx-auto px-4 py-8">
{/* Header */}
<div className="mb-8">
<h1 className="text-4xl font-bold mb-2" style={{ color: colors.brightWhite }}>
Minecraft Plugin Store
</h1>
<p className="text-lg" style={{ color: colors.foreground }}>
Browse and discover plugins from Modrinth
</p>
</div>
{/* Search and Filters */}
<div className="mb-6 space-y-4">
<form onSubmit={handleSearch} className="flex gap-4">
<div className="flex-1 relative">
<Search className="absolute left-4 top-1/2 transform -translate-y-1/2 w-5 h-5" style={{ color: colors.foreground }} />
<input
type="text"
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
placeholder="Search plugins..."
className="w-full pl-12 pr-4 py-3 rounded-xl border focus:outline-none transition-all"
style={{
backgroundColor: colors.brightBlack,
borderColor: colors.brightBlack,
color: colors.brightWhite
}}
/>
</div>
<button
type="submit"
className="px-6 py-3 rounded-xl font-medium transition-all hover:scale-105 border"
style={{
backgroundColor: colors.blue,
borderColor: colors.blue,
color: colors.brightWhite
}}
>
Search
</button>
</form>
<div className="flex gap-4 flex-wrap">
<div className="w-48">
<Dropdown
value={selectedGameVersion}
options={gameVersions}
onChange={(value) => {
setSelectedGameVersion(value);
setCurrentPage(0);
}}
placeholder="All Versions"
icon={Filter}
/>
</div>
</div>
</div>
{/* Error Message */}
{error && (
<div className="mb-6 p-4 rounded-xl border" style={{ backgroundColor: `${colors.red}20`, borderColor: colors.red }}>
<p style={{ color: colors.brightRed }}>{error}</p>
</div>
)}
{/* Loading State */}
{loading && (
<div className="flex justify-center items-center py-12">
<div className="w-8 h-8 border-4 border-current border-t-transparent rounded-full animate-spin" style={{ color: colors.blue }} />
</div>
)}
{/* Plugin Grid */}
{!loading && plugins.length > 0 && (
<>
<div className="mb-4">
<p style={{ color: colors.foreground }}>
Found {totalResults} plugin{totalResults !== 1 ? 's' : ''}
</p>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{plugins.map((plugin) => (
<div
key={plugin.project_id}
onClick={() => handlePluginClick(plugin.project_id)}
className="rounded-xl border p-6 cursor-pointer transition-all hover:scale-105 hover:shadow-lg"
style={{
backgroundColor: colors.backgroundSecondary,
borderColor: colors.brightBlack
}}
>
<div className="flex items-start gap-4 mb-4">
{plugin.icon_url ? (
<img
src={plugin.icon_url}
alt={plugin.title}
className="w-16 h-16 rounded-lg object-cover flex-shrink-0"
/>
) : (
<div
className="w-16 h-16 rounded-lg flex items-center justify-center flex-shrink-0"
style={{ backgroundColor: colors.brightBlack }}
>
<Package className="w-8 h-8" style={{ color: colors.foreground }} />
</div>
)}
<div className="flex-1 min-w-0">
<h3 className="text-lg font-semibold mb-1 truncate" style={{ color: colors.brightWhite }}>
{plugin.title}
</h3>
<p className="text-sm truncate" style={{ color: colors.foreground }}>
by {plugin.author}
</p>
</div>
</div>
<p className="text-sm mb-4 line-clamp-3" style={{ color: colors.foreground }}>
{truncateDescription(plugin.description)}
</p>
<div className="flex items-center justify-between text-sm">
<div className="flex items-center gap-4">
<div className="flex items-center gap-1">
<Download className="w-4 h-4" style={{ color: colors.blue }} />
<span style={{ color: colors.foreground }}>{plugin.downloads?.toLocaleString() || 0}</span>
</div>
</div>
<div className="flex items-center gap-1">
<Calendar className="w-4 h-4" style={{ color: colors.foreground }} />
<span style={{ color: colors.foreground }}>{formatDate(plugin.date_modified)}</span>
</div>
</div>
{plugin.loaders && plugin.loaders.length > 0 && (
<div className="mt-4 flex flex-wrap gap-2">
{plugin.loaders.slice(0, 3).map((loader) => (
<span
key={loader}
className="px-2 py-1 rounded text-xs"
style={{ backgroundColor: colors.brightBlack, color: colors.foreground }}
>
{loader}
</span>
))}
</div>
)}
</div>
))}
</div>
{/* Pagination */}
{totalResults > 20 && (
<div className="mt-8 flex justify-center gap-4">
<button
onClick={() => setCurrentPage(Math.max(0, currentPage - 1))}
disabled={currentPage === 0}
className="px-4 py-2 rounded-xl border transition-all disabled:opacity-50"
style={{
backgroundColor: colors.brightBlack,
borderColor: colors.brightBlack,
color: colors.brightWhite
}}
>
Previous
</button>
<span className="px-4 py-2" style={{ color: colors.foreground }}>
Page {currentPage + 1} of {Math.ceil(totalResults / 20)}
</span>
<button
onClick={() => setCurrentPage(currentPage + 1)}
disabled={(currentPage + 1) * 20 >= totalResults}
className="px-4 py-2 rounded-xl border transition-all disabled:opacity-50"
style={{
backgroundColor: colors.brightBlack,
borderColor: colors.brightBlack,
color: colors.brightWhite
}}
>
Next
</button>
</div>
)}
</>
)}
{/* Empty State */}
{!loading && plugins.length === 0 && !error && (
<div className="text-center py-12">
<Package className="w-16 h-16 mx-auto mb-4" style={{ color: colors.foreground }} />
<p className="text-lg" style={{ color: colors.foreground }}>
No plugins found. Try adjusting your search or filters.
</p>
</div>
)}
</div>
</div>
);
}
export default PluginStore;