Spaces:
Running
Running
File size: 32,764 Bytes
2fdc543 5c85958 14e18f1 279ae3b 5c85958 279ae3b 5c85958 14e18f1 e8700c6 279ae3b 5c85958 279ae3b 14e18f1 5c85958 c28008c 2fdc543 c28008c 5c85958 4d77ab0 279ae3b 4d77ab0 e8700c6 4d77ab0 5c85958 279ae3b 5c85958 6c16771 e8700c6 6c16771 e8700c6 14e18f1 e8700c6 14e18f1 5c85958 6c16771 5c85958 6c16771 5c85958 c28008c 5c85958 e8700c6 5c85958 0fe543d 279ae3b 0fe543d 279ae3b 0fe543d 279ae3b 0fe543d 279ae3b 5c85958 279ae3b 5c85958 279ae3b 5c85958 c28008c 5c85958 c28008c 5c85958 14e18f1 5c85958 14e18f1 5c85958 14e18f1 5c85958 e8700c6 14e18f1 e8700c6 14e18f1 e8700c6 14e18f1 e8700c6 14e18f1 e8700c6 14e18f1 5c85958 2fdc543 5c85958 30a9cef 5c85958 0fe543d 5c85958 30a9cef 2fdc543 14e18f1 5c85958 0fe543d 279ae3b 0fe543d 279ae3b 0fe543d 279ae3b 30a9cef 2fdc543 5c85958 30a9cef 5c85958 2fdc543 5c85958 2fdc543 81fe438 5c85958 2fdc543 5c85958 c28008c 2fdc543 5c85958 30a9cef 5c85958 30a9cef 5c85958 2fdc543 5c85958 279ae3b 45671b3 279ae3b 45671b3 279ae3b 45671b3 5c85958 30a9cef 5c85958 14e18f1 279ae3b 0fe543d 279ae3b c28008c 5c85958 14e18f1 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 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
import { useState, useMemo, useCallback, useEffect, useRef, memo } from 'react';
import {
Box,
Container,
Typography,
InputBase,
Avatar,
Chip,
Checkbox,
FormControlLabel,
CircularProgress,
Link,
IconButton,
Button,
Tooltip,
} 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 FavoriteIcon from '@mui/icons-material/Favorite';
import AccessTimeIcon from '@mui/icons-material/AccessTime';
import VerifiedIcon from '@mui/icons-material/Verified';
import DownloadIcon from '@mui/icons-material/Download';
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
import LogoutIcon from '@mui/icons-material/Logout';
import Layout from '../components/Layout';
import ReachiesCarousel from '../components/ReachiesCarousel';
import { useApps } from '../context/AppsContext';
import { useAuth } from '../context/AuthContext';
import InstallModal from '../components/InstallModal';
/**
* Render text with highlighted match ranges from Fuse.js.
* indices is an array of [start, end] pairs.
*/
function HighlightText({ text, indices }) {
if (!text) return null;
if (!indices || indices.length === 0) return text;
// Only keep matches that span at least 2 characters
const significant = indices.filter(([start, end]) => end - start >= 1);
if (significant.length === 0) return text;
// Merge overlapping / adjacent ranges and sort
const sorted = [...significant].sort((a, b) => a[0] - b[0]);
const merged = [sorted[0]];
for (let i = 1; i < sorted.length; i++) {
const prev = merged[merged.length - 1];
if (sorted[i][0] <= prev[1] + 1) {
prev[1] = Math.max(prev[1], sorted[i][1]);
} else {
merged.push(sorted[i]);
}
}
const parts = [];
let cursor = 0;
for (const [start, end] of merged) {
if (cursor < start) {
parts.push(<span key={`t${cursor}`}>{text.slice(cursor, start)}</span>);
}
parts.push(
<span
key={`h${start}`}
style={{
backgroundColor: 'rgba(255, 149, 0, 0.18)',
color: '#b36b00',
borderRadius: 2,
padding: '0 1px',
}}
>
{text.slice(start, end + 1)}
</span>
);
cursor = end + 1;
}
if (cursor < text.length) {
parts.push(<span key={`t${cursor}`}>{text.slice(cursor)}</span>);
}
return <>{parts}</>;
}
// App Card Component (memoized to avoid re-renders when only search changes)
const AppCard = memo(function AppCard({ app, onInstallClick, isLiked, onToggleLike, isLoggedIn, matchData }) {
const isOfficial = app.isOfficial;
const isPythonApp = app.extra?.isPythonApp !== false; // Default to true for backwards compatibility
const cardData = app.extra?.cardData || {};
const author = app.extra?.author || app.id?.split('/')?.[0] || null;
const baseLikes = app.extra?.likes || 0;
const lastModified = app.extra?.lastModified || null;
const emoji = cardData.emoji || (isPythonApp ? '📦' : '🌐');
const spaceUrl = app.url || `https://huggingface.co/spaces/${app.id}`;
// Compute displayed likes: adjust based on like state vs original data
const displayedLikes = baseLikes + (isLiked ? 1 : 0);
const formattedDate = lastModified
? new Date(lastModified).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })
: null;
const handleCardClick = () => {
if (isPythonApp) {
onInstallClick?.(app);
} else {
// Web app: open Space in new tab
window.open(spaceUrl, '_blank', 'noopener,noreferrer');
}
};
const handleButtonClick = (e) => {
e.preventDefault();
e.stopPropagation();
if (isPythonApp) {
onInstallClick?.(app);
} else {
window.open(spaceUrl, '_blank', 'noopener,noreferrer');
}
};
return (
<Box
onClick={handleCardClick}
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)',
transition: 'all 0.2s ease',
cursor: 'pointer',
'&: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',
}}
>
<HighlightText text={author} indices={matchData?._searchAuthor} />
</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,
},
}}
/>
)}
{/* Web App Badge */}
{!isPythonApp && (
<Chip
label="Web"
size="small"
sx={{
bgcolor: 'rgba(99, 102, 241, 0.1)',
color: '#6366f1',
fontWeight: 600,
fontSize: 10,
height: 20,
flexShrink: 0,
'& .MuiChip-label': {
px: 0.75,
},
}}
/>
)}
</Box>
{/* Likes - Interactive */}
<Tooltip
title={isLoggedIn ? '' : 'Sign in to like this app'}
arrow
placement="top"
disableHoverListener={isLoggedIn}
>
<Box
component="button"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
onToggleLike?.(app.id);
}}
sx={{
display: 'flex',
alignItems: 'center',
gap: 0.5,
flexShrink: 0,
border: 'none',
bgcolor: 'transparent',
cursor: 'pointer',
p: 0.5,
borderRadius: '6px',
transition: 'all 0.15s ease',
'&:hover': {
bgcolor: 'rgba(236, 72, 153, 0.08)',
},
}}
>
{isLiked ? (
<FavoriteIcon sx={{ fontSize: 16, color: '#ec4899' }} />
) : (
<FavoriteBorderIcon sx={{ fontSize: 16, color: '#666666' }} />
)}
<Typography
sx={{
fontSize: 12,
fontWeight: 600,
color: isLiked ? '#ec4899' : '#666666',
}}
>
{displayedLikes}
</Typography>
</Box>
</Tooltip>
</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,
}}
>
<HighlightText
text={app.name || app.id?.split('/').pop()}
indices={matchData?.name}
/>
</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,
}}
>
<HighlightText
text={cardData.short_description || app.description || 'No description'}
indices={matchData?._searchDescription}
/>
</Typography>
{/* Date + Install Button */}
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
{/* Date */}
{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 />
)}
{/* Action Button */}
<Button
variant="text"
size="small"
endIcon={isPythonApp
? <DownloadIcon sx={{ fontSize: 14 }} />
: <OpenInNewIcon sx={{ fontSize: 14 }} />
}
onClick={handleButtonClick}
sx={{
py: 0.5,
px: 1.5,
borderRadius: '8px',
color: isPythonApp ? '#FF9500' : '#6366f1',
fontWeight: 600,
fontSize: 12,
textTransform: 'none',
'&:hover': {
bgcolor: isPythonApp ? 'rgba(255, 149, 0, 0.08)' : 'rgba(99, 102, 241, 0.08)',
},
}}
>
{isPythonApp ? 'Install' : 'Open'}
</Button>
</Box>
</Box>
</Box>
);
});
// Isolated search input — typing only re-renders this component, not the whole page
const SearchInput = memo(function SearchInput({ onSearch }) {
const [value, setValue] = useState('');
const debounceRef = useRef(null);
useEffect(() => {
clearTimeout(debounceRef.current);
if (!value.trim()) {
onSearch('');
return;
}
debounceRef.current = setTimeout(() => onSearch(value.trim()), 200);
return () => clearTimeout(debounceRef.current);
}, [value, onSearch]);
return (
<>
<SearchIcon sx={{ fontSize: 22, color: '#999' }} />
<InputBase
placeholder="Search apps by name, description, tags..."
value={value}
onChange={(e) => setValue(e.target.value)}
sx={{
flex: 1,
fontSize: 15,
fontWeight: 500,
color: '#333',
'& input::placeholder': {
color: '#999',
opacity: 1,
},
}}
/>
{value && (
<IconButton
onClick={() => { setValue(''); onSearch(''); }}
size="small"
sx={{ color: '#999' }}
>
<CloseIcon sx={{ fontSize: 20 }} />
</IconButton>
)}
</>
);
});
// Tags to exclude from category filters
const EXCLUDED_TAGS = new Set([
'reachy_mini', 'reachy-mini', 'reachy_mini_python_app',
'static', 'docker', 'region:us', 'region:eu',
]);
// Format a tag name for display (e.g. "reachy_mini_game" → "Reachy Mini Game")
function formatTagName(tag) {
if (tag.startsWith('sdk:')) {
const sdk = tag.replace('sdk:', '');
return sdk.charAt(0).toUpperCase() + sdk.slice(1).toLowerCase();
}
return tag
.replace(/_/g, ' ')
.replace(/\b\w/g, (l) => l.toUpperCase());
}
// Main Apps Page
export default function Apps() {
// Get apps from context (cached globally)
const { apps, loading, error } = useApps();
const { user, isLoggedIn, isOAuthAvailable, login, logout, isSpaceLiked, toggleLike } = useAuth();
const [officialOnly, setOfficialOnly] = useState(false);
const [selectedCategory, setSelectedCategory] = useState(null);
const [searchResults, setSearchResults] = useState(null); // null = no search, [] = no matches
const [isSearching, setIsSearching] = useState(false);
const workerRef = useRef(null);
// Initialize search Web Worker
useEffect(() => {
workerRef.current = new Worker(
new URL('../workers/searchWorker.js', import.meta.url),
{ type: 'module' }
);
workerRef.current.onmessage = (e) => {
if (e.data.type === 'RESULTS') {
setSearchResults(e.data.results);
}
};
return () => workerRef.current?.terminate();
}, []);
// Send apps to worker to build index whenever apps change
useEffect(() => {
if (workerRef.current && apps.length > 0) {
workerRef.current.postMessage({ type: 'INDEX', apps });
}
}, [apps]);
// Callback from SearchInput component (already debounced)
const handleSearch = useCallback((query) => {
if (!query) {
setSearchResults(null);
setIsSearching(false);
return;
}
setIsSearching(true);
workerRef.current?.postMessage({ type: 'SEARCH', query });
}, []);
// Install modal state
const [installModalOpen, setInstallModalOpen] = useState(false);
const [selectedApp, setSelectedApp] = useState(null);
const handleInstallClick = (app) => {
setSelectedApp(app);
setInstallModalOpen(true);
};
const handleCloseInstallModal = () => {
setInstallModalOpen(false);
setSelectedApp(null);
};
const handleToggleLike = useCallback(
(spaceId) => {
toggleLike(spaceId);
},
[toggleLike]
);
// Extract available categories from app tags, sorted by count (top 8)
const categories = useMemo(() => {
const categoryMap = new Map();
// Use only apps matching current mode (official toggle)
const baseApps = officialOnly ? apps.filter((a) => a.isOfficial) : apps;
baseApps.forEach((app) => {
const rootTags = app.extra?.tags || [];
const cardDataTags = app.extra?.cardData?.tags || [];
const allTags = [...new Set([...rootTags, ...cardDataTags])];
const sdk = app.extra?.sdk || app.extra?.cardData?.sdk;
allTags.forEach((tag) => {
if (
tag &&
typeof tag === 'string' &&
!tag.startsWith('region:') &&
!EXCLUDED_TAGS.has(tag.toLowerCase())
) {
categoryMap.set(tag, (categoryMap.get(tag) || 0) + 1);
}
});
// Add SDK as category if not already covered by a tag
if (sdk && typeof sdk === 'string') {
const hasMatchingTag = allTags.some(
(t) => t && typeof t === 'string' && t.toLowerCase() === sdk.toLowerCase()
);
if (!hasMatchingTag) {
const sdkKey = `sdk:${sdk}`;
categoryMap.set(sdkKey, (categoryMap.get(sdkKey) || 0) + 1);
}
}
});
return Array.from(categoryMap.entries())
.map(([name, count]) => ({ name, count }))
.sort((a, b) => (b.count !== a.count ? b.count - a.count : a.name.localeCompare(b.name)))
.slice(0, 8);
}, [apps, officialOnly]);
// Filter apps based on worker search results, official toggle, and category
const filteredApps = useMemo(() => {
let result = apps;
// Filter by official
if (officialOnly) {
result = result.filter((app) => app.isOfficial === true);
}
// Filter by category
if (selectedCategory) {
result = result.filter((app) => {
const rootTags = app.extra?.tags || [];
const cardDataTags = app.extra?.cardData?.tags || [];
const allTags = [...new Set([...rootTags, ...cardDataTags])];
const sdk = app.extra?.sdk || app.extra?.cardData?.sdk;
if (selectedCategory.startsWith('sdk:')) {
return sdk === selectedCategory.replace('sdk:', '');
}
const tagMatch = allTags.some(
(t) => t && typeof t === 'string' && t.toLowerCase() === selectedCategory.toLowerCase()
);
const sdkMatch =
sdk && typeof sdk === 'string' && sdk.toLowerCase() === selectedCategory.toLowerCase();
return tagMatch || sdkMatch;
});
}
// Apply fuzzy search results from worker
if (searchResults !== null) {
const scoreMap = new Map(searchResults.map((r) => [r.id, r.score]));
const matchedIds = new Set(searchResults.map((r) => r.id));
result = result.filter((app) => matchedIds.has(app.id));
result.sort((a, b) => (scoreMap.get(a.id) || 1) - (scoreMap.get(b.id) || 1));
return result;
}
// Default sort: by likes (descending)
result.sort((a, b) => (b.extra?.likes || 0) - (a.extra?.likes || 0));
return result;
}, [apps, officialOnly, selectedCategory, searchResults]);
// Build a map of app ID → match highlight data
const matchDataMap = useMemo(() => {
if (!searchResults) return null;
const map = new Map();
for (const r of searchResults) {
map.set(r.id, r.matches);
}
return map;
}, [searchResults]);
const isFiltered = searchResults !== null || officialOnly || selectedCategory;
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: 1, position: 'relative', zIndex: 10 }}>
<Box
sx={{
display: 'flex',
alignItems: 'center',
gap: 2,
px: 3,
py: 2,
mb: 2,
borderRadius: '16px',
bgcolor: 'white',
boxShadow: '0 4px 24px rgba(0, 0, 0, 0.1)',
border: '1px solid rgba(0, 0, 0, 0.06)',
}}
>
<SearchInput onSearch={handleSearch} />
{/* 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 }}
/>
{/* Auth: Login / User (only show when OAuth is available) */}
{isOAuthAvailable && (
<Box sx={{ width: '1px', height: '24px', bgcolor: 'rgba(0, 0, 0, 0.1)' }} />
)}
{isLoggedIn ? (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<Avatar
src={user?.avatarUrl}
sx={{
width: 28,
height: 28,
fontSize: 12,
fontWeight: 600,
bgcolor: '#FF9500',
}}
>
{user?.name?.charAt(0)?.toUpperCase()}
</Avatar>
<Typography
sx={{
fontSize: 13,
fontWeight: 600,
color: '#333',
maxWidth: 100,
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}
>
{user?.preferredUsername || user?.name}
</Typography>
<Tooltip title="Sign out">
<IconButton onClick={logout} size="small" sx={{ color: '#999' }}>
<LogoutIcon sx={{ fontSize: 18 }} />
</IconButton>
</Tooltip>
</Box>
) : isOAuthAvailable ? (
<Button
onClick={login}
variant="text"
size="small"
sx={{
textTransform: 'none',
fontWeight: 600,
fontSize: 13,
color: '#333',
gap: 0.75,
px: 1.5,
borderRadius: '8px',
whiteSpace: 'nowrap',
'&:hover': {
bgcolor: 'rgba(0, 0, 0, 0.04)',
},
}}
>
<Box
component="img"
src="/assets/hf-logo.svg"
alt=""
sx={{ height: 16 }}
/>
Sign in
</Button>
) : null}
</Box>
</Container>
{/* Category Tags */}
{!loading && categories.length > 0 && (
<Container maxWidth="lg" sx={{ mt: 1, mb: 4 }}>
<Box
sx={{
display: 'flex',
alignItems: 'center',
gap: 1.5,
flexWrap: 'wrap',
}}
>
<Typography
sx={{
fontSize: 12,
fontWeight: 600,
color: '#999',
textTransform: 'uppercase',
letterSpacing: '0.05em',
}}
>
Tags
</Typography>
{/* "All" chip */}
<Chip
label={
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
<span>All</span>
<Typography
component="span"
sx={{
fontSize: 11,
fontWeight: 600,
color: !selectedCategory ? '#FF9500' : '#999',
opacity: 0.8,
}}
>
({officialOnly ? apps.filter((a) => a.isOfficial).length : apps.length})
</Typography>
</Box>
}
onClick={() => setSelectedCategory(null)}
size="small"
sx={{
height: 28,
fontSize: 12,
fontWeight: !selectedCategory ? 700 : 500,
bgcolor: !selectedCategory
? 'rgba(255, 149, 0, 0.12)'
: 'rgba(0, 0, 0, 0.04)',
color: !selectedCategory ? '#FF9500' : '#666',
border: !selectedCategory
? '1px solid rgba(255, 149, 0, 0.4)'
: '1px solid rgba(0, 0, 0, 0.1)',
cursor: 'pointer',
transition: 'all 0.15s ease',
'&:hover': {
bgcolor: !selectedCategory
? 'rgba(255, 149, 0, 0.18)'
: 'rgba(0, 0, 0, 0.08)',
},
'& .MuiChip-label': { px: 1.5 },
}}
/>
{/* Category chips */}
{categories.map((cat) => {
const isSelected = selectedCategory === cat.name;
return (
<Chip
key={cat.name}
label={
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
<span>{formatTagName(cat.name)}</span>
<Typography
component="span"
sx={{
fontSize: 11,
fontWeight: 600,
color: isSelected ? '#FF9500' : '#999',
opacity: 0.8,
}}
>
({cat.count})
</Typography>
</Box>
}
onClick={() => setSelectedCategory(isSelected ? null : cat.name)}
size="small"
sx={{
height: 28,
fontSize: 12,
fontWeight: isSelected ? 700 : 500,
bgcolor: isSelected
? 'rgba(255, 149, 0, 0.12)'
: 'rgba(0, 0, 0, 0.04)',
color: isSelected ? '#FF9500' : '#666',
border: isSelected
? '1px solid rgba(255, 149, 0, 0.4)'
: '1px solid rgba(0, 0, 0, 0.1)',
cursor: 'pointer',
transition: 'all 0.15s ease',
'&:hover': {
bgcolor: isSelected
? 'rgba(255, 149, 0, 0.18)'
: 'rgba(0, 0, 0, 0.08)',
},
'& .MuiChip-label': { px: 1.5 },
}}
/>
);
})}
</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}
onInstallClick={handleInstallClick}
isLiked={isSpaceLiked(app.id)}
onToggleLike={handleToggleLike}
isLoggedIn={isLoggedIn}
matchData={matchDataMap?.get(app.id) || null}
/>
))}
</Box>
)}
</Container>
{/* Install Modal */}
<InstallModal
open={installModalOpen}
onClose={handleCloseInstallModal}
app={selectedApp}
/>
</Layout>
);
}
|