Skip to content

Commit

Permalink
docs: update usage example and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoa committed Jan 13, 2025
1 parent f6d340b commit 421716e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
11 changes: 6 additions & 5 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ CREDENTIALS_BASE_URL=http://localhost:18150
CSRF_TOKEN_API_PATH=/csrf/api/v1/token
ECOMMERCE_BASE_URL=http://localhost:18130
LANGUAGE_PREFERENCE_COOKIE_NAME=openedx-language-preference
LMS_BASE_URL=http://localhost:18000
LOGIN_URL=http://localhost:18000/login
LOGOUT_URL=http://localhost:18000/login
MARKETING_SITE_BASE_URL=http://localhost:18000
LMS_BASE_URL=http://local.openedx.io:8000
LOGIN_URL=http://local.openedx.io:8000/login
LOGOUT_URL=http://local.openedx.io:8000/login
MARKETING_SITE_BASE_URL=http://local.openedx.io:8000
TERMS_OF_SERVICE_URL=null
PRIVACY_POLICY_URL=null
SUPPORT_EMAIL=null
STUDIO_BASE_URL=http://localhost:18010
ENABLE_ACCESSIBILITY_PAGE=false
ORDER_HISTORY_URL=localhost:1996/orders
REFRESH_ACCESS_TOKEN_ENDPOINT=http://localhost:18000/login_refresh
REFRESH_ACCESS_TOKEN_ENDPOINT=http://local.openedx.io:8000/login_refresh
SEGMENT_KEY=null
SITE_NAME=Open edX
USER_INFO_COOKIE_NAME=edx-user-info
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
ENABLE_FOOTER_LANG_SELECTOR=true
25 changes: 13 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,19 @@ This library has the following exports:
* ``messages``: Internationalization messages suitable for use with `@edx/frontend-platform/i18n <https://edx.github.io/frontend-platform/module-Internationalization.html>`_
* ``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.

<Footer /> component props
==========================
Language Selector
-----------------

* onLanguageSelected: Provides the footer with an event handler for when the user selects a
language from its dropdown.
* supportedLanguages: An array of objects representing available languages. See example below for object shape.
The language selector dropdown is optional and can be enabled by setting the MFE configuration variable ``ENABLE_FOOTER_LANG_SELECTOR`` to ``true``.
Secondly, configue the languages that should be displayed in the dropdown by setting the MFE configuration variable ``SITE_SUPPORTED_LANGUAGES`` to an array of locale languages.
Example:

.. code-block:: python
MFE_CONFIG["EDX_FRONTEND_APP_CONFIG"] = {
"ENABLE_FOOTER_LANG_SELECTOR": True,
"SITE_SUPPORTED_LANGUAGES": ['en', 'es', 'fr', 'pt-br'],
}
Plugin
======
Expand All @@ -108,13 +115,7 @@ Component Usage Example::

...

<Footer
onLanguageSelected={(languageCode) => {/* set language */}}
supportedLanguages={[
{ label: 'English', value: 'en'},
{ label: 'Español', value: 'es' },
]}
/>
<Footer />

* `An example of minimal component and messages usage. <https://github.com/openedx/frontend-template-application/blob/3355bb3a96232390e9056f35b06ffa8f105ed7ca/src/index.jsx#L23>`_
* `An example of SCSS file usage. <https://github.com/openedx/frontend-template-application/blob/3cd5485bf387b8c479baf6b02bf59e3061dc3465/src/index.scss#L9>`_
Expand Down
7 changes: 7 additions & 0 deletions env.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file is used only for the example application.
const config = {
ENABLE_FOOTER_LANG_SELECTOR: true,
SITE_SUPPORTED_LANGUAGES: ['es', 'en'],
};

export default config;
8 changes: 1 addition & 7 deletions example/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ subscribe(APP_READY, () => {
authenticatedUser: null,
config: getConfig(),
}}>
<Footer
onLanguageSelected={() => {}}
supportedLanguages={[
{ label: 'English', value: 'en' },
{ label: 'Español', value: 'es' },
]}
/>
<Footer />
</AppContext.Provider>
</AppProvider>,
document.getElementById('root'),
Expand Down
4 changes: 3 additions & 1 deletion webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const path = require('path');
const { createConfig } = require('@openedx/frontend-build');

module.exports = createConfig('webpack-dev', {
entry: path.resolve(__dirname, 'example'),
entry: {
app: path.resolve(__dirname, 'example'),
},
output: {
path: path.resolve(__dirname, 'example/dist'),
publicPath: '/',
Expand Down

0 comments on commit 421716e

Please sign in to comment.