Skip to content

Commit 0d4ea96

Browse files
brian-smith-tcrilarbrandes
authored andcommitted
feat: provide FooterSlot
This allows consuming MFEs to utilize a standardized Frontend Plugin Framework `PluginSlot` for replacing the footer.
1 parent 8b9f5fa commit 0d4ea96

File tree

8 files changed

+138
-1
lines changed

8 files changed

+138
-1
lines changed

README.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ This library has the following exports:
8585
* ``(default)``: The footer as a React component.
8686
* ``messages``: Internationalization messages suitable for use with `@edx/frontend-platform/i18n <https://edx.github.io/frontend-platform/module-Internationalization.html>`_
8787
* ``dist/footer.scss``: A SASS file which contains style information for the component. It should be imported into the micro-frontend's own SCSS file.
88+
* ``FooterSlot``: The footer wrapped in a `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_ ``PluginSlot``.
8889

8990
<Footer /> component props
9091
==========================
@@ -93,6 +94,12 @@ This library has the following exports:
9394
language from its dropdown.
9495
* supportedLanguages: An array of objects representing available languages. See example below for object shape.
9596

97+
Plugin
98+
======
99+
This package provides a wrapped version of the footer using `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_.
100+
101+
Information on how to utilize the ``FooterSlot`` is available `here </src/components/footer-slot>`_.
102+
96103
Examples
97104
========
98105

@@ -113,6 +120,8 @@ Component Usage Example::
113120
* `An example of minimal component and messages usage. <https://github.com/openedx/frontend-template-application/blob/3355bb3a96232390e9056f35b06ffa8f105ed7ca/src/index.jsx#L23>`_
114121
* `An example of SCSS file usage. <https://github.com/openedx/frontend-template-application/blob/3cd5485bf387b8c479baf6b02bf59e3061dc3465/src/index.scss#L9>`_
115122

123+
124+
116125
Development
117126
===========
118127

package-lock.json

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@edx/frontend-platform": "8.0.1",
4040
"@edx/reactifex": "^2.1.1",
4141
"@openedx/frontend-build": "14.0.3",
42+
"@openedx/frontend-plugin-framework": "^1.1.2",
4243
"@openedx/paragon": "22.3.2",
4344
"@testing-library/jest-dom": "^5.16.4",
4445
"@testing-library/react": "^12.1.1",
@@ -64,9 +65,15 @@
6465
},
6566
"peerDependencies": {
6667
"@edx/frontend-platform": "^7.0.0 || ^8.0.0",
68+
"@openedx/frontend-plugin-framework": "^1.1.2",
6769
"@openedx/paragon": ">= 21.11.3 < 23.0.0",
6870
"prop-types": "^15.5.10",
6971
"react": "^16.9.0 || ^17.0.0",
7072
"react-dom": "^16.9.0 || ^17.0.0"
73+
},
74+
"peerDependenciesMeta": {
75+
"@openedx/frontend-plugin-framework": {
76+
"optional": true
77+
}
7178
}
7279
}

src/components/footer-slot/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Footer Slot
2+
3+
### Slot ID: `footer_slot`
4+
5+
## Description
6+
7+
This slot is used to replace/modify/hide the footer.
8+
9+
## Example
10+
11+
The following `env.config.jsx` will replace the default footer.
12+
13+
![Screenshot of Default Footer](./images/default_footer.png)
14+
15+
with a simple custom footer
16+
17+
![Screenshot of Custom Footer](./images/custom_footer.png)
18+
19+
```js
20+
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
21+
22+
const config = {
23+
pluginSlots: {
24+
footer_slot: {
25+
plugins: [
26+
{
27+
// Hide the default footer
28+
op: PLUGIN_OPERATIONS.Hide,
29+
widgetId: 'default_contents',
30+
},
31+
{
32+
// Insert a custom footer
33+
op: PLUGIN_OPERATIONS.Insert,
34+
widget: {
35+
id: 'custom_footer',
36+
type: DIRECT_PLUGIN,
37+
RenderWidget: () => (
38+
<h1 style={{textAlign: 'center'}}>🦶</h1>
39+
),
40+
},
41+
},
42+
]
43+
}
44+
},
45+
}
46+
47+
export default config;
48+
```
6.25 KB
Loading
6.52 KB
Loading

src/components/footer-slot/index.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
import { PluginSlot } from '@openedx/frontend-plugin-framework';
3+
import Footer from '../Footer';
4+
5+
const FooterSlot = () => (
6+
<PluginSlot id="footer_slot">
7+
<Footer />
8+
</PluginSlot>
9+
);
10+
11+
export default FooterSlot;

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import Footer, { EVENT_NAMES } from './components/Footer';
22
import messages from './i18n/index';
33
import StudioFooter from './components/studio-footer';
4+
import FooterSlot from './components/footer-slot';
45

56
export default Footer;
6-
export { messages, EVENT_NAMES, StudioFooter };
7+
export {
8+
messages, EVENT_NAMES, StudioFooter, FooterSlot,
9+
};

0 commit comments

Comments
 (0)