Skip to content

Commit 1eb47c7

Browse files
xitij2000farhaanbukhsh
authored andcommitted
feat: Add slot for whole application
Adds a slot wrapping the entire application.
1 parent a43027b commit 1eb47c7

File tree

4 files changed

+64
-6
lines changed

4 files changed

+64
-6
lines changed

src/index.jsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ 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 { AuthoringAppSlot } from 'CourseAuthoring/plugin-slots/AuthoringAppSlot';
56
import React, { StrictMode, useEffect } from 'react';
67
import { createRoot } from 'react-dom/client';
78
import {
@@ -97,12 +98,14 @@ const App = () => {
9798

9899
return (
99100
<AppProvider store={initializeStore()} wrapWithRouter={false}>
100-
<ToastProvider>
101-
<QueryClientProvider client={queryClient}>
102-
<Head />
103-
<RouterProvider router={router} />
104-
</QueryClientProvider>
105-
</ToastProvider>
101+
<AuthoringAppSlot>
102+
<ToastProvider>
103+
<QueryClientProvider client={queryClient}>
104+
<Head />
105+
<RouterProvider router={router} />
106+
</QueryClientProvider>
107+
</ToastProvider>
108+
</AuthoringAppSlot>
106109
</AppProvider>
107110
);
108111
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 wraps the entire app in a dashed border as
22+
shown above.
23+
24+
```js
25+
import { PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
26+
27+
const config = {
28+
pluginSlots: {
29+
authoring_app_slot: {
30+
keepDefault: true,
31+
plugins: [
32+
{
33+
op: PLUGIN_OPERATIONS.Wrap,
34+
widgetId: 'default_contents',
35+
wrapper: ({ component }) => (
36+
<div style={{ border: 'thick dashed red' }}>{component}</div>
37+
),
38+
},
39+
],
40+
},
41+
}
42+
};
43+
export default config;
44+
```
Loading
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)