1
- import { Badge , Button , createStyles , Paper , Title } from '@mantine/core' ;
2
- import { IconExternalLink } from '@tabler/icons' ;
1
+ import { ActionIcon , Badge , Button , Code , createStyles , Paper , Text , Title } from '@mantine/core' ;
2
+ import { openConfirmModal } from '@mantine/modals' ;
3
+ import { IconExternalLink , IconX } from '@tabler/icons' ;
3
4
4
- const useStyles = createStyles ( ( theme ) => ( {
5
+ const useStyles = createStyles ( ( theme , _params , getRef ) => ( {
5
6
card : {
7
+ position : 'relative' ,
6
8
height : 350 ,
7
9
width : 210 ,
8
10
display : 'flex' ,
@@ -18,8 +20,17 @@ const useStyles = createStyles((theme) => ({
18
20
transform : 'scale(1.01)' ,
19
21
boxShadow : theme . shadows . md ,
20
22
} ,
23
+ [ `&:hover .${ getRef ( 'removeButton' ) } ` ] : {
24
+ display : 'flex' ,
25
+ } ,
26
+ } ,
27
+ removeButton : {
28
+ ref : getRef ( 'removeButton' ) ,
29
+ position : 'absolute' ,
30
+ right : - 5 ,
31
+ top : - 5 ,
32
+ display : 'none' ,
21
33
} ,
22
-
23
34
title : {
24
35
fontFamily : `${ theme . fontFamily } ` ,
25
36
fontWeight : 900 ,
@@ -37,10 +48,34 @@ interface ArticleCardImageProps {
37
48
image : string ;
38
49
title : string ;
39
50
category ?: string ;
51
+ onRemove : ( ) => void ;
40
52
}
41
53
42
- export function MangaCard ( { image, title, category } : ArticleCardImageProps ) {
54
+ const createRemoveModal = ( title : string , onRemove : ( ) => void ) => {
55
+ const openDeleteModal = ( ) =>
56
+ openConfirmModal ( {
57
+ title : `Delete ${ title } ?` ,
58
+ centered : true ,
59
+ children : (
60
+ < Text size = "sm" >
61
+ Are you sure you want to delete
62
+ < Code className = "text-base font-bold" color = "red" >
63
+ { title }
64
+ </ Code >
65
+ ? This action is destructive and all downloaded files will be removed
66
+ </ Text >
67
+ ) ,
68
+ labels : { confirm : 'Delete' , cancel : 'Cancel' } ,
69
+ confirmProps : { color : 'red' } ,
70
+ onConfirm : onRemove ,
71
+ } ) ;
72
+
73
+ return openDeleteModal ;
74
+ } ;
75
+
76
+ export function MangaCard ( { image, title, category, onRemove } : ArticleCardImageProps ) {
43
77
const { classes } = useStyles ( ) ;
78
+ const removeModal = createRemoveModal ( title , onRemove ) ;
44
79
45
80
return (
46
81
< Paper
@@ -50,6 +85,9 @@ export function MangaCard({ image, title, category }: ArticleCardImageProps) {
50
85
sx = { { backgroundImage : `linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.5)), url(${ image } )` } }
51
86
className = { classes . card }
52
87
>
88
+ < ActionIcon color = "red" variant = "filled" radius = "xl" className = { classes . removeButton } onClick = { removeModal } >
89
+ < IconX size = { 16 } />
90
+ </ ActionIcon >
53
91
< div >
54
92
{ category && (
55
93
< Badge color = "teal" variant = "filled" className = { classes . category } size = "md" >
0 commit comments