forked from reactplay/react-play
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Issue-369-Create-play-workflow' of github.com:reactplay…
…/react-play into Issue-369-Create-play-workflow
- Loading branch information
Showing
8 changed files
with
136 additions
and
2 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
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,55 @@ | ||
import { useState } from 'react'; | ||
import PlayHeader from 'common/playlists/PlayHeader'; | ||
import './styles.css'; | ||
import QRCode from "react-qr-code"; | ||
import * as htmlToImage from 'html-to-image'; | ||
import download from "downloadjs"; | ||
import { MdDonutLarge } from 'react-icons/md' | ||
|
||
function QrCodeGenerator(props) { | ||
|
||
// Your Code Start below. | ||
const [qrCodeValue, setQrCodeValue] = useState('https://reactplay.io') | ||
const [loading, setLoading] = useState(false) | ||
|
||
function handleChange(e) { | ||
setQrCodeValue(e.target.value) | ||
} | ||
|
||
function handleDownload() { | ||
setLoading(true) | ||
htmlToImage.toJpeg(document.querySelector("#qrContain"), { | ||
quality: 1 | ||
}).then((dataUrl) => { | ||
download(dataUrl, 'qrcode.jpeg') | ||
setLoading(false) | ||
}).catch((err) => { | ||
console.log(err) | ||
setLoading(false) | ||
}) | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="play-details"> | ||
<PlayHeader play={props} /> | ||
<div className="play-details-body"> | ||
{/* Your Code Starts Here */} | ||
<div className="App"> | ||
<div id="qrContain" style={{ backgroundColor: 'white', width: 'fit-content' }}> | ||
<QRCode size={256} value={(qrCodeValue === undefined || qrCodeValue === "") ? 'https://reactplay.io' : qrCodeValue} /> | ||
</div> | ||
<input id="qrValue" type={'text'} placeholder='Type something..' onChange={(e) => handleChange(e)} /> | ||
<button id="download-btn" onClick={handleDownload}> | ||
Download | ||
{loading ? <MdDonutLarge /> : ''} | ||
</button> | ||
</div> | ||
{/* Your Code Ends Here */} | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default QrCodeGenerator; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@ | ||
# QR Code Generator | ||
|
||
Generate as well as download QR codes on the go! | ||
|
||
## Play Demographic | ||
|
||
- Language: js | ||
- Level: Beginner | ||
|
||
## Creator Information | ||
|
||
- User: murtuzaalisurti | ||
- Gihub Link: [https://github.com/murtuzaalisurti](https://github.com/murtuzaalisurti) | ||
- Blog: null | ||
- Video: null | ||
|
||
## Implementation Details | ||
|
||
This QR code generator is implemented using `react-qr-code` library and the download functionality is also present! | ||
|
||
## Resources | ||
|
||
> Learn more about [react-qr-code](https://github.com/rosskhanas/react-qr-code) library on their [official documentation](https://github.com/rosskhanas/react-qr-code#readme)! |
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,44 @@ | ||
/* enter stlyes here */ | ||
.App { | ||
--react-play-theme: #00f2fe; | ||
--react-play-bg: #ffffffs; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 1rem; | ||
margin-top: 5rem; | ||
} | ||
|
||
#qrValue, | ||
#download-btn { | ||
border: 0.15rem solid var(--react-play-theme); | ||
padding: 0.5rem 1rem; | ||
background-color: var(--react-play-bg); | ||
outline: none; | ||
border-radius: 0.5rem; | ||
} | ||
|
||
#download-btn { | ||
border-color: #0103262c; | ||
background-color: var(--react-play-theme); | ||
cursor: pointer; | ||
display: flex; | ||
align-items: center; | ||
gap: 0.7rem; | ||
font-size: 1rem; | ||
} | ||
|
||
#download-btn svg { | ||
transform: rotate(0); | ||
animation: load 1s linear infinite; | ||
} | ||
|
||
@keyframes load { | ||
0% { | ||
transform: rotate(0); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} |