-
Notifications
You must be signed in to change notification settings - Fork 324
feat: Add SequenceBottomNavigationSlot for customizable sequence navigation #1918
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
Open
xitij2000
wants to merge
4
commits into
openedx:master
Choose a base branch
from
open-craft:kshitij/sequence-bottom-navigation-slot
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f7005e2
feat: Add `SequenceBottomNavigationSlot` for customizable sequence na…
xitij2000 d1d1abb
fixup! feat: Add `SequenceBottomNavigationSlot` for customizable sequ…
xitij2000 053013c
fixup! fixup! feat: Add `SequenceBottomNavigationSlot` for customizab…
xitij2000 e1703df
fixup! fixup! fixup! feat: Add `SequenceBottomNavigationSlot` for cus…
xitij2000 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
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,66 @@ | ||||||||||||||
| # Sequence Bottom Navigation Slot | ||||||||||||||
|
|
||||||||||||||
| ### Slot ID: `org.openedx.frontend.learning.sequence_bottom_navigation.v1` | ||||||||||||||
|
|
||||||||||||||
| ### Props: | ||||||||||||||
| * `sequenceId` (string) — Current sequence identifier | ||||||||||||||
| * `unitId` (string) — Current unit identifier | ||||||||||||||
| * `nextHandler` (function) — Handler for next navigation action | ||||||||||||||
| * `onNavigate` (function) — Handler for direct unit navigation | ||||||||||||||
| * `previousHandler` (function) — Handler for previous navigation action | ||||||||||||||
|
|
||||||||||||||
| ## Description | ||||||||||||||
|
|
||||||||||||||
| This slot is used to replace/modify/hide the sequence navigation component that controls navigation between units within a course sequence at the bottom of the page. | ||||||||||||||
|
|
||||||||||||||
| ## Example | ||||||||||||||
|
|
||||||||||||||
| ### Default Navigation | ||||||||||||||
|  | ||||||||||||||
|
|
||||||||||||||
| ### Replaced with top naviation arrows | ||||||||||||||
|  | ||||||||||||||
|
|
||||||||||||||
| ```js | ||||||||||||||
| import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||||||||||||||
|
|
||||||||||||||
| const config = { | ||||||||||||||
| pluginSlots: { | ||||||||||||||
| 'org.openedx.frontend.learning.sequence_bottom_navigation.v1': { | ||||||||||||||
| keepDefault: false, | ||||||||||||||
| plugins: [ | ||||||||||||||
| { | ||||||||||||||
| op: PLUGIN_OPERATIONS.Insert, | ||||||||||||||
| widget: { | ||||||||||||||
| id: 'custom_sequence_navigation', | ||||||||||||||
| type: DIRECT_PLUGIN, | ||||||||||||||
| RenderWidget: ({ | ||||||||||||||
| sequenceId, | ||||||||||||||
| unitId, | ||||||||||||||
| nextHandler, | ||||||||||||||
| onNavigate, | ||||||||||||||
| previousHandler | ||||||||||||||
|
Comment on lines
+40
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should match the prop names being spread in from
Suggested change
|
||||||||||||||
| }) => { | ||||||||||||||
| const { courseId } = useParams(); | ||||||||||||||
| return ( | ||||||||||||||
| <div className="d-flex justify-content-center align-items-center"> | ||||||||||||||
| <UnitNavigation | ||||||||||||||
| courseId={courseId} | ||||||||||||||
| sequenceId={sequenceId} | ||||||||||||||
| unitId={unitId} | ||||||||||||||
| isAtTop={true} | ||||||||||||||
| onClickPrevious={previousHandler} | ||||||||||||||
| onClickNext={nextHandler} | ||||||||||||||
| /> | ||||||||||||||
| </div> | ||||||||||||||
| ); | ||||||||||||||
| }, | ||||||||||||||
| }, | ||||||||||||||
| }, | ||||||||||||||
| ], | ||||||||||||||
| }, | ||||||||||||||
| }, | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| export default config; | ||||||||||||||
| ``` | ||||||||||||||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,47 @@ | ||
| import { UnitNavigation } from '@src/courseware/course/sequence/sequence-navigation'; | ||
| import React from 'react'; | ||
| import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
|
||
| export interface SequenceBottomNavigationSlotProps { | ||
| courseId: string; | ||
| sequenceId: string; | ||
| unitId: string; | ||
| nextHandler: () => void; | ||
| onNavigate: (unitId: string) => void; | ||
| previousHandler: () => void; | ||
| } | ||
|
|
||
| const SequenceBottomNavigationSlot = ({ | ||
| courseId, | ||
| sequenceId, | ||
| unitId, | ||
| nextHandler, | ||
| onNavigate, | ||
| previousHandler, | ||
| }: SequenceBottomNavigationSlotProps) => ( | ||
| <PluginSlot | ||
| id="org.openedx.frontend.learning.sequence_bottom_navigation.v1" | ||
| slotOptions={{ | ||
| mergeProps: true, | ||
| }} | ||
| pluginProps={{ | ||
| courseId, | ||
| sequenceId, | ||
| unitId, | ||
| nextHandler, | ||
| onNavigate, | ||
| previousHandler, | ||
| }} | ||
| > | ||
| <UnitNavigation | ||
| courseId={courseId} | ||
| sequenceId={sequenceId} | ||
| unitId={unitId} | ||
| isAtTop={false} | ||
| onClickPrevious={previousHandler} | ||
| onClickNext={nextHandler} | ||
| /> | ||
| </PluginSlot> | ||
| ); | ||
|
|
||
| export default SequenceBottomNavigationSlot; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I debated quite a few things when thinking through how to make this more DRY.
The first thing that came to mind was moving this logic into
renderUnitNavigation, and I also considered removingrenderUnitNavigation'sisAtTopparam, but the fact that it's apluginPropinUnitTitleSlotfrontend-app-learning/src/plugin-slots/UnitTitleSlot/index.jsx
Line 24 in db18c2c
makes that risky.
I do still think we can make this more DRY without changing the existing slot prop API by doing something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely the cleaner way to do things. I will try to apply the changes tomorrow.