Skip to content

Commit 6795147

Browse files
feat: move FooterSlot and StudioFooterSlot in from slot-footer (#521)
Co-authored-by: Muhammad Anas <[email protected]>
1 parent a87c111 commit 6795147

File tree

17 files changed

+150
-17
lines changed

17 files changed

+150
-17
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ This library has the following exports:
9595

9696
Plugin
9797
======
98-
The footer can be replaced using using `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_.
98+
The footer can be replaced or modified using `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_.
9999

100-
Information on how to utilize the ``FooterSlot`` component to do so is available in the `frontend-slot-footer repository <https://github.com/openedx/frontend-slot-footer/>`_.
100+
Information on how to replace or modify the footer is available `here </src/plugin-slots>`_.
101101

102102
Examples
103103
========

package-lock.json

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"build": "make build",
1111
"i18n_extract": "fedx-scripts formatjs extract",
1212
"lint": "fedx-scripts eslint --ext .js --ext .jsx .",
13+
"lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx .",
1314
"snapshot": "fedx-scripts jest --updateSnapshot",
1415
"start": "fedx-scripts webpack-dev-server --progress",
1516
"start:with-theme": "paragon install-theme && npm start && npm install",
@@ -55,7 +56,7 @@
5556
"@fortawesome/free-regular-svg-icons": "6.7.2",
5657
"@fortawesome/free-solid-svg-icons": "6.7.2",
5758
"@fortawesome/react-fontawesome": "0.2.2",
58-
"@openedx/frontend-plugin-framework": "^1.5.0",
59+
"@openedx/frontend-plugin-framework": "^1.7.0",
5960
"classnames": "^2.5.1",
6061
"jest-environment-jsdom": "^29.7.0",
6162
"lodash": "^4.17.21",

src/components/Footer.test.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { IntlProvider } from '@edx/frontend-platform/i18n';
77
import { AppContext } from '@edx/frontend-platform/react';
88

99
import Footer from './Footer';
10+
import FooterSlot from '../plugin-slots/FooterSlot';
1011

1112
const FooterWithContext = ({ locale = 'es' }) => {
1213
const contextValue = useMemo(() => ({
@@ -22,7 +23,7 @@ const FooterWithContext = ({ locale = 'es' }) => {
2223
<AppContext.Provider
2324
value={contextValue}
2425
>
25-
<Footer />
26+
<FooterSlot />
2627
</AppContext.Provider>
2728
</IntlProvider>
2829
);

src/components/studio-footer/StudioFooter.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import userEvent from '@testing-library/user-event';
55
import '@testing-library/jest-dom/extend-expect';
66
import { IntlProvider } from '@edx/frontend-platform/i18n';
77
import { AppContext } from '@edx/frontend-platform/react';
8-
import StudioFooter from './StudioFooter';
8+
import StudioFooterSlot from '../../plugin-slots/StudioFooterSlot';
99
import messages from './messages';
1010

1111
const config = {
@@ -36,7 +36,7 @@ const Component = ({ updateVariable }) => {
3636
return (
3737
<IntlProvider locale="en">
3838
<AppContext.Provider value={contextValue}>
39-
<StudioFooter />
39+
<StudioFooterSlot />
4040
</AppContext.Provider>
4141
</IntlProvider>
4242
);

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
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 './plugin-slots/FooterSlot';
5+
import StudioFooterSlot from './plugin-slots/StudioFooterSlot';
46

57
export default Footer;
68
export {
7-
messages, EVENT_NAMES, StudioFooter,
9+
messages, EVENT_NAMES, StudioFooter, FooterSlot, StudioFooterSlot,
810
};

src/plugin-slots/FooterSlot/README.md

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

src/plugin-slots/FooterSlot/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 '../../components/Footer';
4+
5+
const FooterSlot = () => (
6+
<PluginSlot id="org.openedx.frontend.layout.footer.v1" idAliases={['footer_slot']}>
7+
<Footer />
8+
</PluginSlot>
9+
);
10+
11+
export default FooterSlot;

0 commit comments

Comments
 (0)