Skip to content

Instantly share code, notes, and snippets.

@ankh2054
Created April 18, 2020 13:54
Show Gist options
  • Save ankh2054/4996c172419075e9ca6992fd5dd830f0 to your computer and use it in GitHub Desktop.
Save ankh2054/4996c172419075e9ca6992fd5dd830f0 to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
import { Navbar, NavbarBrand, Nav, NavbarToggler, Collapse, NavItem, Jumbotron,
Button, Modal, ModalHeader, ModalBody,
Form, FormGroup, Input, Label } from 'reactstrap';
import { NavLink } from 'react-router-dom';
const Header = (props) => {
//Hooks
const [modal, setModal] = useState(false);
const [nav, setNav] = useState(true);
//Funtion that toggles the state to the opposite of what it is
const toggleModal = () => setModal(!modal);
const toggleNav = () => setNav(!nav);
//Login function
const handleLogin= (event) => {
//this.toggleModal();
alert("Username: " + this.username.value + " Password: " + this.password.value
+ " Remember: " + this.remember.checked);
event.preventDefault();
}
return(
<React.Fragment>
<Navbar dark expand="md">
<div className="container">
<NavbarToggler onClick={toggleNav} />
<NavbarBrand className="mr-auto" href="/"><img src='assets/images/logo.png' height="30" width="41" alt='Ristorante Con Fusion' /></NavbarBrand>
<Collapse isOpen={nav} navbar>
<Nav navbar>
<NavItem>
<NavLink className="nav-link" to='/home'><span className="fa fa-home fa-lg"></span> Home</NavLink>
</NavItem>
<NavItem>
<NavLink className="nav-link" to='/aboutus'><span className="fa fa-info fa-lg"></span> About Us</NavLink>
</NavItem>
<NavItem>
<NavLink className="nav-link" to='/menu'><span className="fa fa-list fa-lg"></span> Menu</NavLink>
</NavItem>
<NavItem>
<NavLink className="nav-link" to='/contactus'><span className="fa fa-address-card fa-lg"></span> Contact Us</NavLink>
</NavItem>
</Nav>
<Nav className="ml-auto" navbar>
<NavItem>
<Button outline onClick={toggleModal}><span className="fa fa-sign-in fa-lg"></span> Login</Button>
</NavItem>
</Nav>
</Collapse>
</div>
</Navbar>
<Jumbotron>
<div className="container">
<div className="row row-header">
<div className="col-12 col-sm-6">
<h1>Ristorante con Fusion</h1>
<p>We take inspiration from the World's best cuisines, and create a unique fusion experience. Our lipsmacking creations will tickle your culinary senses!</p>
</div>
</div>
</div>
</Jumbotron>
{/* isOpen - boolean to control the state of the popover
toggle - callback for toggling isOpen in the controlling component */}
<Modal isOpen={modal} toggle={toggleModal}>
<ModalHeader toggle={toggleModal}>Login</ModalHeader>
<ModalBody>
<Form onSubmit={handleLogin}>
<FormGroup>
<Label htmlFor="username">Username</Label>
<Input type="text" id="username" name="username"
Ref={(input) => this.username = input} />
</FormGroup>
<FormGroup>
<Label htmlFor="password">Password</Label>
<Input type="password" id="password" name="password"
Ref={(input) => this.password = input} />
</FormGroup>
<FormGroup check>
<Label check>
<Input type="checkbox" name="remember"
Ref={(input) => this.remember = input} />
Remember me
</Label>
</FormGroup>
<Button type="submit" value="submit" color="primary">Login</Button>
</Form>
</ModalBody>
</Modal>
</React.Fragment>
);
}
export default Header;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment