import { ActionIcon, Box, Button, Group, Overlay, Stack, Text } from '@mantine/core'; import { useState } from 'react'; import { FiEdit, FiShuffle, FiTrash, FiX } from 'react-icons/fi'; import { actionIconClasses } from 'styles'; function ThemeCard({ handleOpen, handleDeleteTheme, theme, allThemes, setTheme, cardTheme, currentTheme, setValue, createTheme, }: any) { const [hover, setHover] = useState(false); const [shift, setShift] = useState(0); return ( setHover(true)} onMouseLeave={() => setHover(false)} > {cardTheme.name} {currentTheme === 'random' && cardTheme.name === theme.name ? ( { setShift(2); }} onMouseLeave={() => { setShift(0); }} onClick={() => { setShift(0); }} gap={0} style={{ zIndex: 300, position: 'absolute', right: 0, top: 27 - shift, backgroundColor: shift === 0 ? 'white' : 'var(--color-background)', borderRadius: '50%', padding: '8px', margin: '4px', border: 'solid 2px', borderColor: shift === 0 ? 'black' : 'var(--color-text-pri)', transition: 'all 0.2s', }} > { const enabled = allThemes .filter((t: any) => t.randomEnabled) .filter((t: any) => t.name !== theme.name); if (enabled.length === 0) { setTheme(allThemes[0]); } else { const index = Math.floor(Math.random() * enabled.length); setTheme(enabled[index]); } }} style={{ fontSize: '2em', fontWeight: 'bold', color: shift === 0 ? 'black' : 'var(--color-text-pri)', }} /> ) : ( { createTheme({ method: 'PATCH', endpoint: 'api/themes', body: { ...cardTheme, randomEnabled: !cardTheme.randomEnabled }, }); }} > {cardTheme.randomEnabled ? : } handleOpen(cardTheme)} mb={2} > handleDeleteTheme(cardTheme)} > )} ); } export default ThemeCard;