Skip to content

Commit

Permalink
fix: studio dropdown hover styles (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored Nov 16, 2023
1 parent 665653e commit bace828
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 195 deletions.
31 changes: 30 additions & 1 deletion example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AppContext, AppProvider } from '@edx/frontend-platform/react';
import Header from '@edx/frontend-component-header';

import './index.scss';
import StudioHeader from '../src/studio-header/StudioHeader';

subscribe(APP_READY, () => {
ReactDOM.render(
Expand All @@ -32,7 +33,35 @@ subscribe(APP_READY, () => {
}}>
<Header />
</AppContext.Provider>
<h5 className="mt-2">Logged in state</h5>
<h5 className="mt-2 mb-5">Logged in state</h5>
<AppContext.Provider value={{
authenticatedUser: {
userId: '123abc',
username: 'testuser',
roles: [],
administrator: false,
},
config: getConfig(),
}}>
<StudioHeader
number="run123"
org="testX"
title="Course Name"
isHiddenMainMenu={false}
mainMenuDropdowns={[
{
id: 'content-dropdown',
buttonTitle: 'Content',
items: [{
href: '#',
title: 'Outline',
}],
},
]}
outlineLink="#"
/>
</AppContext.Provider>
<h5 className="mt-2">Logged in state for Studio header</h5>
</AppProvider>,
document.getElementById('root'),
);
Expand Down
8 changes: 4 additions & 4 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $blue: #007db8;
$white: #fff;

@import './Menu/menu.scss';
@import './studio-header/header.scss';
@import './studio-header/StudioHeader.scss';

.dropdown-item a {
text-decoration: none;
Expand Down Expand Up @@ -43,9 +43,9 @@ $white: #fff;
.user-dropdown {
.btn {
height: 3rem;
@media (max-width: -1 + map-get($grid-breakpoints, "sm")) {
padding: 0 0.5rem;
}
// @media (max-width: -1 + map-get($grid-breakpoints, "sm")) {
// padding: 0 0.5rem;
// }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/studio-header/CourseLockUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const CourseLockUp = ({
)}
>
<a
className="course-title-lockup w-25 mr-2"
className="course-title-lockup mr-2"
href={outlineLink}
aria-label={intl.formatMessage(messages['header.label.courseOutline'])}
data-testid="course-lock-up-block"
Expand Down
39 changes: 22 additions & 17 deletions src/studio-header/HeaderBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const HeaderBody = ({
);

return (
<Container size="xl" className="px-4">
<Container size="xl" className="px-2.5">
<ActionRow as="header">
{isHiddenMainMenu ? (
<Row className="flex-nowrap ml-4">
Expand All @@ -64,29 +64,31 @@ const HeaderBody = ({
Menu
</Button>
) : (
<Row className="flex-nowrap m-0">
{renderBrandNav}
<CourseLockUp
{...{
outlineLink,
number,
org,
title,
}}
/>
</Row>
<div className="w-25">
<Row className="m-0 flex-nowrap">
{renderBrandNav}
<CourseLockUp
{...{
outlineLink,
number,
org,
title,
}}
/>
</Row>
</div>
)}
{isMobile ? (
<>
<ActionRow.Spacer />
{renderBrandNav}
</>
) : (
<Nav data-testid="desktop-menu" className="ml-4">
<Nav data-testid="desktop-menu" className="ml-2">
{mainMenuDropdowns.map(dropdown => {
const { id, buttonTitle, items } = dropdown;
return (
<NavDropdownMenu {...{ id, buttonTitle, items }} />
<NavDropdownMenu key={id} {...{ id, buttonTitle, items }} />
);
})}
</Nav>
Expand All @@ -113,9 +115,9 @@ const HeaderBody = ({
HeaderBody.propTypes = {
studioBaseUrl: PropTypes.string.isRequired,
logoutUrl: PropTypes.string.isRequired,
setModalPopupTarget: PropTypes.func.isRequired,
toggleModalPopup: PropTypes.func.isRequired,
isModalPopupOpen: PropTypes.bool.isRequired,
setModalPopupTarget: PropTypes.func,
toggleModalPopup: PropTypes.func,
isModalPopupOpen: PropTypes.bool,
number: PropTypes.string,
org: PropTypes.string,
title: PropTypes.string,
Expand All @@ -138,6 +140,9 @@ HeaderBody.propTypes = {
};

HeaderBody.defaultProps = {
setModalPopupTarget: null,
toggleModalPopup: null,
isModalPopupOpen: false,
logo: null,
logoAltText: null,
number: '',
Expand Down
3 changes: 0 additions & 3 deletions src/studio-header/MobileHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ const MobileHeader = ({
MobileHeader.propTypes = {
studioBaseUrl: PropTypes.string.isRequired,
logoutUrl: PropTypes.string.isRequired,
setModalPopupTarget: PropTypes.func.isRequired,
toggleModalPopup: PropTypes.func.isRequired,
isModalPopupOpen: PropTypes.bool.isRequired,
number: PropTypes.string,
org: PropTypes.string,
title: PropTypes.string,
Expand Down
4 changes: 3 additions & 1 deletion src/studio-header/NavDropdownMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ const NavDropdownMenu = ({
<DropdownButton
id={id}
title={buttonTitle}
variant="tertiary"
variant="outline-primary"
className="mr-2"
>
{items.map(item => (
<Dropdown.Item
key={`${item.title}-dropdown-item`}
href={item.href}
className="small"
>
Expand Down
9 changes: 5 additions & 4 deletions src/studio-header/StudioHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ const StudioHeader = ({
};

return (
<>
<Responsive maxWidth={768}>
<div className="studio-header">
<a className="nav-skip sr-only sr-only-focusable" href="#main">Skip to content</a>
<Responsive maxWidth={841}>
<MobileHeader {...props} />
</Responsive>
<Responsive minWidth={769}>
<Responsive minWidth={842}>
<HeaderBody {...props} />
</Responsive>
</>
</div>
);
};

Expand Down
49 changes: 49 additions & 0 deletions src/studio-header/StudioHeader.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
$spacer: 1rem;
$white: #FFFFFF;

.studio-header {
position: relative;
z-index: 1000;

height: 3.75rem;
box-shadow: 0 1px 0 0 rgb(0 0 0 / .1);
background: $white;

.btn-outline-primary {
border-color: $white;
}

.logo {
display: block;
box-sizing: content-box;
position: relative;
top: -.05em;
height: 1.75rem;
padding: $spacer 0;
margin-right: $spacer;

img {
display: block;
height: 100%;
}
}

.course-title-lockup {
@media only screen and (min-width: 769px) {
padding: .5rem;
padding-right: $spacer;
border-right: 1px solid #E5E5E5;
width: 70%;
}

overflow: hidden;

span {
color: #333333;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
line-height: 1.375rem;
}
}
}
64 changes: 0 additions & 64 deletions src/studio-header/header.scss

This file was deleted.

Loading

0 comments on commit bace828

Please sign in to comment.