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

Fix the organization logo display and positioning #2

Merged
merged 1 commit into from
Mar 20, 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
2 changes: 1 addition & 1 deletion src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $white: #fff;
.user-dropdown {
.btn {
height: 3rem;
@media (max-width: -1 + map-get($grid-breakpoints, "sm")) {
@media (map-get($grid-breakpoints, "sm")) {
padding: 0 0.5rem;
}
}
Expand Down
29 changes: 18 additions & 11 deletions src/learning-header/LearningHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import AuthenticatedUserDropdown from './AuthenticatedUserDropdown';
import messages from './messages';
import getCourseLogoOrg from './data/api';

import './_header.scss';

function LinkedLogo({
href,
src,
Expand All @@ -28,6 +30,9 @@ LinkedLogo.propTypes = {
alt: PropTypes.string.isRequired,
};

// this feature flag is not included on the frontend-platform, we have to get it directly from ENV
const enabledOrgLogo = process.env.ENABLED_ORG_LOGO || false;

function LearningHeader({
courseOrg, courseTitle, intl, showUserDropdown,
}) {
Expand All @@ -54,17 +59,19 @@ function LearningHeader({
<a className="sr-only sr-only-focusable" href="#main-content">{intl.formatMessage(messages.skipNavLink)}</a>
<div className="container-xl py-2 d-flex align-items-center">
{headerLogo}
<div className="flex-grow-1 course-title-lockup text-center" style={{ lineHeight: 1 }}>
{
(courseOrg && logoOrg)
&& <img src={logoOrg} alt={`${courseOrg} logo`} style={{ maxHeight: '50px' }} />
}
<span
className="d-inline-block course-title font-weight-bold ml-3 overflow-hidden text-nowrap text-left w-25"
style={{ textOverflow: 'ellipsis' }}
>
{courseTitle}
</span>
<div className="d-none d-md-block flex-grow-1 course-title-lockup">
<div className={`d-md-flex ${enabledOrgLogo && 'align-items-center justify-content-center'} w-100`}>
{enabledOrgLogo ? (
(courseOrg && logoOrg)
&& <img src={logoOrg} alt={`${courseOrg} logo`} style={{ maxHeight: '45px' }} />
) : null}
<span
className="d-inline-block course-title font-weight-semibold ml-3 text-truncate text-left w-25"
style={{ fontSize: '0.85rem' }}
>
{courseTitle}
</span>
</div>
</div>
{showUserDropdown && authenticatedUser && (
<AuthenticatedUserDropdown
Expand Down
1 change: 0 additions & 1 deletion src/learning-header/LearningHeader.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ describe('Header', () => {
render(<Header {...courseData} />);
waitFor(
() => {

expect(screen.getByAltText(`${courseData.courseOrg} logo`)).toHaveAttribute('src', 'logo-url');
expect(screen.getByText(`${courseData.courseOrg}`)).toBeInTheDocument();
expect(screen.getByText(courseData.courseTitle)).toBeInTheDocument();
Expand Down
10 changes: 10 additions & 0 deletions src/learning-header/_header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import "../../node_modules/bootstrap/scss/bootstrap-grid";
@import "../../node_modules/bootstrap/scss/mixins/breakpoints";

.logo {
img {
@include media-breakpoint-down(sm) {
max-width: 85% !important;
}
}
}
Loading