Skip to content

Commit

Permalink
fix CollectionPoster
Browse files Browse the repository at this point in the history
  • Loading branch information
fishshi committed Dec 16, 2024
1 parent 4687394 commit 5e6e79d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 30 deletions.
59 changes: 31 additions & 28 deletions src/renderer/src/components/Showcase/posters/CollectionPoster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,26 @@ export function CollectionPoster({
const gameId = collections[collctionId].games[0]
const length = collections[collctionId].games.length
return (
<div
className={cn(
'group relative overflow-hidden shadow-custom-initial cursor-pointer w-[160px] h-[160px] rounded-[0.3rem]',
'transition-border duration-300 ease-in-out',
'border-2 border-transparent',
'hover:border-primary hover:border-2',
'3xl:w-[190px] 3xl:h-[190px]'
)}
onClick={() => navigate(`/library/collections/${collctionId}`)}
>
{/* background mask layer */}
<CollectionCM collectionId={collctionId}>
<div
className={cn(
'absolute inset-0 bg-muted/40 backdrop-blur-sm z-10 border-t-0.5 border-white/30 pointer-events-none'
'group relative overflow-hidden shadow-custom-initial cursor-pointer w-[160px] h-[160px] rounded-[0.3rem]',
'transition-border duration-300 ease-in-out',
'border-2 border-transparent',
'hover:border-primary hover:border-2',
'3xl:w-[190px] 3xl:h-[190px]'
)}
/>
onClick={() => navigate(`/library/collections/${collctionId}`)}
>
{/* background mask layer */}
<div
className={cn(
'absolute inset-0 bg-muted/40 backdrop-blur-sm z-10 border-t-0.5 border-white/30 pointer-events-none'
)}
/>

{/* HoverBigCardAnimation layer */}

{/* HoverBigCardAnimation layer */}
<CollectionCM collectionId={collctionId}>
<div className="relative z-0">
<HoverSquareCardAnimation className={cn('rounded-none')}>
<GameImage
Expand All @@ -60,21 +61,23 @@ export function CollectionPoster({
/>
</HoverSquareCardAnimation>
</div>
</CollectionCM>

{/* text content layer */}
<div
className={cn(
'absolute inset-0 z-20 mt-7',
'flex items-center justify-center',
'pointer-events-none'
)}
>
<div className="flex flex-col gap-1 items-center justify-center">
<div className={cn('text-accent-foreground text-lg font-semibold')}>{collectionName}</div>
<div className={cn('text-accent-foreground/70')}>{`( ${length} )`}</div>
{/* text content layer */}
<div
className={cn(
'absolute inset-0 z-20 mt-7',
'flex items-center justify-center',
'pointer-events-none'
)}
>
<div className="flex flex-col gap-1 items-center justify-center">
<div className={cn('text-accent-foreground text-lg font-semibold')}>
{collectionName}
</div>
<div className={cn('text-accent-foreground/70')}>{`( ${length} )`}</div>
</div>
</div>
</div>
</div>
</CollectionCM>
)
}
18 changes: 16 additions & 2 deletions src/renderer/src/components/contextMenu/CollectionCM/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '@ui/alert-dialog'
import { useCollections } from '~/hooks'
import { cn } from '~/utils'
import { useState } from 'react'
import { useEffect, useState } from 'react'

export function CollectionCM({
collectionId,
Expand All @@ -33,6 +33,13 @@ export function CollectionCM({
const { renameCollection, removeCollection, collections } = useCollections()
const [newName, setNewName] = useState<string>('')
const [isOpen, setIsOpen] = useState<boolean>(false)

useEffect(() => {
if (collections[collectionId].name !== newName) {
setNewName(collections[collectionId].name)
}
}, [collections[collectionId].name])

return (
<ContextMenu>
<ContextMenuTrigger>{children}</ContextMenuTrigger>
Expand All @@ -59,12 +66,19 @@ export function CollectionCM({
<Button
onClick={() => {
renameCollection(collectionId, newName)
setNewName('')
setIsOpen(false)
}}
>
确定
</Button>
<Button
onClick={() => {
setIsOpen(false)
setNewName(collections[collectionId].name)
}}
>
取消
</Button>
</DialogContent>
</Dialog>
<ContextMenuSeparator />
Expand Down

0 comments on commit 5e6e79d

Please sign in to comment.