feat: update next unit button plugin for left sidebar navigation usage (#1578)
* feat: move unit next button slot to plugins folder * feat: update unit navigation at top to use next unit plugin * fix: remove 2u plugin specific code
This commit is contained in:
55
src/plugin-slots/NextUnitTopNavTriggerSlot/README.md
Normal file
55
src/plugin-slots/NextUnitTopNavTriggerSlot/README.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# Next Unit Top Navigation Trigger Slot
|
||||
|
||||
### Slot ID: `next_unit_top_nav_trigger_slot`
|
||||
|
||||
## Description
|
||||
|
||||
This slot is used to replace/modify/hide the next button used for unit and sequence navigation at the top of the unit page.
|
||||
|
||||
## Example
|
||||
|
||||
### Default content
|
||||
|
||||
**Next unit button in at top for left sidebar navigation**
|
||||

|
||||
|
||||
**Next unit button in horizontal navigation**
|
||||

|
||||
|
||||
### Replaced with custom component
|
||||
|
||||
**Next unit button in at top for left sidebar navigation**
|
||||

|
||||
|
||||
**Next unit button in horizontal navigation**
|
||||

|
||||

|
||||
|
||||
The following `env.config.jsx` will replace the next unit/sequence button at the top of the unit page. This can be used control the
|
||||
button's `onClick` atrribute or change the name of the button.
|
||||
|
||||
```js
|
||||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
|
||||
|
||||
const config = {
|
||||
pluginSlots: {
|
||||
next_unit_top_nav_trigger_slot: {
|
||||
keepDefault: false,
|
||||
plugins: [
|
||||
{
|
||||
op: PLUGIN_OPERATIONS.Insert,
|
||||
widget: {
|
||||
id: 'custom_button_component',
|
||||
type: DIRECT_PLUGIN,
|
||||
RenderWidget: () => (
|
||||
<button>📊</button>
|
||||
),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default config;
|
||||
```
|
||||
53
src/plugin-slots/NextUnitTopNavTriggerSlot/index.tsx
Normal file
53
src/plugin-slots/NextUnitTopNavTriggerSlot/index.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import React from 'react';
|
||||
|
||||
import { PluginSlot } from '@openedx/frontend-plugin-framework';
|
||||
|
||||
import NextButton from '../../courseware/course/sequence/sequence-navigation/generic/NextButton';
|
||||
|
||||
interface Props {
|
||||
courseId: string | '';
|
||||
disabled: boolean;
|
||||
buttonText: string | '';
|
||||
nextLink: string;
|
||||
sequenceId: string;
|
||||
unitId: string;
|
||||
onClickHandler: () => void;
|
||||
variant: string;
|
||||
buttonStyle: string;
|
||||
}
|
||||
|
||||
export const NextUnitTopNavTriggerSlot : React.FC<Props> = ({
|
||||
courseId,
|
||||
disabled,
|
||||
buttonText,
|
||||
nextLink,
|
||||
sequenceId,
|
||||
onClickHandler,
|
||||
variant,
|
||||
buttonStyle,
|
||||
}) => (
|
||||
<PluginSlot
|
||||
id="next_unit_top_nav_trigger_slot"
|
||||
pluginProps={{
|
||||
courseId,
|
||||
disabled,
|
||||
buttonText,
|
||||
nextLink,
|
||||
sequenceId,
|
||||
onClickHandler,
|
||||
variant,
|
||||
buttonStyle,
|
||||
}}
|
||||
>
|
||||
<NextButton
|
||||
{...{
|
||||
variant,
|
||||
buttonStyle,
|
||||
onClickHandler,
|
||||
nextLink,
|
||||
disabled,
|
||||
buttonText,
|
||||
}}
|
||||
/>
|
||||
</PluginSlot>
|
||||
);
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Reference in New Issue
Block a user