-
Notifications
You must be signed in to change notification settings - Fork 335
feat: Add Sidebar and SidebarNotificationButton components for Value Prop #414
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e86335c
Add Sidebar and SidebarNotificationButton components
julianajlk 0853f95
Add tests
julianajlk ff81ee1
Change resposiveness to apply at tablet md size
julianajlk b227c94
Remove REV-1512 experiment code
julianajlk fea9899
After UX asked for changes in responsive version
julianajlk 52a2142
Move notification icon and red dot to separate component
julianajlk b773e3e
Change conditional outside of Sidebar component and update Sidebar.te…
julianajlk 635f7e0
Update Course/CourseBreadcrumbs screen size conditional
julianajlk 5afefc5
Update styling on notification button and icon
julianajlk d73f7fc
Update SequenceNav/SequenceNav.test screen size conditional
julianajlk a238f91
Remove unused props from Sequence
julianajlk 2609953
Add SidebarNotificationButton to Sequence i/o SequenceNavigation comp…
julianajlk 86d79b8
Update inline CSS on sequence div
julianajlk ade188e
Install js-cookie for handling cookies
julianajlk a98714a
Add temporary cookie code to hide sidebar and button
julianajlk 3bf88c7
Styling/a11y updates
julianajlk f6880b4
Add no notifications conditional for the sidebar height
julianajlk 65fb9fa
Styling updates, add NotificationIcons scss file
julianajlk a44b20c
Add responsiveBreakpoints replacing hard coded pixels
julianajlk bc2e75f
Add more tests, temporary cookie naming update
julianajlk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import classNames from 'classnames'; | ||
| import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; | ||
| import { Icon } from '@edx/paragon'; | ||
| import { WatchOutline } from '@edx/paragon/icons'; | ||
|
|
||
| import './NotificationIcon.scss'; | ||
| import messages from './messages'; | ||
|
|
||
| function NotificationIcon({ intl, status, notificationColor }) { | ||
| return ( | ||
| <div className="icon-container"> | ||
| <Icon src={WatchOutline} className="m-0 m-auto" alt={intl.formatMessage(messages.openSidebarButton)} /> | ||
| {status === 'active' | ||
| ? <span className={classNames(notificationColor, 'notification-dot')} data-testid="notification-dot" /> | ||
| : null} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| NotificationIcon.propTypes = { | ||
| intl: intlShape.isRequired, | ||
| status: PropTypes.string.isRequired, | ||
| notificationColor: PropTypes.string.isRequired, | ||
| }; | ||
|
|
||
| export default injectIntl(NotificationIcon); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| .icon-container { | ||
| position: relative; | ||
| display: flex; | ||
| align-items: center; | ||
| width: 2.4rem; | ||
| height: 2rem; | ||
| } | ||
|
|
||
| .notification-dot { | ||
| position: absolute; | ||
| top: 0.3rem; | ||
| right: 0.55rem; | ||
| border-radius: 50% !important; | ||
| padding: 0.25rem !important; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import classNames from 'classnames'; | ||
| import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; | ||
| import { Icon } from '@edx/paragon'; | ||
| import { ArrowBackIos, Close } from '@edx/paragon/icons'; | ||
| import './Sidebar.scss'; | ||
| import messages from './messages'; | ||
| import useWindowSize, { responsiveBreakpoints } from '../../generic/tabs/useWindowSize'; | ||
|
|
||
| function Sidebar({ | ||
| intl, toggleSidebar, | ||
| }) { | ||
| const shouldDisplayFullScreen = useWindowSize().width < responsiveBreakpoints.large.minWidth; | ||
|
|
||
| // REV-2130 TODO: temporary variable set to true, should be replaced with | ||
| // whether the course can be upgraded (ie. shouldDisplayUpgradeNotification) | ||
| const shouldDisplayNoNotification = true; | ||
|
|
||
| return ( | ||
| <section className={classNames('sidebar-container ml-0 ml-lg-4', { 'no-notification': shouldDisplayNoNotification && !shouldDisplayFullScreen })} aria-label={intl.formatMessage(messages.sidebarNotification)}> | ||
| {shouldDisplayFullScreen ? ( | ||
| <div className="mobile-close-container" onClick={() => { toggleSidebar(); }} onKeyDown={() => { toggleSidebar(); }} role="button" tabIndex="0" alt={intl.formatMessage(messages.responsiveCloseSidebar)}> | ||
| <Icon src={ArrowBackIos} /> | ||
| <span className="mobile-close">{intl.formatMessage(messages.responsiveCloseSidebar)}</span> | ||
| </div> | ||
| ) : null} | ||
| <div className="sidebar-header px-3"> | ||
| <span>{intl.formatMessage(messages.notificationTitle)}</span> | ||
| {shouldDisplayFullScreen | ||
| ? null | ||
| : <Icon src={Close} className="close-btn" onClick={() => { toggleSidebar(); }} onKeyDown={() => { toggleSidebar(); }} role="button" tabIndex="0" alt={intl.formatMessage(messages.closeSidebarButton)} />} | ||
| </div> | ||
| <div className="sidebar-divider" /> | ||
| <div className="sidebar-content"> | ||
| {/* REV-2130 TODO: replace logic to display upgrade expiration box if condition is true */} | ||
| {shouldDisplayNoNotification ? <p>{intl.formatMessage(messages.noNotificationsMessage)}</p> : null} | ||
| </div> | ||
| </section> | ||
| ); | ||
| } | ||
|
|
||
| Sidebar.propTypes = { | ||
| intl: intlShape.isRequired, | ||
| toggleSidebar: PropTypes.func, | ||
| }; | ||
|
|
||
| Sidebar.defaultProps = { | ||
| toggleSidebar: null, | ||
| }; | ||
|
|
||
| export default injectIntl(Sidebar); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| @import "~@edx/brand/paragon/fonts"; | ||
| @import "~@edx/brand/paragon/variables"; | ||
| @import "~@edx/paragon/scss/core/core"; | ||
| @import "~@edx/brand/paragon/overrides"; | ||
|
|
||
| .sidebar-container { | ||
| border: 1px solid $light-400; | ||
| border-radius: 4px; | ||
| width: 20rem; | ||
| vertical-align: top; | ||
|
|
||
| @media (max-width: -1 + map-get($grid-breakpoints, 'lg')) { | ||
| position: fixed; | ||
| top: 0; | ||
| bottom: 0; | ||
| left: 0; | ||
| right: 0; | ||
| width: 100%; | ||
| height: 100% !important; | ||
| background-color: white; | ||
| margin: 0; | ||
| border: none; | ||
| border-radius: 0; | ||
| } | ||
| } | ||
|
|
||
| .no-notification { | ||
| height: 15rem; | ||
| } | ||
|
|
||
| .sidebar-header { | ||
| padding: 0.625rem 0; | ||
|
|
||
| span { | ||
| display: inline-block; | ||
| } | ||
| } | ||
|
|
||
| .close-btn { | ||
| float: right; | ||
| } | ||
|
|
||
| .sidebar-divider { | ||
| width: 100.5%; | ||
| height: 0.5rem; | ||
| background: $gray-100; | ||
| border: 1px solid $light-400; | ||
| border-left: 0; | ||
| } | ||
|
|
||
| .sidebar-content { | ||
| padding: 1rem; | ||
| font-size: 0.875rem; | ||
| } | ||
|
|
||
| .mobile-close-container { | ||
| padding-top: 0.5rem; | ||
| padding-bottom: 0.75rem; | ||
| border-bottom: 1px solid $light-400; | ||
|
|
||
| span { | ||
| display: inline-block; | ||
| } | ||
| svg { | ||
| top: 0.4rem; | ||
| left: 0.8rem; | ||
| } | ||
| } | ||
|
|
||
| .mobile-close { | ||
| font-weight: 500; | ||
| margin-left: 1.2rem; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import React from 'react'; | ||
| import { Factory } from 'rosie'; | ||
| import { | ||
| render, initializeTestStore, screen, fireEvent, waitFor, | ||
| } from '../../setupTest'; | ||
| import Sidebar from './Sidebar'; | ||
| import useWindowSize from '../../generic/tabs/useWindowSize'; | ||
|
|
||
| jest.mock('../../generic/tabs/useWindowSize'); | ||
|
|
||
| describe('Sidebar', () => { | ||
| let mockData; | ||
| const courseMetadata = Factory.build('courseMetadata'); | ||
|
|
||
| beforeEach(async () => { | ||
| mockData = { | ||
| toggleSidebar: () => {}, | ||
| }; | ||
| }); | ||
|
|
||
| beforeAll(async () => { | ||
| await initializeTestStore({ courseMetadata, excludeFetchCourse: true, excludeFetchSequence: true }); | ||
| }); | ||
|
|
||
| it('renders sidebar', async () => { | ||
| useWindowSize.mockReturnValue({ width: 1200, height: 422 }); | ||
| const { container } = render(<Sidebar {...mockData} />); | ||
|
|
||
| expect(container).toBeInTheDocument(); | ||
| expect(container).toHaveTextContent('Notifications'); | ||
| expect(container).not.toHaveTextContent('Back to course'); | ||
| }); | ||
|
|
||
| it('renders no notifications message', async () => { | ||
| // REV-2130 TODO: add conditional if no expiration box/upgradeable | ||
| const testData = { ...mockData }; | ||
| const { container } = render(<Sidebar {...testData} />); | ||
|
|
||
| expect(container).toBeInTheDocument(); | ||
| expect(container).toHaveTextContent('You have no new notifications at this time.'); | ||
| }); | ||
|
|
||
| it('renders sidebar with full screen "Back to course" at response width', async () => { | ||
| useWindowSize.mockReturnValue({ width: 991, height: 422 }); | ||
| const toggleSidebar = jest.fn(); | ||
| const testData = { | ||
| ...mockData, | ||
| toggleSidebar, | ||
| }; | ||
| render(<Sidebar {...testData} />); | ||
|
|
||
| const responsiveCloseButton = screen.getByRole('button', { name: 'Back to course' }); | ||
| await waitFor(() => expect(responsiveCloseButton).toBeInTheDocument()); | ||
|
|
||
| fireEvent.click(responsiveCloseButton); | ||
| expect(toggleSidebar).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.