-
Notifications
You must be signed in to change notification settings - Fork 211
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!: organize plugin slots as components, add footer slot #1381
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Footer Slot | ||
|
||
### Slot ID: `footer_slot` | ||
|
||
## Description | ||
|
||
This slot is used to replace/modify/hide the footer. | ||
|
||
The implementation of the `FooterSlot` component lives in [the `frontend-slot-footer` repository](https://github.com/openedx/frontend-slot-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) | ||
|
||
```jsx | ||
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; | ||
``` |
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/) |
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. | ||
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. @MaxFrank13 I'm not 💯 on the wording I have here, if you have any suggestions that'd be wonderful! 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. As someone who doesn't develop much in this MFE, this makes sense to me — which I think is an indication that it's written well 👍 |
||
|
||
## 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; | ||
``` |
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; |
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; | ||
``` |
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; |
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.
Just a note for the purpose of transparency: we've decided to attempt to move the Footer Slot to
frontend-component-footer
itself.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.
Addressed in https://github.com/openedx/frontend-app-learning/compare/f662654c7692086bba8f6eada37375c83362328e..98fdde1ffdb669ac9ba1e584e2d633437d4701da