|
| 1 | +# Sequence Navigation Slot |
| 2 | + |
| 3 | +### Slot ID: `org.openedx.frontend.learning.sequence_navigation.v1` |
| 4 | + |
| 5 | +### Props: |
| 6 | +* `sequenceId` (string) — Current sequence identifier |
| 7 | +* `unitId` (string) — Current unit identifier |
| 8 | +* `nextHandler` (function) — Handler for next navigation action |
| 9 | +* `onNavigate` (function) — Handler for direct unit navigation |
| 10 | +* `previousHandler` (function) — Handler for previous navigation action |
| 11 | + |
| 12 | +## Description |
| 13 | + |
| 14 | +This slot is used to replace/modify/hide the sequence navigation component that controls navigation between units within a course sequence. |
| 15 | + |
| 16 | +## Example |
| 17 | + |
| 18 | +### Default content |
| 19 | + |
| 20 | + |
| 21 | +### Replaced with custom component |
| 22 | + |
| 23 | + |
| 24 | +The following `env.config.jsx` will replace the sequence navigation with a custom implementation that uses all available props. |
| 25 | + |
| 26 | +```js |
| 27 | +import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; |
| 28 | + |
| 29 | +const config = { |
| 30 | + pluginSlots: { |
| 31 | + 'org.openedx.frontend.learning.sequence_navigation.v1': { |
| 32 | + keepDefault: false, |
| 33 | + plugins: [ |
| 34 | + { |
| 35 | + op: PLUGIN_OPERATIONS.Insert, |
| 36 | + widget: { |
| 37 | + id: 'custom_sequence_navigation', |
| 38 | + type: DIRECT_PLUGIN, |
| 39 | + RenderWidget: ({ sequenceId, unitId, nextHandler, onNavigate, previousHandler }) => { |
| 40 | + // Mock unit data for demonstration |
| 41 | + const units = ['unit-1', 'unit-2', 'unit-3']; |
| 42 | + |
| 43 | + return ( |
| 44 | + <Stack gap={2} direction="horizontal" className="p-3 bg-light w-100"> |
| 45 | + <Button |
| 46 | + className="flex-grow-1" |
| 47 | + onClick={previousHandler} |
| 48 | + > |
| 49 | + ⬅️ Previous |
| 50 | + </Button> |
| 51 | + <Stack gap={2} direction="horizontal"> |
| 52 | + {units.map((unit, index) => ( |
| 53 | + <Button |
| 54 | + variant="outline-primary" |
| 55 | + key={unit} |
| 56 | + className={`btn btn-sm ${unitId === unit ? 'btn-primary' : 'btn-outline-secondary'}`} |
| 57 | + onClick={() => onNavigate(unit)} |
| 58 | + > |
| 59 | + {index + 1} |
| 60 | + </Button> |
| 61 | + ))} |
| 62 | + </Stack> |
| 63 | + <Button |
| 64 | + className="flex-grow-1" |
| 65 | + onClick={nextHandler} |
| 66 | + > |
| 67 | + Next ➡️ |
| 68 | + </Button> |
| 69 | + </Stack> |
| 70 | + ) |
| 71 | + }, |
| 72 | + }, |
| 73 | + }, |
| 74 | + ] |
| 75 | + } |
| 76 | + }, |
| 77 | +} |
| 78 | + |
| 79 | +export default config; |
| 80 | +``` |
0 commit comments