Spaces:
Running
Running
File size: 15,877 Bytes
5c85958 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
import { useState, useMemo } from 'react';
import {
Box,
Container,
Typography,
InputBase,
Avatar,
Chip,
Checkbox,
FormControlLabel,
CircularProgress,
Link,
IconButton,
} from '@mui/material';
import SearchIcon from '@mui/icons-material/Search';
import CloseIcon from '@mui/icons-material/Close';
import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder';
import AccessTimeIcon from '@mui/icons-material/AccessTime';
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
import VerifiedIcon from '@mui/icons-material/Verified';
import Layout from '../components/Layout';
import ReachiesCarousel from '../components/ReachiesCarousel';
import { useApps } from '../context/AppsContext';
// App Card Component
function AppCard({ app }) {
const isOfficial = app.isOfficial;
const cardData = app.cardData || {};
const author = app.id?.split('/')?.[0] || app.author || null;
const likes = app.likes || 0;
const lastModified = app.lastModified || app.createdAt || null;
const emoji = cardData.emoji || '📦';
const formattedDate = lastModified
? new Date(lastModified).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })
: null;
const spaceUrl = `https://huggingface.co/spaces/${app.id}`;
return (
<Box
component={Link}
href={spaceUrl}
target="_blank"
rel="noopener noreferrer"
sx={{
display: 'flex',
flexDirection: 'column',
borderRadius: '16px',
position: 'relative',
overflow: 'hidden',
bgcolor: '#ffffff',
border: isOfficial ? '1px solid rgba(59, 130, 246, 0.25)' : '1px solid rgba(0, 0, 0, 0.08)',
cursor: 'pointer',
transition: 'all 0.2s ease',
textDecoration: 'none',
'&:hover': {
transform: 'translateY(-4px)',
boxShadow: '0 12px 40px rgba(0, 0, 0, 0.12)',
borderColor: isOfficial ? 'rgba(59, 130, 246, 0.4)' : 'rgba(0, 0, 0, 0.15)',
},
}}
>
{/* Top Bar with Author, Official Badge, and Likes */}
<Box
sx={{
px: 2.5,
pt: 2,
pb: 1.5,
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
borderBottom: '1px solid rgba(0, 0, 0, 0.06)',
}}
>
{/* Author + Official Badge */}
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, minWidth: 0, flex: 1 }}>
{author && (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.75, minWidth: 0 }}>
<Avatar
sx={{
width: 22,
height: 22,
bgcolor: isOfficial ? 'rgba(59, 130, 246, 0.15)' : 'rgba(0, 0, 0, 0.08)',
fontSize: 11,
fontWeight: 600,
color: isOfficial ? '#FF9500' : '#1a1a1a',
flexShrink: 0,
}}
>
{author.charAt(0).toUpperCase()}
</Avatar>
<Typography
sx={{
fontSize: 12,
fontWeight: 500,
color: '#666666',
fontFamily: 'monospace',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}
>
{author}
</Typography>
</Box>
)}
{/* Official Badge - inline with author */}
{isOfficial && (
<Chip
icon={<VerifiedIcon sx={{ fontSize: 12 }} />}
label="Official"
size="small"
sx={{
bgcolor: 'rgba(255, 149, 0, 0.1)',
color: '#FF9500',
fontWeight: 600,
fontSize: 10,
height: 20,
flexShrink: 0,
'& .MuiChip-icon': {
color: '#FF9500',
ml: 0.5,
},
'& .MuiChip-label': {
px: 0.75,
},
}}
/>
)}
</Box>
{/* Likes */}
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, flexShrink: 0 }}>
<FavoriteBorderIcon sx={{ fontSize: 16, color: '#666666' }} />
<Typography
sx={{
fontSize: 12,
fontWeight: 600,
color: '#666666',
}}
>
{likes}
</Typography>
</Box>
</Box>
{/* Content */}
<Box
sx={{
px: 2.5,
py: 2.5,
display: 'flex',
flexDirection: 'column',
flex: 1,
}}
>
{/* Title + Emoji Row */}
<Box sx={{ display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 1, mb: 1 }}>
<Typography
sx={{
fontSize: 17,
fontWeight: 700,
color: '#1a1a1a',
letterSpacing: '-0.3px',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
flex: 1,
}}
>
{app.name || app.id?.split('/').pop()}
</Typography>
<Typography
component="span"
sx={{
fontSize: 28,
lineHeight: 1,
flexShrink: 0,
}}
>
{emoji}
</Typography>
</Box>
{/* Description */}
<Typography
sx={{
fontSize: 13,
color: '#666666',
lineHeight: 1.5,
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
overflow: 'hidden',
textOverflow: 'ellipsis',
mb: 2,
flex: 1,
}}
>
{cardData.short_description || app.description || 'No description'}
</Typography>
{/* Date + Open Link */}
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
{formattedDate && (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
<AccessTimeIcon sx={{ fontSize: 14, color: '#999' }} />
<Typography
sx={{
fontSize: 11,
fontWeight: 500,
color: '#999',
}}
>
{formattedDate}
</Typography>
</Box>
)}
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, color: '#FF9500' }}>
<Typography sx={{ fontSize: 12, fontWeight: 600 }}>
View on HF
</Typography>
<OpenInNewIcon sx={{ fontSize: 14 }} />
</Box>
</Box>
</Box>
</Box>
);
}
// Main Apps Page
export default function Apps() {
// Get apps from context (cached globally)
const { apps, loading, error } = useApps();
const [searchQuery, setSearchQuery] = useState('');
const [officialOnly, setOfficialOnly] = useState(false);
// Filter apps based on search and official toggle
const filteredApps = useMemo(() => {
let result = apps;
// Filter by official
if (officialOnly) {
result = result.filter(app => app.isOfficial === true);
}
// Filter by search
if (searchQuery.trim()) {
const query = searchQuery.toLowerCase();
result = result.filter(app =>
app.name?.toLowerCase().includes(query) ||
app.id?.toLowerCase().includes(query) ||
app.description?.toLowerCase().includes(query) ||
app.cardData?.short_description?.toLowerCase().includes(query)
);
}
return result;
}, [apps, searchQuery, officialOnly]);
const isFiltered = searchQuery.trim() || officialOnly;
return (
<Layout transparentHeader>
{/* Hero Header */}
<Box
sx={{
background: 'linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%)',
pt: { xs: 16, md: 18 },
pb: { xs: 10, md: 12 },
position: 'relative',
overflow: 'visible',
}}
>
{/* Gradient orbs */}
<Box
sx={{
position: 'absolute',
top: '10%',
right: '10%',
width: 400,
height: 400,
background: 'radial-gradient(circle, rgba(236, 72, 153, 0.15) 0%, transparent 60%)',
filter: 'blur(80px)',
pointerEvents: 'none',
}}
/>
<Box
sx={{
position: 'absolute',
bottom: '-20%',
left: '5%',
width: 350,
height: 350,
background: 'radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 60%)',
filter: 'blur(60px)',
pointerEvents: 'none',
}}
/>
<Container maxWidth="lg" sx={{ position: 'relative', zIndex: 10 }}>
<Box
sx={{
display: 'flex',
alignItems: 'center',
gap: { xs: 4, md: 6 },
flexDirection: { xs: 'column', md: 'row' },
}}
>
{/* Reachies Carousel */}
<Box sx={{ flexShrink: 0 }}>
<ReachiesCarousel
width={200}
height={200}
interval={2500}
fadeInDuration={400}
fadeOutDuration={150}
zoom={1.6}
verticalAlign="60%"
/>
</Box>
{/* Text content */}
<Box sx={{ textAlign: { xs: 'center', md: 'left' } }}>
<Box
sx={{
display: 'inline-flex',
alignItems: 'center',
gap: 0.75,
px: 2,
py: 0.75,
mb: 2,
borderRadius: 50,
backgroundColor: 'rgba(255,255,255,0.1)',
border: '1px solid rgba(255,255,255,0.15)',
backdropFilter: 'blur(10px)',
}}
>
<Typography
variant="caption"
sx={{
color: 'rgba(255,255,255,0.7)',
fontWeight: 500,
fontSize: 11,
}}
>
Powered by
</Typography>
<Box component="img" src="/assets/hf-logo.svg" alt="Hugging Face" sx={{ height: 14 }} />
</Box>
<Typography
variant="h1"
component="h1"
sx={{
color: 'white',
fontWeight: 700,
mb: 3,
fontSize: { xs: 36, md: 52 },
background: 'linear-gradient(135deg, #ffffff 0%, rgba(255,255,255,0.8) 100%)',
WebkitBackgroundClip: 'text',
WebkitTextFillColor: 'transparent',
}}
>
Applications
</Typography>
<Typography
variant="h6"
sx={{
color: 'rgba(255,255,255,0.7)',
fontWeight: 400,
maxWidth: 550,
lineHeight: 1.7,
}}
>
Discover apps built by the community and official apps from Pollen Robotics.
Install them directly from the Reachy Mini desktop app.
</Typography>
</Box>
</Box>
</Container>
</Box>
{/* Search Section */}
<Container maxWidth="lg" sx={{ mt: -4, mb: 4, position: 'relative', zIndex: 10 }}>
<Box
sx={{
display: 'flex',
alignItems: 'center',
gap: 2,
px: 3,
py: 2,
borderRadius: '16px',
bgcolor: 'white',
boxShadow: '0 4px 24px rgba(0, 0, 0, 0.1)',
border: '1px solid rgba(0, 0, 0, 0.06)',
}}
>
<SearchIcon sx={{ fontSize: 22, color: '#999' }} />
<InputBase
placeholder="Search apps by name or description..."
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
sx={{
flex: 1,
fontSize: 15,
fontWeight: 500,
color: '#333',
'& input::placeholder': {
color: '#999',
opacity: 1,
},
}}
/>
{/* Clear search */}
{searchQuery && (
<IconButton
onClick={() => setSearchQuery('')}
size="small"
sx={{ color: '#999' }}
>
<CloseIcon sx={{ fontSize: 20 }} />
</IconButton>
)}
{/* Separator */}
<Box sx={{ width: '1px', height: '24px', bgcolor: 'rgba(0, 0, 0, 0.1)' }} />
{/* Apps count */}
<Typography
sx={{
fontSize: 13,
fontWeight: 700,
color: isFiltered ? '#FF9500' : '#999',
px: 1.5,
py: 0.5,
borderRadius: '8px',
bgcolor: isFiltered ? 'rgba(255, 149, 0, 0.1)' : 'rgba(0, 0, 0, 0.03)',
}}
>
{isFiltered ? `${filteredApps.length}/${apps.length}` : apps.length}
</Typography>
{/* Separator */}
<Box sx={{ width: '1px', height: '24px', bgcolor: 'rgba(0, 0, 0, 0.1)' }} />
{/* Official toggle */}
<FormControlLabel
control={
<Checkbox
checked={officialOnly}
onChange={(e) => setOfficialOnly(e.target.checked)}
size="small"
sx={{
color: '#999',
'&.Mui-checked': {
color: '#FF9500',
},
}}
/>
}
label={
<Typography sx={{ fontSize: 13, fontWeight: 600, color: '#666' }}>
Official only
</Typography>
}
sx={{ m: 0 }}
/>
</Box>
</Container>
{/* Apps Grid */}
<Container maxWidth="lg" sx={{ pb: 10 }}>
{loading ? (
<Box sx={{ display: 'flex', justifyContent: 'center', py: 10 }}>
<CircularProgress sx={{ color: '#FF9500' }} />
</Box>
) : error ? (
<Box sx={{ textAlign: 'center', py: 10 }}>
<Typography color="error">{error}</Typography>
</Box>
) : filteredApps.length === 0 ? (
<Box sx={{ textAlign: 'center', py: 10 }}>
<Typography sx={{ fontSize: 48, mb: 2 }}>🔍</Typography>
<Typography variant="h6" sx={{ color: '#666' }}>
No apps found
</Typography>
<Typography sx={{ color: '#999' }}>
Try adjusting your search or filters
</Typography>
</Box>
) : (
<Box
sx={{
display: 'grid',
gridTemplateColumns: {
xs: '1fr',
sm: 'repeat(2, 1fr)',
md: 'repeat(3, 1fr)',
},
gap: 3,
}}
>
{filteredApps.map((app, index) => (
<AppCard
key={app.id || index}
app={app}
/>
))}
</Box>
)}
</Container>
</Layout>
);
}
|