Skip to content

Commit a7c1600

Browse files
committed
feat: Add slot for whole application
Adds a slot wrapping the entire application.
1 parent fe36e65 commit a7c1600

File tree

4 files changed

+64
-6
lines changed

4 files changed

+64
-6
lines changed

src/index.jsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {
22
APP_INIT_ERROR, APP_READY, subscribe, initialize, mergeConfig, getConfig, getPath,
33
} from '@edx/frontend-platform';
44
import { AppProvider, ErrorPage } from '@edx/frontend-platform/react';
5+
import { PluginSlot } from '@openedx/frontend-plugin-framework';
6+
import { AuthoringAppSlot } from "CourseAuthoring/plugin-slots/AuthoringAppSlot";
57
import React, { StrictMode, useEffect } from 'react';
68
import { createRoot } from 'react-dom/client';
79
import {
@@ -97,12 +99,14 @@ const App = () => {
9799

98100
return (
99101
<AppProvider store={initializeStore()} wrapWithRouter={false}>
100-
<ToastProvider>
101-
<QueryClientProvider client={queryClient}>
102-
<Head />
103-
<RouterProvider router={router} />
104-
</QueryClientProvider>
105-
</ToastProvider>
102+
<AuthoringAppSlot>
103+
<ToastProvider>
104+
<QueryClientProvider client={queryClient}>
105+
<Head />
106+
<RouterProvider router={router} />
107+
</QueryClientProvider>
108+
</ToastProvider>
109+
</AuthoringAppSlot>
106110
</AppProvider>
107111
);
108112
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# AuthoringAppSlot
2+
3+
### Slot ID: `authoring_app_slot`
4+
5+
### Plugin Props:
6+
7+
NONE
8+
9+
## Description
10+
11+
The slot wraps the entire application. It can be used to add content before or
12+
after the application (such as cookie banners) or to wrap the entire
13+
application in a component. One possible use case of that is to wrap the entire
14+
application in a context manager that would allow communication between
15+
different slots injected on the page.
16+
17+
## Example
18+
19+
![Screenshot of the entire app surrounded by border](./images/app_wrapped_in_border.png)
20+
21+
The following example configuration inserts an extra button to the header as shown above.
22+
23+
```js
24+
import { PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
25+
26+
const config = {
27+
pluginSlots: {
28+
authoring_app_slot: {
29+
keepDefault: true,
30+
plugins: [
31+
{
32+
op: PLUGIN_OPERATIONS.Wrap,
33+
widgetId: 'default_contents',
34+
wrapper: ({ component }) => (
35+
<div style={{ border: 'thick dashed red' }}>{component}</div>
36+
),
37+
},
38+
],
39+
},
40+
}
41+
};
42+
export default config;
43+
```
119 KB
Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { PluginSlot } from '@openedx/frontend-plugin-framework';
2+
3+
export const AuthoringAppSlot = ({ children }:AuthoringAppSlotProps) => (
4+
<PluginSlot id="authoring_app_slot">
5+
{children}
6+
</PluginSlot>
7+
);
8+
9+
interface AuthoringAppSlotProps {
10+
children: React.ReactNode;
11+
}

0 commit comments

Comments
 (0)