-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wrap existing sidebars in
frontend-plugin-framework
`PluginSl…
…ot`s
- Loading branch information
1 parent
642031b
commit 810b811
Showing
20 changed files
with
321 additions
and
15 deletions.
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
39 changes: 39 additions & 0 deletions
39
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,39 @@ | ||
# Course Outline 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 | ||
|
||
![📌 in trigger slot](./screenshot.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.jsx
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 { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
||
import CourseOutlineTrigger from '../../courseware/course/sidebar/sidebars/course-outline/CourseOutlineTrigger'; | ||
|
||
const CourseOutlineMobileSidebarTriggerSlot = () => ( | ||
<PluginSlot | ||
id="course_outline_mobile_sidebar_trigger_slot" | ||
slotOptions={{ | ||
mergeProps: true, | ||
}} | ||
> | ||
<CourseOutlineTrigger isMobileView /> | ||
</PluginSlot> | ||
); | ||
|
||
export default CourseOutlineMobileSidebarTriggerSlot; |
Binary file added
BIN
+27.1 KB
src/plugin-slots/CourseOutlineMobileSidebarTriggerSlot/screenshot.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,39 @@ | ||
# Course Outline Sidebar Slot | ||
|
||
### Slot ID: `course_outline_sidebar_slot` | ||
|
||
## Description | ||
|
||
This slot is used to replace/modify/hide the course outline sidebar. | ||
|
||
## Example | ||
|
||
![📊 in sidebar slot](./screenshot.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 { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
||
import CourseOutlineTray from '../../courseware/course/sidebar/sidebars/course-outline/CourseOutlineTray'; | ||
|
||
const CourseOutlineSidebarSlot = () => ( | ||
<PluginSlot | ||
id="course_outline_sidebar_slot" | ||
slotOptions={{ | ||
mergeProps: true, | ||
}} | ||
> | ||
<CourseOutlineTray /> | ||
</PluginSlot> | ||
); | ||
|
||
export default CourseOutlineSidebarSlot; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions
40
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,40 @@ | ||
# 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 | ||
|
||
![📌 in trigger slot with sidebar closed](./screenshot_1.png) | ||
![📌 in trigger slot with sidebar open](./screenshot_2.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.jsx
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 { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
||
import CourseOutlineTrigger from '../../courseware/course/sidebar/sidebars/course-outline/CourseOutlineTrigger'; | ||
|
||
const CourseOutlineSidebarTriggerSlot = () => ( | ||
<PluginSlot | ||
id="course_outline_sidebar_trigger_slot" | ||
slotOptions={{ | ||
mergeProps: true, | ||
}} | ||
> | ||
<CourseOutlineTrigger /> | ||
</PluginSlot> | ||
); | ||
|
||
export default CourseOutlineSidebarTriggerSlot; |
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.
39 changes: 39 additions & 0 deletions
39
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,39 @@ | ||
# Notifications Discussions Sidebar Slot | ||
|
||
### Slot ID: `notifications_discussions_sidebar_slot` | ||
|
||
## Description | ||
|
||
This slot is used to replace/modify/hide the notifications discussions sidebar. | ||
|
||
## Example | ||
|
||
![📊 in sidebar slot](./screenshot.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; | ||
``` |
30 changes: 30 additions & 0 deletions
30
src/plugin-slots/NotificationsDiscussionsSidebarSlot/index.jsx
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,30 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
import { useModel } from '@src/generic/model-store'; | ||
|
||
import Sidebar from '../../courseware/course/sidebar/Sidebar'; | ||
import NewSidebar from '../../courseware/course/new-sidebar/Sidebar'; | ||
|
||
const NotificationsDiscussionsSidebarSlot = ({ courseId }) => { | ||
const { | ||
isNewDiscussionSidebarViewEnabled, | ||
} = useModel('courseHomeMeta', courseId); | ||
|
||
return ( | ||
<PluginSlot | ||
id="notifications_discussions_sidebar_slot" | ||
slotOptions={{ | ||
mergeProps: true, | ||
}} | ||
> | ||
{isNewDiscussionSidebarViewEnabled ? <NewSidebar /> : <Sidebar />} | ||
</PluginSlot> | ||
); | ||
}; | ||
|
||
NotificationsDiscussionsSidebarSlot.propTypes = { | ||
courseId: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default NotificationsDiscussionsSidebarSlot; |
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/NotificationsDiscussionsSidebarTriggerSlot/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 Trigger Slot | ||
|
||
### Slot ID: `notifications_discussions_sidebar_trigger_slot` | ||
|
||
## Description | ||
|
||
This slot is used to replace/modify/hide the notifications discussions 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 notifications discussions sidebar trigger. | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
notifications_discussions_sidebar_trigger_slot: { | ||
keepDefault: false, | ||
plugins: [ | ||
{ | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_sidebar_trigger_component', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: () => ( | ||
<h1 className='ml-auto'>📬</h1> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
28 changes: 28 additions & 0 deletions
28
src/plugin-slots/NotificationsDiscussionsSidebarTriggerSlot/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,28 @@ | ||
import React from 'react'; | ||
|
||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
import { useModel } from '@src/generic/model-store'; | ||
|
||
import SidebarTriggers from '../../courseware/course/sidebar/SidebarTriggers'; | ||
import NewSidebarTriggers from '../../courseware/course/new-sidebar/SidebarTriggers'; | ||
|
||
interface Props { | ||
courseId: string; | ||
} | ||
|
||
export const NotificationsDiscussionsSidebarTriggerSlot : React.FC<Props> = ({ courseId }) => { | ||
const { | ||
isNewDiscussionSidebarViewEnabled, | ||
} = useModel('courseHomeMeta', courseId); | ||
|
||
return ( | ||
<PluginSlot | ||
id="notifications_discussions_sidebar_trigger_slot" | ||
slotOptions={{ | ||
mergeProps: true, | ||
}} | ||
> | ||
{isNewDiscussionSidebarViewEnabled ? <NewSidebarTriggers /> : <SidebarTriggers /> } | ||
</PluginSlot> | ||
); | ||
}; |
Binary file added
BIN
+27.1 KB
src/plugin-slots/NotificationsDiscussionsSidebarTriggerSlot/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
+25 KB
src/plugin-slots/NotificationsDiscussionsSidebarTriggerSlot/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.
Oops, something went wrong.