import { useEffect, useRef, useState } from 'react'; import { Swiper, SwiperSlide } from 'swiper/react'; import Header from '../components/store/header'; import browser from 'webextension-polyfill'; import { Autoplay } from 'swiper/modules'; import { motion } from 'framer-motion'; import 'swiper/css'; import 'swiper/css/pagination'; import 'swiper/css/scrollbar'; import 'swiper/css/autoplay'; export type Theme = { name: string; description: string; coverImage: string; marqueeImage: string; id: string; } type ThemesResponse = { themes: Theme[]; } const Store = () => { const [searchTerm, setSearchTerm] = useState(''); const swiperCover = useRef(null); const [gridThemes, setGridThemes] = useState([]); const [filteredThemes, setFilteredThemes] = useState([]); const [coverThemes, setCoverThemes] = useState([]); useEffect(() => { fetch('https://raw.githubusercontent.com/BetterSEQTA/BetterSEQTA-Themes/main/store/themes.json', { cache: 'no-store' }) .then(response => response.json()) .then((data: ThemesResponse) => { setGridThemes(data.themes); // Select up to 3 random themes to display in coverThemes const shuffled = [...data.themes].sort(() => 0.5 - Math.random()); setCoverThemes(shuffled.slice(0, 3)); }) .catch(error => console.error('Failed to fetch themes', error)); }, []); useEffect(() => { setFilteredThemes(gridThemes.filter(theme => theme.name.toLowerCase().includes(searchTerm.toLowerCase()) || theme.description.toLowerCase().includes(searchTerm.toLowerCase()) )); }, [searchTerm, gridThemes]); const downloadTheme = (id: string) => { const themeContent = gridThemes.find(theme => theme.id === id); if (!themeContent) { alert('There was an error, The theme was not found!') return }; browser.runtime.sendMessage({ type: 'StoreDownloadTheme', body: { themeContent } }); }; return (
{ coverThemes.map((theme, index) => ( Theme Preview

{theme.name}

{theme.description}

{/* shadow from the bottom of the image */}
)) } {/* pagination */}
{filteredThemes.map((theme, index) => (
{theme.name}

{theme.description}

Theme Preview
))}
{filteredThemes.length == 0 && (

That doesnt exist! 😭😭😭

Sorry, we couldn’t find the theme you’re looking for. Maybe... you could create it?

)}
); }; export default Store;