Skip to content

Commit

Permalink
feat: create login form
Browse files Browse the repository at this point in the history
Description:
Create login form using paragon form fields
VAN-1882
  • Loading branch information
ahtesham-quraish committed Apr 2, 2024
1 parent c7a2ba0 commit 0b01a2e
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/authn-component/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import PropTypes from 'prop-types';

import BaseContainer from '../base-container';
import { LoginForm } from '../forms';

/**
* Main component that holds the logic for conditionally rendering login or registration form.
Expand All @@ -17,7 +18,7 @@ const AuthnComponent = ({
open, setOpen,
}) => (
<BaseContainer open={open} setOpen={setOpen}>
<div>Login form</div>
<LoginForm />
</BaseContainer>
);

Expand Down
4 changes: 4 additions & 0 deletions src/forms/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// TODO: This will be removed when register form will be exported
/* eslint-disable import/prefer-default-export */

export { default as LoginForm } from './login';
67 changes: 67 additions & 0 deletions src/forms/login/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React from 'react';

import { useIntl } from '@edx/frontend-platform/i18n';
import {
Button, Container, Form, Hyperlink,
} from '@openedx/paragon';

import messages from './messages';
import SocialAuthButtons from '../../common-ui/SocialAuthButtons';

import './index.scss';

/**
* Login form component that holds the login form functionality.
*
* @returns {JSX.Element} The rendered login component along with social auth buttons.
*/

const LoginForm = () => {
const { formatMessage } = useIntl();

return (
<Container size="lg" className="w-100 h-100 overflow-auto form-layout">
<h1 className="display-1 font-italic text-center mb-4">{formatMessage(messages.loginFormHeadingText)}</h1>
<SocialAuthButtons />
<div className="text-center mb-4.5 mt-4.5">
{formatMessage(messages.loginFormOrTxt)}
</div>
<Form>
<Form.Row className="mb-4">
<Form.Group controlId="email" className="w-100 m-0">
<Form.Control
type="email"
floatingLabel={formatMessage(messages.loginFormEmailText)}
/>
</Form.Group>
</Form.Row>
<Form.Row className="mb-3">
<Form.Group controlId="password" className="w-100 m-0">
<Form.Control
type="password"
floatingLabel={formatMessage(messages.loginFormPasswordText)}
/>
</Form.Group>
</Form.Row>
<Form.Row>
<Hyperlink className="hyper-link">
{formatMessage(messages.loginFormForgotPasswordButtonText)}
</Hyperlink>
</Form.Row>
<Form.Row className="mt-6 mb-4.5">
<Button className="w-100" variant="primary">{formatMessage(messages.loginFormSignInButtonText)}</Button>
</Form.Row>
<Form.Row>
<span>
{formatMessage(messages.loginFormSignUpHelpingText)}&nbsp;
</span>
<Hyperlink className="hyper-link">
{formatMessage(messages.loginFormSignUpLink)}
</Hyperlink>
</Form.Row>
</Form>
</Container>
);
};

export default LoginForm;
12 changes: 12 additions & 0 deletions src/forms/login/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.form-layout {
padding: 3.5rem 2.5rem 3.5rem 2.5rem;
}

.hyper-link {
cursor: pointer;
}

.pgn__form-control-floating-label-text:after {
content:"*";
color: #AB0D02;
}
46 changes: 46 additions & 0 deletions src/forms/login/messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { defineMessages } from '@edx/frontend-platform/i18n';

const messages = defineMessages({
loginFormHeadingText: {
id: 'login.form.heading.text',
defaultMessage: 'Login',
description: 'Text of heading',
},
loginFormSignInButtonText: {
id: 'login.form.signin.button.text',
defaultMessage: 'Sign in',
description: 'Text of sign in button',
},
loginFormForgotPasswordButtonText: {
id: 'login.form.forgot.password.button.text',
defaultMessage: 'Forgot Password?',
description: 'Button text for forgot password',
},
loginFormSignUpHelpingText: {
id: 'login.form.sign.up.helping.text',
defaultMessage: 'Don’t have an account yet?',
description: 'Description of sign up link helping text',
},
loginFormSignUpLink: {
id: 'login.form.sign.up.link.text',
defaultMessage: 'Create an account',
description: 'Description of sign up link',
},
loginFormEmailText: {
id: 'login.form.email.field.text',
defaultMessage: 'Email',
description: 'Email field label',
},
loginFormPasswordText: {
id: 'login.form.password.field.text',
defaultMessage: 'Password',
description: 'Password field label',
},
loginFormOrTxt: {
id: 'login.form.or.message',
defaultMessage: 'or',
description: 'Text of or',
},
});

export default messages;

0 comments on commit 0b01a2e

Please sign in to comment.