Skip to content

Commit

Permalink
[feat] 💄 prettier & linter (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
dappsar committed Nov 1, 2024
1 parent 45b020c commit 0792e87
Showing 1 changed file with 33 additions and 25 deletions.
58 changes: 33 additions & 25 deletions src/sections/nfts/nft-item-share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ import Image from 'next/image'
import { useState } from 'react'
import { m } from 'framer-motion'
import { Icon } from '@iconify/react'
import { useSnackbar } from 'notistack'

import { Box, Stack } from '@mui/system'
import { Card, Button, Dialog, Typography, IconButton, DialogTitle, DialogContent, DialogActions } from '@mui/material'
import {
Card,
Button,
Dialog,
IconButton,
Typography,
DialogTitle,
DialogActions,
DialogContent
} from '@mui/material'

import { useResponsive } from 'src/hooks/use-responsive'

Expand Down Expand Up @@ -36,12 +46,12 @@ export default function NftItemShare({ nftId, nftData }: NftItemClaimProps) {
const handleShare = (platform: string) => {
const nftUrl = `${NFT_MARKETPLACE_URL}/${nftId}`
const text = nftData.metadata.description

const shareUrls = {
twitter: `https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}&url=${encodeURIComponent(nftUrl)}`,
facebook: `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(nftUrl)}`,
whatsapp: `https://wa.me/?text=${encodeURIComponent(`${text} ${nftUrl}`)}`,
linkedin: `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(nftUrl)}`,
linkedin: `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(nftUrl)}`
} as const

window.open(shareUrls[platform as keyof typeof shareUrls], '_blank')
Expand Down Expand Up @@ -81,7 +91,7 @@ export default function NftItemShare({ nftId, nftData }: NftItemClaimProps) {
{ icon: 'ri:whatsapp-fill', name: 'WhatsApp', action: () => handleShare('whatsapp') },
{ icon: 'ri:linkedin-box-fill', name: 'LinkedIn', action: () => handleShare('linkedin') },
{ icon: 'ri:facebook-circle-fill', name: 'Facebook', action: () => handleShare('facebook') },
{ icon: 'ri:links-fill', name: 'Copiar Link', action: handleCopyLink },
{ icon: 'ri:links-fill', name: 'Copiar Link', action: handleCopyLink }
]

return (
Expand All @@ -98,7 +108,7 @@ export default function NftItemShare({ nftId, nftData }: NftItemClaimProps) {
mb: mdUp ? 0 : 5
}}
>
{nftData.metadata.description}
{nftData.metadata.description}
</Typography>
</m.div>
<Box
Expand Down Expand Up @@ -126,21 +136,21 @@ export default function NftItemShare({ nftId, nftData }: NftItemClaimProps) {
alt={nftData.metadata.description}
/>
</Box>

{/* Botones flotantes */}
<Box sx={{ position: 'absolute', top: 10, right: 10, display: 'flex', gap: 1 }}>
<m.div variants={varFade().in}>
<IconButton
onClick={() => setOpenShare(true)}
sx={{
sx={{
backgroundColor: 'white',
'&:hover': { backgroundColor: 'rgba(255,255,255,0.9)' }
}}
>
<Icon icon="ri:share-fill" width={24} />
<Icon icon='ri:share-fill' width={24} />
</IconButton>
</m.div>

<m.button
initial={{ scale: 1 }}
whileHover={{ scale: 1.1, cursor: 'pointer' }}
Expand All @@ -150,7 +160,7 @@ export default function NftItemShare({ nftId, nftData }: NftItemClaimProps) {
backgroundColor: 'white',
border: 'none',
borderRadius: '50%',
padding: '8px',
padding: '8px'
}}
>
<Image
Expand All @@ -165,31 +175,29 @@ export default function NftItemShare({ nftId, nftData }: NftItemClaimProps) {

<m.div variants={varFade().inUp}>
<Button size='large' color='inherit' variant='contained' onClick={handleTriggerShare}>
<Icon icon="ri:share-fill" width={20} style={{ marginRight: 8 }} /> {t('nfts.share.cta')}
<Icon icon='ri:share-fill' width={20} style={{ marginRight: 8 }} />{' '}
{t('nfts.share.cta')}
</Button>
</m.div>
</Box>

{/* Diálogo de compartir */}
<Dialog
open={openShare}
onClose={handleTriggerShare}
maxWidth="xs"
fullWidth
>
<Dialog open={openShare} onClose={handleTriggerShare} maxWidth='xs' fullWidth>
<DialogTitle>{t('nfts.share.cta')}</DialogTitle>
<DialogContent>
<Box sx={{
display: 'grid',
gridTemplateColumns: 'repeat(2, 1fr)',
gap: 2,
pt: 2
}}>
<Box
sx={{
display: 'grid',
gridTemplateColumns: 'repeat(2, 1fr)',
gap: 2,
pt: 2
}}
>
{socialButtons.map((button) => (
<Button
key={button.name}
onClick={button.action}
variant="outlined"
variant='outlined'
startIcon={<Icon icon={button.icon} />}
fullWidth
sx={{ justifyContent: 'flex-start' }}
Expand All @@ -207,4 +215,4 @@ export default function NftItemShare({ nftId, nftData }: NftItemClaimProps) {
</Dialog>
</Stack>
)
}
}

0 comments on commit 0792e87

Please sign in to comment.