Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user can now upload logo from storage #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/components/Homepage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,25 @@ function Homepage() {
const [author, setauthor] = useState('');
const [logo, setlogo] = useState('');
const [template,settemplate]=useState('template4');
const [uploadLogo, setUploadLogo] = useState();
const componentRef = useRef();
const handlePrint = useReactToPrint({
content: () => componentRef.current,
});
const signout = () => {
firebase.auth().signOut();
}
const logoUploadRef = useRef();
const handleUploadLogoClick = (e) => {
logoUploadRef.current.click()
}
const handleUploadLogoChange = (e) => {
const file = e.target.files[0];
setUploadLogo(file)
setlogo(URL.createObjectURL(file))
e.target.value = null;
}

return (
<div className="main">
<Popup trigger={pop} setpop={setpop} >
Expand Down Expand Up @@ -179,7 +191,15 @@ function Homepage() {
</div>
<div className="input-box">
<span className="details">Logo URL</span>
<input type="text" placeholder="Enter logo URL" onChange={e => setlogo(e.target.value)} />
<div className='logo-inputs'>
<input type="text" placeholder={!uploadLogo?.name ? "Enter logo URL" : uploadLogo?.name} onChange={e => setlogo(e.target.value)} />
<div className='logo-upload-icon'>
<button onClick={handleUploadLogoClick}>
<ArrowUpwardIcon />
</button>
<input type='file' accept="image/png, image/gif, image/jpeg" hidden ref={logoUploadRef} onChange={handleUploadLogoChange}/>
</div>
</div>
</div>

{/* <button className="generate" onClick={handlePrint}>Generate Certificate</button> */}
Expand Down
20 changes: 20 additions & 0 deletions src/components/homepage.css
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,24 @@
.leftmost .templates img{
width: 100%;
height: 100%;
}
.logo-inputs{
display: flex;
}
.logo-inputs .logo-upload-icon{
padding: 6px 0 10px 10px;
}
.logo-inputs .logo-upload-icon button{
line-height: 1;
border-radius: 3px;
border: navajowhite;
font-weight: 700;
font-size: 14px;
padding: 10px 10px;
text-align: center;
color: rgb(255, 255, 255);
background-color: rgb(255, 108, 55) !important;
border-color: rgb(255, 108, 55) !important;
text-transform: uppercase;
cursor: pointer;
}