Skip to content

Commit

Permalink
refactor: refactor the structure of base container
Browse files Browse the repository at this point in the history
Description:
Refactor the structure of base component
VAN-1840
  • Loading branch information
ahtesham-quraish committed Mar 27, 2024
1 parent 3953c76 commit b4473ba
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 96 deletions.
6 changes: 2 additions & 4 deletions example/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import { AppProvider } from '@edx/frontend-platform/react';
import { initialize, subscribe, APP_READY } from '@edx/frontend-platform';

import './index.scss';
import BaseContainer from '../src/base-container'
import AuthnComponent from '../src/authn-component'

subscribe(APP_READY, () => {
ReactDOM.render(
<AppProvider>
<BaseContainer open isPrivacyPolicy onClose={() => {}}>
<div>Login Form</div>
</BaseContainer>
<AuthnComponent open setOpen={() => {}}/>
</AppProvider>,
document.getElementById('root'),
);
Expand Down
43 changes: 43 additions & 0 deletions src/authn-component/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';

import { ModalDialog } from '@openedx/paragon';
import PropTypes from 'prop-types';

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

const AuthnComponent = ({
open, setOpen, footerContext,
}) => (
<ModalDialog
isOpen={open}
onClose={setOpen}
size="fullscreen"
variant="default"
className="bg-light-400"
hasCloseButton
>
<ModalDialog.Body className="modal-body-container overflow-hidden">
<BaseContainer>
<div>Login Form</div>
</BaseContainer>
</ModalDialog.Body>
{footerContext && (
<ModalDialog.Footer className="bg-dark-500 p-0">
<p className="p-4.5 mb-0 text-white">{footerContext}</p>
</ModalDialog.Footer>
)}
</ModalDialog>
);

AuthnComponent.defaultProps = {
footerContext: null,
};

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

export default AuthnComponent;
12 changes: 12 additions & 0 deletions src/authn-component/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@import "@edx/brand/paragon/variables";

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

.pgn__modal-close-container {
background: $light-400;
border-radius: 50%;
border: 2px solid $light-500;
}

15 changes: 0 additions & 15 deletions src/base-container/PrivacyPolicyFooter.jsx

This file was deleted.

42 changes: 10 additions & 32 deletions src/base-container/index.jsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,25 @@
import React from 'react';

import { ModalDialog } from '@openedx/paragon';
import PropTypes from 'prop-types';

import LargeLayout from './layout/LargeLayout';
import PrivacyPolicy from './PrivacyPolicyFooter';
import './index.scss';

const BaseContainer = ({
children, open, onClose, isPrivacyPolicy,
children,
}) => (
<ModalDialog
isOpen={open}
onClose={onClose}
size="fullscreen"
variant="default"
hasCloseButton
>
<ModalDialog.Body className="modal-body-container overflow-hidden">
<div className="modal-body-content-layout">
<div className="w-50 d-flex">
{children}
</div>
<LargeLayout>
<div className="w-100 h-100 bg-dark-500" />
</LargeLayout>
</div>
</ModalDialog.Body>
<ModalDialog.Footer className="modal-footer-content">
{isPrivacyPolicy && (<PrivacyPolicy />)}
</ModalDialog.Footer>
</ModalDialog>
);

BaseContainer.defaultProps = {
isPrivacyPolicy: false,
};
<div className="modal-body-content-layout">
<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>
);

BaseContainer.propTypes = {
children: PropTypes.node.isRequired,
open: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
isPrivacyPolicy: PropTypes.bool,
};

export default BaseContainer;
18 changes: 1 addition & 17 deletions src/base-container/index.scss
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
.modal-body-container .pgn__modal-body-content {
height: 100%;
}

.modal-body-container .modal-body-content-layout {
.modal-body-content-layout {
display: flex;
width: 100%;
height: 100%;
}

.pgn__modal-close-container {
background: white;
border-radius: 50%;
}

.modal-footer-content {
padding: 0 !important;
}

.privacy-policy-content {
margin-bottom: 0px;
}
15 changes: 0 additions & 15 deletions src/base-container/layout/LargeLayout.jsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/base-container/messages.js

This file was deleted.

0 comments on commit b4473ba

Please sign in to comment.