|
| 1 | +# Header User Menu Group Slot |
| 2 | + |
| 3 | +### Slot ID: `header_user_menu_group_slot` |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +This slot is used to insert a user menu group in the header's user menu for both desktop and mobile screens. |
| 8 | + |
| 9 | +Note: Ensure the slot is provided with appropriate JSX that can render smoothly on both desktop and mobile screens. |
| 10 | + |
| 11 | +## Example |
| 12 | + |
| 13 | +The following ``env.config.jsx`` demonstrates how to insert a user menu group into the header's user menu |
| 14 | +for both mobile and desktop screens. |
| 15 | + |
| 16 | +**Default Behaviour:** |
| 17 | + |
| 18 | +Desktop: |
| 19 | + |
| 20 | + |
| 21 | +Mobile: |
| 22 | + |
| 23 | + |
| 24 | +**Inserted a user menu group:** |
| 25 | + |
| 26 | +Desktop: |
| 27 | + |
| 28 | + |
| 29 | +Mobile: |
| 30 | + |
| 31 | + |
| 32 | +```jsx |
| 33 | +import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; |
| 34 | +import { breakpoints, Dropdown, useWindowSize } from '@openedx/paragon'; |
| 35 | + |
| 36 | +const config = { |
| 37 | + pluginSlots: { |
| 38 | + header_user_menu_group_slot: { |
| 39 | + plugins: [ |
| 40 | + { |
| 41 | + // Insert some user menu group |
| 42 | + op: PLUGIN_OPERATIONS.Insert, |
| 43 | + widget: { |
| 44 | + id: 'user_menu_group', |
| 45 | + type: DIRECT_PLUGIN, |
| 46 | + RenderWidget: () => { |
| 47 | + const { width } = useWindowSize(); |
| 48 | + const isMobile = width <= breakpoints.small.maxWidth; |
| 49 | + if (!isMobile) { |
| 50 | + return ( |
| 51 | + <> |
| 52 | + <Dropdown.Header>User Menu Group Header</Dropdown.Header> |
| 53 | + <Dropdown.Item as="a" href="#" className="active"> |
| 54 | + User Menu Group Item - Active |
| 55 | + </Dropdown.Item> |
| 56 | + <Dropdown.Item as="a" href="#"> |
| 57 | + User Menu Group Item 2 |
| 58 | + </Dropdown.Item> |
| 59 | + <Dropdown.Divider /> |
| 60 | + </> |
| 61 | + ); |
| 62 | + } |
| 63 | + return ( |
| 64 | + <> |
| 65 | + <li className="nav-item"> |
| 66 | + <a href="#" className="nav-link active"> |
| 67 | + User Menu Group Item - Active |
| 68 | + </a> |
| 69 | + </li> |
| 70 | + <li className="nav-item"> |
| 71 | + <a href="#" className="nav-link active"> |
| 72 | + User Menu Group Item 2 |
| 73 | + </a> |
| 74 | + </li> |
| 75 | + </> |
| 76 | + ); |
| 77 | + }, |
| 78 | + }, |
| 79 | + }, |
| 80 | + ], |
| 81 | + }, |
| 82 | + }, |
| 83 | +} |
| 84 | + |
| 85 | +export default config; |
| 86 | +``` |
0 commit comments