You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/how_tos/theming.md
+58-12
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,9 @@
2
2
3
3
## Overview
4
4
5
-
This document serves as a guide to using `@openedx/frontend-platform` to support MFE theming with Paragon using theme CSS loaded externally (e.g., from a CDN).
5
+
This document is a guide for using `@openedx/frontend-platform` to support MFE theming with Paragon loading the theme CSS externally (e.g., from a CDN).
6
6
7
-
To do this, configured URLs pointing to relevant CSS files from `@openedx/paragon` and (optionally) `@openedx/brand-openedx` are loaded and injected to the HTML document at runtime. This differs than the consuming application importing the styles from `@openedx/paragon` and `@openedx/brand-openedx` directly, which includes these styles in the application's production assets.
7
+
To do this, configured URLs pointing to relevant CSS files from `@openedx/paragon` and (optionally) `@openedx/brand-openedx` are loaded and injected to the HTML document at runtime. This differs from importing the styles from `@openedx/paragon` and `@openedx/brand-openedx` directly, which includes these styles in the application's production assets.
8
8
9
9
By serving CSS loaded externally, consuming applications of Paragon no longer need to be responsible for compiling the theme SCSS to CSS themselves and instead use a pre-compiled CSS file. In doing so, this allows making changes to the Paragon theme without needing to necessarily re-build and re-deploy all consuming applications.
10
10
@@ -14,13 +14,13 @@ By serving CSS loaded externally, consuming applications of Paragon no longer ne
14
14
15
15
1.**Get theme preference from localStorage.** Supports persisting and loading the user's preference for their selected theme variant, until cleared.
16
16
1.**Detect user system settings.** Rely on the `prefers-color-scheme` media query to detect if the user's system indicates a preference for dark mode. If so, use the default dark theme variant, if one is configured.
17
-
1.**Use default theme variant as configured (see below).** Otherwise, load the default theme variant as configured by the `defaults` option described below.
17
+
1.**Use the default theme variant as configured (see below).** Otherwise, load the default theme variant as configured by the `defaults` option described below.
18
18
19
-
Whenever the current theme variant changes, an attrivbute`data-paragon-theme-variant="*"` is updated on the `<html>` element. This attribute enables applications' both JS and CSS to have knowledge of the currently applied theme variant.
19
+
Whenever the current theme variant changes, an attribute`data-paragon-theme-variant="*"` is updated on the `<html>` element. This attribute enables applications both JS and CSS to have knowledge of the currently applied theme variant.
20
20
21
21
### Supporting custom theme variants beyond `light` and `dark`
22
22
23
-
If your use case necessitates additional variants beyond the default supported `light` and `dark` theme variants, you may pass any number of custom theme variants. Custom theme variants will work the user's persisted localStorage setting (i.e., if a user switches to a custom theme variant, the MFE will continue to load the custom theme variant by default). By supporting custom theme variants, it also supports having multiple or alternative `light` and/or `dark` theme variants.
23
+
If your use case requires additional variants beyond the default `light` and `dark` theme variants, you may pass any number of custom theme variants. Custom theme variants will work the user's persisted localStorage setting (i.e., if a user switches to a custom theme variant, the MFE will continue to load the custom theme variant by default). By supporting custom theme variants, it also supports having multiple or alternative `light` and/or `dark` theme variants. You can see the [Configuration options](#configuration-options) example for better understanding.
24
24
25
25
### Performance implications
26
26
@@ -90,6 +90,52 @@ The `dark` theme variant options are optional.
90
90
|`variants.dark.urls.default`| String | URL for the `dark.css` file from `@openedx/paragon`. |
91
91
|`variants.dark.urls.brandOverride`| String | URL for the `dark.css` file from `@openedx/brand-openedx`. |
92
92
93
+
Understanding the different configuration options, a complex use case:
One approach to configuring the `PARAGON_THEME_URLS` is to create a `env.config.js` file in the root of the repository. The configuration is defined as a JavaScript file, which affords consumers to use more complex data types, amongst other benefits.
@@ -145,7 +191,7 @@ MFE_CONFIG_OVERRIDES = {
145
191
}
146
192
```
147
193
148
-
### Locally installed `@openedx/paragon`
194
+
### Reference the locally installed `@openedx/paragon` version
149
195
150
196
If you would like to use the same version of the Paragon CSS urls as the locally installed `@openedx/paragon`, the configuration for the Paragon CSS urls may contain a wildcard `$paragonVersion` which gets replaced with the locally installed version of `@openedx/paragon` in the consuming application, e.g.:
151
197
@@ -158,9 +204,9 @@ In the event the other Paragon CSS urls are configured via one of the other docu
158
204
159
205
## Usage with `@openedx/brand-openedx`
160
206
161
-
The core Paragon design tokens and styles may be optionally overriden by utilizing `@openedx/brand-openedx`, which allows theme authors to customize the default Paragon theme to match the look and feel of their custom brand.
207
+
The core Paragon design tokens and styles may be optionally overridden by utilizing `@openedx/brand-openedx`, which allows theme authors to customize the default Paragon theme to match the look and feel of their custom brand.
162
208
163
-
This override mechanism works by compiling the design tokens defined in `@openedx/brand-openedx` 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.
209
+
This override mechanism works by compiling the design tokens defined in `@openedx/brand-openedx` with 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.
164
210
165
211
The CSS urls for `@openedx/brand-openedx` overrides will be applied after the core Paragon theme urls load, thus overriding any previously set CSS variables and/or styles.
### Reference the locally installed `@openedx/brand-openedx` version
196
242
197
-
If you would like to use the same version of the brand override CSS urls as the locally installed `@openedx/brand-openedx`, the configuration for the brand override CSS urls may contain a wildcard `$brandVersion` which gets replaced with the locally installed version of `@openedx/brand-openedx` in the consuming application, e.g.:
243
+
If you would like to use the same version of the brand overrides CSS urls as the locally installed `@openedx/brand-openedx`, the configuration for the brand override CSS urls may contain a wildcard `$brandVersion` which gets replaced with the locally installed version of `@openedx/brand-openedx` in the consuming application, e.g.:
0 commit comments