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

feat: create popup base layout for forms #1

Merged
merged 2 commits into from
Mar 28, 2024
Merged
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
29 changes: 29 additions & 0 deletions src/authn-component/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';

import PropTypes from 'prop-types';

import BaseContainer from '../base-container';

/**
* Main component that holds the logic for conditionally rendering login or registration form.
*
* @param {boolean} open - Required. Whether to open the modal window containing login or registration form.
* @param {function} setOpen - Required. Is used to toggle the modal window's open flag.
*
* @returns {JSX.Element} The rendered BaseContainer component containing either login or registration form.
*/

const AuthnComponent = ({
open, setOpen,
}) => (
<BaseContainer open={open} setOpen={setOpen}>
<div>Login form</div>
</BaseContainer>
);

AuthnComponent.propTypes = {
open: PropTypes.bool.isRequired,
setOpen: PropTypes.func.isRequired,
};

export default AuthnComponent;
60 changes: 60 additions & 0 deletions src/base-container/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';

import { ModalDialog } from '@openedx/paragon';
import PropTypes from 'prop-types';
ahtesham-quraish marked this conversation as resolved.
Show resolved Hide resolved

import './index.scss';

/**
* Base component for registration or login form modals.
*
* @param {boolean} open - Required. Whether to open the modal window.
* @param {function} setOpen - Required. Is used to toggle the modal window's open flag.
* @param {string} footerText - Optional. The text for the modal footer.
* @param {React.node} children - Required. The login or registration form.
*
* @returns {JSX.Element} The rendered login or registration form modal.
*/

const BaseContainer = ({
children, footerText, open, setOpen,
}) => (
<ModalDialog
isOpen={open}
onClose={setOpen}
size="fullscreen"
variant="default"
className="bg-light-400"
hasCloseButton
>
<ModalDialog.Body className="modal-body-container overflow-hidden">
<div className="d-flex w-100 h-100">
<div className="w-50 d-flex">
{children}
</div>
<div className="w-50 d-flex">
<div className="w-100 h-100 bg-dark-500" />
</div>
</div>
</ModalDialog.Body>
{footerText && (
<ModalDialog.Footer className="bg-dark-500 p-4.5">
<p className="mb-0 text-white">{footerText}</p>
</ModalDialog.Footer>
)}
</ModalDialog>

);

BaseContainer.propTypes = {
children: PropTypes.node.isRequired,
footerText: PropTypes.string,
open: PropTypes.bool.isRequired,
setOpen: PropTypes.func.isRequired,
};

BaseContainer.defaultProps = {
footerText: '',
};

export default BaseContainer;
18 changes: 18 additions & 0 deletions src/base-container/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@import "@edx/brand/paragon/variables";

.modal-body-container .pgn__modal-body-content {
height: 100%;
}

// This class is related to close button of modal
.pgn__modal-close-container {
background: $white;
border-radius: 50%;
border: 2px solid $light-500;
}

.pgn__modal-close-container .btn-icon__icon-container {
color: $light-700;
}


Loading