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:
Kristin Aoki
2025-01-28 13:01:18 -05:00
committed by GitHub
parent 7865fadec2
commit 8823cfaa0a
11 changed files with 158 additions and 57 deletions

View 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**
![Screenshot of next unit button slot at the top for left sidebar navigation with default content](./screenshot_unit_at_top_default.png)
**Next unit button in horizontal navigation**
![Screenshot of horizontal navigaton next unit button slot with default content](./screenshot_horizontal_nav_default.png)
### Replaced with custom component
**Next unit button in at top for left sidebar navigation**
![Screenshot of 📊 in next unit slot at the top for left sidebar navigation](./screenshot_unit_at_top_custom.png)
**Next unit button in horizontal navigation**
![Screenshot of 📊 in next unit slot for horizontal navigaton](./screenshot_horizontal_nav_default.png)
![📊 in next unit slot](./screenshot_horizontal_nav_custom.png)
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;
```

View 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