|
| 1 | +# Studio Header Search Button Slot |
| 2 | + |
| 3 | +### Slot ID: `org.openedx.frontend.layout.studio_header_search_button_slot.v1` |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +This slot is used to replace/modify/hide the search button in the studio header. |
| 8 | + |
| 9 | +## Examples |
| 10 | + |
| 11 | +### Replace search with custom component |
| 12 | + |
| 13 | +The following `env.config.jsx` will replace the search button entirely (in this case with a custom emoji icon): |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +```jsx |
| 18 | +import { |
| 19 | + DIRECT_PLUGIN, |
| 20 | + PLUGIN_OPERATIONS, |
| 21 | +} from "@openedx/frontend-plugin-framework"; |
| 22 | + |
| 23 | +const config = { |
| 24 | + pluginSlots: { |
| 25 | + "org.openedx.frontend.layout.studio_header_search_button_slot.v1": { |
| 26 | + keepDefault: false, |
| 27 | + plugins: [ |
| 28 | + { |
| 29 | + op: PLUGIN_OPERATIONS.Insert, |
| 30 | + widget: { |
| 31 | + id: "custom_notification_tray", |
| 32 | + type: DIRECT_PLUGIN, |
| 33 | + RenderWidget: () => <span>🔔</span>, |
| 34 | + }, |
| 35 | + }, |
| 36 | + ], |
| 37 | + }, |
| 38 | + }, |
| 39 | +}; |
| 40 | + |
| 41 | +export default config; |
| 42 | +``` |
| 43 | + |
| 44 | +### Add custom component before and after search button |
| 45 | + |
| 46 | +The following `env.config.jsx` will insert emoji after and before the search button |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +```jsx |
| 51 | +import { |
| 52 | + DIRECT_PLUGIN, |
| 53 | + PLUGIN_OPERATIONS, |
| 54 | +} from "@openedx/frontend-plugin-framework"; |
| 55 | + |
| 56 | +const config = { |
| 57 | + pluginSlots: { |
| 58 | + "org.openedx.frontend.layout.studio_header_search_button_slot.v1": { |
| 59 | + keepDefault: true, |
| 60 | + plugins: [ |
| 61 | + { |
| 62 | + op: PLUGIN_OPERATIONS.Insert, |
| 63 | + widget: { |
| 64 | + priority: 10, |
| 65 | + id: 'custom_notification_tray_before', |
| 66 | + type: DIRECT_PLUGIN, |
| 67 | + RenderWidget: () => <span>🔔</span>, |
| 68 | + }, |
| 69 | + }, |
| 70 | + { |
| 71 | + op: PLUGIN_OPERATIONS.Insert, |
| 72 | + widget: { |
| 73 | + priority: 90, |
| 74 | + id: 'custom_notification_tray_after', |
| 75 | + type: DIRECT_PLUGIN, |
| 76 | + RenderWidget: () => <span>🔕</span>, |
| 77 | + }, |
| 78 | + }, |
| 79 | + ], |
| 80 | + }, |
| 81 | +}; |
| 82 | + |
| 83 | +export default config; |
| 84 | +``` |
| 85 | +
|
| 86 | +## API |
| 87 | +
|
| 88 | +- **Slot ID:** `org.openedx.frontend.layout.studio_header_search_button_slot.v1` |
| 89 | +- **Component:** Uses the [PluginSlot](https://github.com/openedx/frontend-plugin-framework#pluginslot) from the Open edX Frontend Plugin Framework for plugin injection. |
0 commit comments