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: User Profile image #4

Merged
merged 1 commit into from
Dec 1, 2023
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
18 changes: 15 additions & 3 deletions src/learning-header/AuthenticatedUserDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faUserCircle } from '@fortawesome/free-solid-svg-icons';
import { getConfig } from '@edx/frontend-platform';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { Dropdown } from '@edx/paragon';
import { Dropdown, Image } from '@edx/paragon';
import {
ProfileIcon, LogoutIcon, AccountIcon, DashboardIcon,
} from '../Icons';

import messages from './messages';

const AuthenticatedUserDropdown = ({ intl, username }) => {
const AuthenticatedUserDropdown = ({ intl, username, userProfileImage }) => {
const dashboardMenuItem = (
<Dropdown.Item href={`${getConfig().LMS_BASE_URL}/dashboard`}>
<span className="drop-icon"><DashboardIcon className="text-primary" /></span>
Expand All @@ -25,7 +25,14 @@ const AuthenticatedUserDropdown = ({ intl, username }) => {
{/* <a className="text-gray-700" href={}>{intl.formatMessage(messages.help)}</a> */}
<Dropdown className="user-dropdown ml-3">
<Dropdown.Toggle variant="none" className="user-dropdown-toggle">
<FontAwesomeIcon icon={faUserCircle} className="d-md-none" size="lg" />
<FontAwesomeIcon icon={faUserCircle} className="d-none" size="lg" />
{
userProfileImage && (
<div className="user-profile mr-3">
<Image src={userProfileImage} fluid alt={username} />
</div>
)
}
<span data-hj-suppress className="d-none d-md-inline">
{username}
</span>
Expand Down Expand Up @@ -57,7 +64,12 @@ const AuthenticatedUserDropdown = ({ intl, username }) => {

AuthenticatedUserDropdown.propTypes = {
intl: intlShape.isRequired,
userProfileImage: PropTypes.string,
username: PropTypes.string.isRequired,
};

AuthenticatedUserDropdown.defaultProps = {
userProfileImage: null,
};

export default injectIntl(AuthenticatedUserDropdown);
5 changes: 4 additions & 1 deletion src/learning-header/LearningHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ LinkedLogo.propTypes = {
};

const LearningHeader = ({
courseOrg, courseNumber, courseTitle, intl, showUserDropdown,
courseOrg, courseNumber, courseTitle, intl, showUserDropdown, userProfileImage,
}) => {
const { authenticatedUser } = useContext(AppContext);

Expand All @@ -50,6 +50,7 @@ const LearningHeader = ({
</div>
{showUserDropdown && authenticatedUser && (
<AuthenticatedUserDropdown
userProfileImage={userProfileImage}
username={authenticatedUser.username}
/>
)}
Expand All @@ -65,6 +66,7 @@ LearningHeader.propTypes = {
courseOrg: PropTypes.string,
courseNumber: PropTypes.string,
courseTitle: PropTypes.string,
userProfileImage: PropTypes.string,
intl: intlShape.isRequired,
showUserDropdown: PropTypes.bool,
};
Expand All @@ -73,6 +75,7 @@ LearningHeader.defaultProps = {
courseOrg: null,
courseNumber: null,
courseTitle: null,
userProfileImage: null,
showUserDropdown: true,
};

Expand Down