import type { MouseEvent } from 'react'; import React from 'react'; import type { UnstyledButtonProps } from '@mantine/core'; import { Group } from '@mantine/core'; import { RiPlayFill, RiMore2Fill, RiHeartFill, RiHeartLine } from 'react-icons/ri'; import styled from 'styled-components'; import { _Button } from '/@/renderer/components/button'; import { DropdownMenu } from '/@/renderer/components/dropdown-menu'; import type { LibraryItem, PlayQueueAddOptions } from '/@/renderer/types'; import { Play } from '/@/renderer/types'; import { useSettingsStore } from '/@/renderer/store/settings.store'; type PlayButtonType = UnstyledButtonProps & React.ComponentPropsWithoutRef<'button'>; const PlayButton = styled.button` display: flex; align-items: center; justify-content: center; width: 50px; height: 50px; background-color: rgb(255, 255, 255); border: none; border-radius: 50%; opacity: 0.8; transition: opacity 0.2s ease-in-out; transition: scale 0.2s linear; &:hover { opacity: 1; scale: 1.1; } &:active { opacity: 1; scale: 1; } svg { fill: rgb(0, 0, 0); stroke: rgb(0, 0, 0); } `; const SecondaryButton = styled(_Button)` opacity: 0.8; transition: opacity 0.2s ease-in-out; transition: scale 0.2s linear; &:hover { opacity: 1; scale: 1.1; } &:active { opacity: 1; scale: 1; } `; const GridCardControlsContainer = styled.div` display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; `; const ControlsRow = styled.div` width: 100%; height: calc(100% / 3); `; // const TopControls = styled(ControlsRow)` // display: flex; // align-items: flex-start; // justify-content: space-between; // padding: 0.5rem; // `; // const CenterControls = styled(ControlsRow)` // display: flex; // align-items: center; // justify-content: center; // padding: 0.5rem; // `; const BottomControls = styled(ControlsRow)` display: flex; align-items: flex-end; justify-content: space-between; padding: 1rem 0.5rem; `; const FavoriteWrapper = styled.span<{ isFavorite: boolean }>` svg { fill: ${(props) => props.isFavorite && 'var(--primary-color)'}; } `; const PLAY_TYPES = [ { label: 'Play', play: Play.NOW, }, { label: 'Add to queue (last)', play: Play.LAST, }, { label: 'Add to queue (next)', play: Play.NEXT, }, ]; export const GridCardControls = ({ itemData, itemType, handlePlayQueueAdd, }: { handlePlayQueueAdd?: (options: PlayQueueAddOptions) => void; itemData: any; itemType: LibraryItem; }) => { const playButtonBehavior = useSettingsStore((state) => state.player.playButtonBehavior); const handlePlay = async (e: MouseEvent, playType?: Play) => { e.preventDefault(); e.stopPropagation(); handlePlayQueueAdd?.({ byItemType: { id: [itemData.id], type: itemType, }, play: playType || playButtonBehavior, }); }; return ( {/* */} {/* */} {itemData?.isFavorite ? ( ) : ( )} { e.preventDefault(); e.stopPropagation(); }} > {PLAY_TYPES.filter((type) => type.play !== playButtonBehavior).map((type) => ( ) => handlePlay(e, type.play)} > {type.label} ))} Add to playlist Refresh metadata ); };