-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: organize plugin slots as components, add footer slot
BREAKING CHANGE: slot ids have been changed for consistency * `sequence_container_plugin` -> `sequence_container_slot` * `unit_title_plugin` -> `unit_title_slot`
- Loading branch information
1 parent
1c3610e
commit f662654
Showing
17 changed files
with
213 additions
and
29 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
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
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,48 @@ | ||
# Footer Slot | ||
|
||
### Slot ID: `footer_slot` | ||
|
||
## Description | ||
|
||
This slot is used to replace/modify/hide the footer. | ||
|
||
## Example | ||
|
||
The following `env.config.jsx` will replace the default footer. | ||
|
||
![Screenshot of Default Footer](./images/default_footer.png) | ||
|
||
with a simple custom footer | ||
|
||
![Screenshot of Custom Footer](./images/custom_footer.png) | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
footer_slot: { | ||
plugins: [ | ||
{ | ||
// Hide the default footer | ||
op: PLUGIN_OPERATIONS.Hide, | ||
widgetId: 'default_contents', | ||
}, | ||
{ | ||
// Insert a custom footer | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_footer', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: () => ( | ||
<h1 style={{textAlign: 'center'}}>🦶</h1> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
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 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,10 @@ | ||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
import Footer from '@edx/frontend-component-footer'; | ||
|
||
const FooterSlot = () => ( | ||
<PluginSlot id="footer_slot"> | ||
<Footer /> | ||
</PluginSlot> | ||
); | ||
|
||
export default FooterSlot; |
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,5 @@ | ||
# `frontend-app-learning` Plugin Slots | ||
|
||
* [`footer_slot`](./FooterSlot/) | ||
* [`sequence_container_slot`](./SequenceContainerSlot/) | ||
* [`unit_title_slot`](./UnitTitleSlot/) |
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,45 @@ | ||
# Sequence Container Slot | ||
|
||
### Slot ID: `sequence_container_slot` | ||
### Props: | ||
* `courseId` | ||
* `unitId` | ||
|
||
## Description | ||
|
||
This slot is used for adding content after the Sequence content section. | ||
|
||
## Example | ||
|
||
The following `env.config.jsx` will render the `course_id` and `unit_id` of the course as `<p>` elements in a `<div>`. | ||
|
||
![Screenshot of Content added after the Sequence Container](./images/post_sequence_container.png) | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
sequence_container_slot: { | ||
plugins: [ | ||
{ | ||
// Insert custom content after sequence content | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_sequence_container_content', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: ({courseId, unitId}) => ( | ||
<div> | ||
<p>📚: {courseId}</p> | ||
<p>📙: {unitId}</p> | ||
</div> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
export default config; | ||
``` |
Binary file added
BIN
+39.8 KB
src/plugin-slots/SequenceContainerSlot/images/post_sequence_container.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,23 @@ | ||
import PropTypes from 'prop-types'; | ||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
||
const SequenceContainerSlot = ({ courseId, unitId }) => ( | ||
<PluginSlot | ||
id="sequence_container_slot" | ||
pluginProps={{ | ||
courseId, | ||
unitId, | ||
}} | ||
/> | ||
); | ||
|
||
SequenceContainerSlot.propTypes = { | ||
courseId: PropTypes.string.isRequired, | ||
unitId: PropTypes.string, | ||
}; | ||
|
||
SequenceContainerSlot.defaultProps = { | ||
unitId: null, | ||
}; | ||
|
||
export default SequenceContainerSlot; |
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,45 @@ | ||
# Unit Title Slot | ||
|
||
### Slot ID: `unit_title_slot` | ||
### Props: | ||
* `courseId` | ||
* `unitId` | ||
|
||
## Description | ||
|
||
This slot is used for adding content after the Unit title. | ||
|
||
## Example | ||
|
||
The following `env.config.jsx` will render the `course_id` and `unit_id` of the course as `<p>` elements. | ||
|
||
![Screenshot of Content added after the Unit Title](./images/post_unit_title.png) | ||
|
||
```js | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
const config = { | ||
pluginSlots: { | ||
unit_title_slot: { | ||
plugins: [ | ||
{ | ||
// Insert custom content after unit title | ||
op: PLUGIN_OPERATIONS.Insert, | ||
widget: { | ||
id: 'custom_unit_title_content', | ||
type: DIRECT_PLUGIN, | ||
RenderWidget: ({courseId, unitId}) => ( | ||
<> | ||
<p>📚: {courseId}</p> | ||
<p>📙: {unitId}</p> | ||
</> | ||
), | ||
}, | ||
}, | ||
] | ||
} | ||
}, | ||
} | ||
|
||
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.
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,19 @@ | ||
import PropTypes from 'prop-types'; | ||
import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
|
||
const UnitTitleSlot = ({ courseId, unitId }) => ( | ||
<PluginSlot | ||
id="unit_title_slot" | ||
pluginProps={{ | ||
courseId, | ||
unitId, | ||
}} | ||
/> | ||
); | ||
|
||
UnitTitleSlot.propTypes = { | ||
courseId: PropTypes.string.isRequired, | ||
unitId: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default UnitTitleSlot; |
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