Skip to content

Commit 48dad9f

Browse files
adamstankiewiczdcoa
authored andcommitted
fix: brand overrides
docs: fix code example docs: add missing comma docs: update how to
1 parent b1551a5 commit 48dad9f

File tree

2 files changed

+314
-138
lines changed

2 files changed

+314
-138
lines changed

docs/how_tos/theming.md

Lines changed: 78 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@ This document serves as a guide to using `@edx/frontend-platform` to support MFE
66

77
![overview of paragon theme loader](./assets/paragon-theme-loader.png "Paragon theme loader")
88

9-
## Theme URL configuration
9+
## Basic theme URL configuration
1010

11-
Paragon supports 2 mechanisms for configuring the Paragon theme URLs:
11+
Paragon supports 2 mechanisms for configuring the Paragon theme urls:
1212
* JavaScript-based configuration via `env.config.js`.
1313
* MFE runtime configuration API via `edx-platform`
1414

1515
Using either configuration mechanism, a `PARAGON_THEME_URLS` configuration setting must be created to point to the externally hosted Paragon theme CSS files, e.g.:
1616

1717
```json
1818
{
19-
"core": "https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/core.css",
19+
"core": {
20+
"url": "https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/core.min.css"
21+
},
2022
"variants": {
21-
"light": "https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/light.css"
23+
"light": {
24+
"url": "https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/light.min.css",
25+
"default": true,
26+
"dark": false,
27+
}
2228
}
2329
}
2430
```
@@ -32,16 +38,22 @@ To use this JavaScript-based configuration approach, you may set a `PARAGON_THEM
3238
```js
3339
const config = {
3440
PARAGON_THEME_URLS: {
35-
core: 'https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/paragon.css',
41+
core: {
42+
url: 'https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/core.min.css',
43+
},
3644
variants: {
37-
light: 'https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/scss/core/css/variables.css',
45+
light: {
46+
url: 'https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/light.min.css',
47+
default: true,
48+
dark: false,
49+
},
3850
},
3951
},
4052
};
53+
4154
export default config;
4255
```
4356

44-
4557
### MFE runtime configuration API
4658

4759
`@edx/frontend-platform` additionally supports loading application configuration from the MFE runtime configuration API via `edx-platform`. The configuration is served by the `http://localhost:18000/api/mfe_config/v1` API endpoint. For more information, refer to [this documentation](https://github.com/openedx/edx-platform/blob/master/lms/djangoapps/mfe_config_api/docs/decisions/0001-mfe-config-api.rst) about the MFE runtime configuration API, please see these docs.
@@ -52,12 +64,18 @@ The application configuration may be setup via Django settings as follows:
5264
ENABLE_MFE_CONFIG_API = True
5365
MFE_CONFIG = {}
5466
MFE_CONFIG_OVERRIDES = {
55-
# `APP_ID` defined in your MFE
67+
# The below key represented the `APP_ID` defined in your MFE
5668
'profile': {
5769
'PARAGON_THEME_URLS': {
58-
'core': 'https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/core.css',
70+
'core': {
71+
'url': 'https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/core.min.css',
72+
},
5973
'variants': {
60-
'light': 'https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/light.css',
74+
'light': {
75+
'url': 'https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/light.min.css',
76+
'default': True,
77+
'dark': False,
78+
},
6179
},
6280
},
6381
},
@@ -66,11 +84,57 @@ MFE_CONFIG_OVERRIDES = {
6684

6785
### Locally installed `@edx/paragon`
6886

69-
In the event the other Paragon CSS URLs are configured via one of the other documented mechanisms, but they fail to load (e.g., the CDN url throws a 404), `@edx/frontend-platform` will fallback to injecting the locally installed Paragon CSS from the consuming application into the HTML document.
87+
If you would like to use the same version of the Paragon CSS urls as the locally installed `@edx/paragon`, the configuration for the Paragon CSS urls may contain a wildcard `$paragonVersion` which gets replaced with the locally installed version of `@edx/paragon` in the consuming application, e.g.:
88+
89+
```shell
90+
https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/core.min.css
91+
https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/light.min.css
92+
```
93+
94+
In the event the other Paragon CSS urls are configured via one of the other documented mechanisms, but they fail to load (e.g., the CDN url throws a 404), `@edx/frontend-platform` will attempt to fallback to injecting the locally installed Paragon CSS from the consuming application into the HTML document.
95+
96+
## Usage with `@edx/brand`
97+
98+
The core Paragon design tokens and styles may be optionally overriden by utilizing `@edx/brand`, which allows theme authors to customize the default Paragon theme to match the look and feel of their custom brand.
7099

71-
If you would like to use the same version of the Paragon CSS URLs as the locally installed `@edx/paragon`, the configuration for the Paragon CSS URLs may contain a wildcard `$paragonVersion` which gets replaced with the locally installed version of `@edx/paragon` in the consuming application, e.g.:
100+
This override mechanism works by compiling the design tokens defined in `@edx/brand` with the the core Paragon tokens to generate overrides to Paragon's default CSS variables, and then compiling the output CSS with any SCSS theme customizations not possible through a design token override.
101+
102+
The CSS urls for `@edx/brand` overrides will be applied after the core Paragon theme urls load, thus overriding any previously set CSS variables and/or styles.
103+
104+
To enable `@edx/brand` overrides, the `PARAGON_THEME_URLS` setting may be configured as following:
105+
106+
```js
107+
const config = {
108+
PARAGON_THEME_URLS: {
109+
core: {
110+
urls: {
111+
default: 'https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/core.min.css',
112+
brandOverride: 'https://cdn.jsdelivr.net/npm/@edx/brand-edx.org@#brandVersion/dist/core.min.css',
113+
},
114+
},
115+
variants: {
116+
light: {
117+
urls: {
118+
default: 'https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/light.min.css',
119+
brandOverride: 'https://cdn.jsdelivr.net/npm/@edx/brand-edx.org@$brandVersion/dist/light.min.css',
120+
},
121+
default: true,
122+
dark: false,
123+
},
124+
},
125+
},
126+
};
127+
128+
export default config;
129+
```
130+
131+
### Locally installed `@edx/brand`
132+
133+
If you would like to use the same version of the brand override CSS urls as the locally installed `@edx/brand`, the configuration for the brand override CSS urls may contain a wildcard `$brandVersion` which gets replaced with the locally installed version of `@edx/brand` in the consuming application, e.g.:
72134

73135
```shell
74-
https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/dist/core.css
75-
https://cdn.jsdelivr.net/npm/@edx/paragon@$paragonVersion/scss/core/css/variables.css
136+
https://cdn.jsdelivr.net/npm/@edx/brand@$brandVersion/dist/core.min.css
137+
https://cdn.jsdelivr.net/npm/@edx/brand@$brandVersion/dist/light.min.css
76138
```
139+
140+
In the event the other brand override CSS urls are configured via one of the other documented mechanisms, but they fail to load (e.g., the CDN is down), `@edx/frontend-platform` will attempt to fallback to injecting the locally installed brand override CSS urls from the consuming application into the HTML document.

0 commit comments

Comments
 (0)