-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add qr share link to share an item (#797)
* feat: add qr share link to share an item * feat: use dialog instead of modal for qr code * ci: cypress workflow * test: add a test for sharing item with qr code * fix: id btn for qr share
- Loading branch information
Showing
9 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useState } from 'react'; | ||
import QR from 'react-qr-code'; | ||
|
||
import { QrCode2 } from '@mui/icons-material'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
import { Box, Dialog, DialogContent, IconButton, Tooltip } from '@mui/material'; | ||
|
||
import { useBuilderTranslation } from '@/config/i18n'; | ||
import { | ||
SHARE_ITEM_QR_BTN_ID, | ||
SHARE_ITEM_QR_DIALOG_ID, | ||
} from '@/config/selectors'; | ||
import { BUILDER } from '@/langs/constants'; | ||
|
||
type Props = { | ||
value: string; | ||
}; | ||
|
||
const QRCode = ({ value }: Props): JSX.Element => { | ||
const { t: translateBuilder } = useBuilderTranslation(); | ||
const [openQrModal, setOpenQrModal] = useState<boolean>(false); | ||
|
||
return ( | ||
<> | ||
<Tooltip title={translateBuilder(BUILDER.SHARE_ITEM_LINK_QR_CODE)}> | ||
<IconButton | ||
onClick={() => setOpenQrModal(true)} | ||
id={SHARE_ITEM_QR_BTN_ID} | ||
> | ||
<QrCode2 /> | ||
</IconButton> | ||
</Tooltip> | ||
<Dialog | ||
open={openQrModal} | ||
onClose={() => setOpenQrModal(false)} | ||
id={SHARE_ITEM_QR_DIALOG_ID} | ||
> | ||
<IconButton | ||
aria-label="close" | ||
onClick={() => setOpenQrModal(false)} | ||
sx={{ | ||
position: 'absolute', | ||
right: 8, | ||
top: 8, | ||
}} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
<DialogContent sx={{ p: 5 }}> | ||
<Box width={{ xs: '60vw', sm: '50vw', md: '30vw', lg: '24vw' }}> | ||
<QR | ||
style={{ height: 'auto', maxWidth: '100%', width: '100%' }} | ||
value={value} | ||
/> | ||
</Box> | ||
</DialogContent> | ||
</Dialog> | ||
</> | ||
); | ||
}; | ||
|
||
export default QRCode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters