From c24af09afb8cf972cfc0af2ab56dbd55020c4876 Mon Sep 17 00:00:00 2001 From: eemaanamir Date: Thu, 21 Nov 2024 13:43:06 +0500 Subject: [PATCH] fix: fixed reponsiveness issues on mobile view --- src/profile-v2/CertificateCard.jsx | 53 +++++++++++--- src/profile-v2/Certificates.jsx | 98 +++++++++++++++----------- src/profile-v2/ProfilePage.jsx | 69 +++++++++++++++--- src/profile-v2/UsernameDescription.jsx | 33 +++++---- src/profile-v2/index.scss | 3 + 5 files changed, 186 insertions(+), 70 deletions(-) diff --git a/src/profile-v2/CertificateCard.jsx b/src/profile-v2/CertificateCard.jsx index bbdb55f6b..53005ea17 100644 --- a/src/profile-v2/CertificateCard.jsx +++ b/src/profile-v2/CertificateCard.jsx @@ -1,9 +1,10 @@ import React from 'react'; import PropTypes from 'prop-types'; import { FormattedDate, FormattedMessage, useIntl } from '@edx/frontend-platform/i18n'; -import { Hyperlink } from '@openedx/paragon'; +import { breakpoints, Hyperlink, useWindowSize } from '@openedx/paragon'; import get from 'lodash.get'; +import classNames from 'classnames'; import professionalCertificateSVG from './assets/professional-certificate.svg'; import verifiedCertificateSVG from './assets/verified-certificate.svg'; import messages from './Certificates.messages'; @@ -27,6 +28,8 @@ const CertificateCard = ({ audit: null, }[certificateType] || null; + const isMobileView = useWindowSize().width <= breakpoints.small.minWidth; + return (
-
+
-

+

{intl.formatMessage(get( messages, `profile.certificates.types.${certificateType}`, messages['profile.certificates.types.unknown'], ))}

-

{courseDisplayName}

-

+

+ {courseDisplayName} +

+

{courseOrganization}
-

+

{intl.formatMessage(messages['profile.certificates.view.certificate'])}

-

+

( -

-
-
-

- -

+const Certificates = ({ certificates }) => { + const isMobileView = useWindowSize().width <= breakpoints.small.minWidth; + const isTabletView = useWindowSize().width <= breakpoints.medium.minWidth; + return ( +
+
+
+

+ +

+
+
+

+ +

+
-
-

+ {certificates?.length > 0 ? ( +

+
+ {certificates.map(certificate => ( + + ))} +
+
+ ) : ( +
-

-
-
- {certificates?.length > 0 ? ( -
-
- {certificates.map(certificate => ( - - ))}
-
- ) : ( -
- -
- )} -
-); + )} +
+ ); +}; Certificates.propTypes = { certificates: PropTypes.arrayOf(PropTypes.shape({ diff --git a/src/profile-v2/ProfilePage.jsx b/src/profile-v2/ProfilePage.jsx index 22bcf7179..c853ae30a 100644 --- a/src/profile-v2/ProfilePage.jsx +++ b/src/profile-v2/ProfilePage.jsx @@ -7,7 +7,13 @@ import { sendTrackingLogEvent } from '@edx/frontend-platform/analytics'; import { ensureConfig, getConfig } from '@edx/frontend-platform'; import { AppContext } from '@edx/frontend-platform/react'; import { useIntl } from '@edx/frontend-platform/i18n'; -import { Alert, Hyperlink } from '@openedx/paragon'; +import { + Alert, + Hyperlink, + breakpoints, + useWindowSize, +} from '@openedx/paragon'; +import classNames from 'classnames'; import { fetchProfile, saveProfilePhoto, @@ -42,6 +48,8 @@ const ProfilePage = ({ params }) => { } = useSelector(profilePageSelector); const [viewMyRecordsUrl, setViewMyRecordsUrl] = useState(null); + const isMobileView = useWindowSize().width <= breakpoints.small.minWidth; + const isTabletView = useWindowSize().width <= breakpoints.medium.minWidth; useEffect(() => { const { CREDENTIALS_BASE_URL } = context.config; @@ -81,7 +89,10 @@ const ProfilePage = ({ params }) => { return ( { ) : ( <> -
+
-
+
{ savePhotoState={savePhotoState} isEditable={isAuthenticatedUserProfile() && !requiresParentalConsent} /> -
-

{params.username}

+
+

+ {params.username} +

{isBlockVisible(name) && ( -

{name}

+

+ {name} +

+ )} +
+ >
-
+
{renderViewMyRecordsButton()}
diff --git a/src/profile-v2/UsernameDescription.jsx b/src/profile-v2/UsernameDescription.jsx index bbbd70333..d807903bc 100644 --- a/src/profile-v2/UsernameDescription.jsx +++ b/src/profile-v2/UsernameDescription.jsx @@ -1,18 +1,27 @@ import React from 'react'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; import { getConfig } from '@edx/frontend-platform'; +import classNames from 'classnames'; +import { breakpoints, useWindowSize } from '@openedx/paragon'; -const UsernameDescription = () => ( -

- -

-); +const UsernameDescription = () => { + const isMobileView = useWindowSize().width <= breakpoints.small.minWidth; + return ( +

+ +

+ ); +}; export default UsernameDescription; diff --git a/src/profile-v2/index.scss b/src/profile-v2/index.scss index 32762c523..0538ccfcd 100644 --- a/src/profile-v2/index.scss +++ b/src/profile-v2/index.scss @@ -151,6 +151,9 @@ max-width: 32em; } +.max-width-19rem{ + max-width: 19rem; +} .width-75rem { width: 75rem; }