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

fix: login and register page responsive #201

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
name="description"
content="Web site created using create-react-app"
/>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous"
/>

Comment on lines +10 to +16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pankajsahu221 Why are you adding bootstrap 5 css link here? If you want to use bootstrap 5 then install it using npm and import it in the component.
Also see my below comment related to semantic-ui, I think we don't need to use react-bootstrap here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll fix that.

<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
Expand Down
152 changes: 71 additions & 81 deletions src/components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@ import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { postLogin } from '../actions/login';
import {
Form,
Grid,
Image,
Divider,
Icon,
Message,
Button,
} from 'semantic-ui-react';
import { Form, Image, Divider, Icon, Message, Button } from 'semantic-ui-react';
import { Container } from 'react-bootstrap';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have imported here { Container } from 'react-bootstrap' but react-bootstrap is not in package.json. It is not compiling locally.
Also container is present in semantic-ui: https://react.semantic-ui.com/elements/container/

Copy link
Author

@pankajsahu221 pankajsahu221 May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I haven't used semantic-ui, So let me see how responsive containers work in semantic-ui. @codesankalp can I use bootstrap classes to make containers responsive?

import PropTypes from 'prop-types';
import './../styles/Login.css';
import orgLogo from '../assets/org-logo.jpg';
Expand Down Expand Up @@ -112,80 +105,77 @@ class Login extends Component {
render() {
const { showPassword, error, submitted } = this.state;
return (
<>
<Grid>
<Grid.Row>
<Grid.Column width={5}>
<div className="login">
<span>
<b>Login</b>
</span>
<Divider />
<Form>
<Form.Input
name="username"
data-testid="input-username"
value={this.state.username}
onChange={this.onChange}
label="Username"
required
placeholder="Enter your username..."
<Container className="container d-flex align-items-center">
<Container
className="remo d-flex flex-xl-row flex-lg-row flex-md-row flex-column-reverse align-items-center justify-content-center justify-content-xl-around justify-content-lg-around w-100"
style={{ height: 'calc(100vh - 56px)' }}
>
<div className="login">
<span>
<b>Login</b>
</span>
<Divider />
<Form>
<Form.Input
name="username"
data-testid="input-username"
value={this.state.username}
onChange={this.onChange}
label="Username"
required
placeholder="Enter your username..."
/>
<Form.Input
data-testid="input-password"
type={showPassword ? 'text' : 'password'}
icon={
<Icon
name={showPassword ? 'eye slash outline' : 'eye'}
data-testid="hide-password"
onClick={this.handleShow}
link
/>
<Form.Input
data-testid="input-password"
type={showPassword ? 'text' : 'password'}
icon={
<Icon
name={showPassword ? 'eye slash outline' : 'eye'}
data-testid="hide-password"
onClick={this.handleShow}
link
/>
}
name="password"
value={this.state.password}
onChange={this.onChange}
label="Password"
required
placeholder="Enter your password..."
/>
<Button
data-testid="button-login"
fluid
primary
type="button"
onClick={this.submitLogin}
disabled={!this.state.username || !this.state.password}
>
LOG IN
</Button>
</Form>
}
name="password"
value={this.state.password}
onChange={this.onChange}
label="Password"
required
placeholder="Enter your password..."
/>
<Button
data-testid="button-login"
fluid
primary
type="button"
onClick={this.submitLogin}
disabled={!this.state.username || !this.state.password}
>
LOG IN
</Button>
</Form>

{/* form validation */}
{this.state.usernameerror ? (
<Message error content="Username cannot be empty!" />
) : null}
{this.state.passworderror ? (
<Message error content="Password cannot be empty!" />
) : null}
{error && submitted ? (
<Message error content={this.props.loginerror.detail} />
) : null}
<Divider />
<span>
Don't have an account? <Link to={register()}>Register here.</Link>
</span>
</div>

{/* form validation */}
{this.state.usernameerror ? (
<Message error content="Username cannot be empty!" />
) : null}
{this.state.passworderror ? (
<Message error content="Password cannot be empty!" />
) : null}
{error && submitted ? (
<Message error content={this.props.loginerror.detail} />
) : null}
<Divider />
<span>
Don't have an account?{' '}
<Link to={register()}>Register here.</Link>
</span>
</div>
</Grid.Column>
<Grid.Column width={10}>
<div className="logo">
<Image src={orgLogo} />
</div>
</Grid.Column>
</Grid.Row>
</Grid>
</>
<div className="logo">
<Image src={orgLogo} />
</div>
</Container>
</Container>
);
}
}
Expand Down
Loading