-
Notifications
You must be signed in to change notification settings - Fork 214
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: wrap existing sidebars in frontend-plugin-framework
PluginSlot
s
#1543
Merged
brian-smith-tcril
merged 1 commit into
openedx:master
from
brian-smith-tcril:mvp-sidebar-slots
Dec 4, 2024
Merged
Changes from all commits
Commits
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 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 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 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,43 @@ | ||
# Course Breadcrumbs Slot | ||
|
||
### Slot ID: `course_breadcrumbs_slot` | ||
|
||
## Description | ||
|
||
This slot is used to replace/modify/hide the course breadcrumbs. | ||
|
||
## Example | ||
|
||
### Default content | ||
![Breadcrumbs slot with default content](./screenshot_default.png) | ||
|
||
### Replaced with custom component | ||
![🍞 in breadcrumbs slot](./screenshot_custom.png) | ||
|
||
The following `env.config.jsx` will replace the course breadcrumbs entirely. | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
course_breadcrumbs_slot: { | ||
keepDefault: false, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_breadcrumbs_component', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: () => ( | ||
<h1>🍞</h1> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
This file contains 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,32 @@ | ||
import React from 'react'; | ||
|
||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
||
import CourseBreadcrumbs from '../../courseware/course/CourseBreadcrumbs'; | ||
|
||
interface Props { | ||
courseId: string; | ||
sectionId?: string; | ||
sequenceId?: string; | ||
unitId?: string; | ||
isStaff?: boolean; | ||
} | ||
|
||
export const CourseBreadcrumbsSlot : React.FC<Props> = ({ | ||
courseId, sectionId, sequenceId, unitId, isStaff, | ||
}) => ( | ||
<PluginSlot | ||
id="course_breadcrumbs_slot" | ||
slotOptions={{ | ||
mergeProps: true, | ||
}} | ||
> | ||
<CourseBreadcrumbs | ||
courseId={courseId} | ||
sectionId={sectionId} | ||
sequenceId={sequenceId} | ||
isStaff={isStaff} | ||
unitId={unitId} | ||
/> | ||
</PluginSlot> | ||
); |
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.
43 changes: 43 additions & 0 deletions
43
src/plugin-slots/CourseOutlineMobileSidebarTriggerSlot/README.md
This file contains 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,43 @@ | ||
# Course Outline Mobile Sidebar Trigger Slot | ||
|
||
### Slot ID: `course_outline_mobile_sidebar_trigger_slot` | ||
|
||
## Description | ||
|
||
This slot is used to replace/modify/hide the course outline sidebar mobile trigger. | ||
|
||
## Example | ||
|
||
### Default content | ||
![Trigger slot with default content](./screenshot_default.png) | ||
|
||
### Replaced with custom component | ||
![📌 in trigger slot](./screenshot_custom.png) | ||
|
||
The following `env.config.jsx` will replace the course outline sidebar mobile trigger entirely. | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
course_outline_mobile_sidebar_trigger_slot: { | ||
keepDefault: false, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_sidebar_trigger_component', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: () => ( | ||
<h1 className="d-xl-none">📌</h1> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
16 changes: 16 additions & 0 deletions
16
src/plugin-slots/CourseOutlineMobileSidebarTriggerSlot/index.tsx
This file contains 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,16 @@ | ||
import React from 'react'; | ||
|
||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
||
import CourseOutlineTrigger from '../../courseware/course/sidebar/sidebars/course-outline/CourseOutlineTrigger'; | ||
|
||
export const CourseOutlineMobileSidebarTriggerSlot : React.FC = () => ( | ||
<PluginSlot | ||
id="course_outline_mobile_sidebar_trigger_slot" | ||
slotOptions={{ | ||
mergeProps: true, | ||
}} | ||
> | ||
<CourseOutlineTrigger isMobileView /> | ||
</PluginSlot> | ||
); |
Binary file added
BIN
+22 KB
src/plugin-slots/CourseOutlineMobileSidebarTriggerSlot/screenshot_custom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.9 KB
src/plugin-slots/CourseOutlineMobileSidebarTriggerSlot/screenshot_default.png
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 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,43 @@ | ||
# Course Outline Sidebar Slot | ||
|
||
### Slot ID: `course_outline_sidebar_slot` | ||
|
||
## Description | ||
|
||
This slot is used to replace/modify/hide the course outline sidebar. | ||
bradenmacdonald marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Example | ||
|
||
### Default content | ||
![Sidebar slot with default content](./screenshot_default.png) | ||
|
||
### Replaced with custom component | ||
![📊 in sidebar slot](./screenshot_custom.png) | ||
|
||
The following `env.config.jsx` will replace the course outline sidebar entirely. | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
course_outline_sidebar_slot: { | ||
keepDefault: false, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_sidebar_component', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: () => ( | ||
<h1>📊</h1> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
This file contains 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,16 @@ | ||
import React from 'react'; | ||
|
||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
||
import CourseOutlineTray from '../../courseware/course/sidebar/sidebars/course-outline/CourseOutlineTray'; | ||
|
||
export const CourseOutlineSidebarSlot : React.FC = () => ( | ||
<PluginSlot | ||
id="course_outline_sidebar_slot" | ||
slotOptions={{ | ||
mergeProps: true, | ||
}} | ||
> | ||
<CourseOutlineTray /> | ||
</PluginSlot> | ||
); |
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.
43 changes: 43 additions & 0 deletions
43
src/plugin-slots/CourseOutlineSidebarTriggerSlot/README.md
This file contains 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,43 @@ | ||
# Course Outline Sidebar Trigger Slot | ||
|
||
### Slot ID: `course_outline_sidebar_trigger_slot` | ||
|
||
## Description | ||
|
||
This slot is used to replace/modify/hide the course outline sidebar trigger. | ||
|
||
## Example | ||
|
||
### Default content | ||
![Trigger slot with default content](./screenshot_default.png) | ||
|
||
### Replaced with custom component | ||
![📌 in trigger slot](./screenshot_custom.png) | ||
|
||
The following `env.config.jsx` will replace the course outline sidebar trigger entirely. | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
course_outline_sidebar_trigger_slot: { | ||
keepDefault: false, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_sidebar_trigger_component', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: () => ( | ||
<h1 className="d-none d-xl-block">📌</h1> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
16 changes: 16 additions & 0 deletions
16
src/plugin-slots/CourseOutlineSidebarTriggerSlot/index.tsx
This file contains 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,16 @@ | ||
import React from 'react'; | ||
|
||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
||
import CourseOutlineTrigger from '../../courseware/course/sidebar/sidebars/course-outline/CourseOutlineTrigger'; | ||
|
||
export const CourseOutlineSidebarTriggerSlot : React.FC = () => ( | ||
<PluginSlot | ||
id="course_outline_sidebar_trigger_slot" | ||
slotOptions={{ | ||
mergeProps: true, | ||
}} | ||
> | ||
<CourseOutlineTrigger isMobileView={false} /> | ||
</PluginSlot> | ||
); |
Binary file added
BIN
+38.7 KB
src/plugin-slots/CourseOutlineSidebarTriggerSlot/screenshot_custom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37 KB
src/plugin-slots/CourseOutlineSidebarTriggerSlot/screenshot_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions
43
src/plugin-slots/NotificationsDiscussionsSidebarSlot/README.md
This file contains 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,43 @@ | ||
# Notifications Discussions Sidebar Slot | ||
|
||
### Slot ID: `notifications_discussions_sidebar_slot` | ||
|
||
## Description | ||
|
||
This slot is used to replace/modify/hide the notifications discussions sidebar. | ||
|
||
## Example | ||
|
||
### Default content | ||
![Sidebar slot with default content](./screenshot_default.png) | ||
|
||
### Replaced with custom component | ||
![📊 in sidebar slot](./screenshot_custom.png) | ||
|
||
The following `env.config.jsx` will replace the notifications discussions sidebar. | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
notifications_discussions_sidebar_slot: { | ||
keepDefault: false, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_sidebar_component', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: () => ( | ||
<h1>📊</h1> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
Oops, something went wrong.
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.
But what is the "course outline sidebar mobile trigger"?
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 ties in to the "wrapping complexity" goal of this PR. The course outline sidebar trigger (the button that opens up the sidebar) is displayed in a different location (both visually and within the DOM) on mobile vs on desktop. The
CourseOutlineTrigger
component is used in bothSequence
andCourse
. InCourse
, the component is used withisMobileView
always set totrue
, where as inSequence
it is always set tofalse
.With the new slots,
CourseOutlineMobileSidebarTriggerSlot
exists only inCourse
, andCourseOutlineSidebarTriggerSlot
exists only inSequence
.I'm not sure what the best way to communicate this complexity in the README would be, any suggestions are very warmly welcome!
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 see. I do think it's more clear with the updated README screenshots showing before+after! Otherwise I don't have any suggestions :/