Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratham271 committed Aug 16, 2023
1 parent e244a6e commit eb009a3
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 16 deletions.
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"tailwindcss": "^3.3.3"
}
}
19 changes: 3 additions & 16 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
import logo from './logo.svg';
import './App.css';
import QrFrontend from './components/QrFrontend';

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<div >
<QrFrontend/>
</div>
);
}
Expand Down
74 changes: 74 additions & 0 deletions src/components/QrFrontend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React, { useState } from 'react';

const QrFrontend = () => {
const [showText, setShowText] = useState(false);
const [qrImage, setQrImage] = useState('');
const [inputText, setInputText] = useState('');

const generateQR = async () => {
try {
const response = await fetch('http://143.110.177.177:5000/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ inputtext: inputText }),
});

if (response.ok) {
const data = await response.json();
setQrImage(data.qr_image);
setShowText(true);
} else {
console.error('Failed to generate QR code');
}
} catch (error) {
console.error('Error:', error);
}
};

return (
<>
<div className='p-4 md:p-6 flex flex-col gap-2 justify-center items-center'>
<h1 className='text-xl md:text-2xl mt-2'>QR Code Generator 🔥</h1>
<h2 className='text-sm font-medium md:font-normal md:text-xl mt-2'>
Insert a link below to generate a QR Code
</h2>
</div>
<form
className='p-4 md:p-6 flex flex-col md:flex-row justify-center items-center gap-2'
onSubmit={(e) => {
e.preventDefault();
generateQR();
}}
>
<input
type='text'
name='link'
className='text-white bg-black px-2 py-1 w-full md:w-2/6 h-9'
value={inputText}
onChange={(e) => setInputText(e.target.value)}
/>
<button
type='submit'
className='text-white bg-blue-600 border-none px-2 py-1 cursor-pointer rounded-md md:ml-2'
style={{ backgroundColor: 'rgb(41, 64, 121)' }}
>
Generate QR
</button>
</form>
<div className='p-4 md:p-6 flex flex-col justify-center items-center'>
{showText && (
<>
<img src={qrImage} alt='QR Code' />
<p className='text-sm md:text-lg'>
Here is the QR code we generated for you 🚀
</p>
</>
)}
</div>
</>
);
};

export default QrFrontend;
3 changes: 3 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
@tailwind base;
@tailwind components;
@tailwind utilities;
11 changes: 11 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}

0 comments on commit eb009a3

Please sign in to comment.