Skip to content

Commit e2e549a

Browse files
committed
GH-10: Document the usage of theme variables
1 parent 24344f7 commit e2e549a

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

README.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ python -m pip install django-mermaid
1515

1616
## Configuration
1717

18-
Add the `django_mermaid.apps.MermaidConfig` to your `INSTALLED_APPS` setting:
18+
Add the `django_mermaid.apps.MermaidConfig` to your `INSTALLED_APPS` in your Django project's **settings.py** file.
1919

2020
```python
2121
INSTALLED_APPS = [
@@ -26,7 +26,8 @@ INSTALLED_APPS = [
2626

2727
## Usage
2828

29-
Once you have installed the app, you can use the `mermaid` template tag in your templates.
29+
After you configure the `INSTALLED_APPS`, you will be able to load the `mermaid` in your template and use the template
30+
tag for rendering mermaid diagrams.
3031

3132
```jinja2
3233
{% load mermaid %}
@@ -47,23 +48,37 @@ the **mermaid.min.js** file.
4748

4849
### Mermaid theme
4950

50-
You can specify the theme right in the template tag dynamically overriding the value of the `MERMAID_THEME` variable.
51+
To set a default theme for the whole project, set the `MERMAID_THEME` variable in your Django project's **settings.py**
52+
file. However, Django Mermaid uses
53+
the [default](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-default.js) theme of
54+
mermaid by default. Also, check out the mermaid [docs](https://mermaid.js.org/config/theming.html?#theme-variables) for
55+
the available themes.
56+
57+
```python
58+
MERMAID_THEME = 'neutral'
59+
```
60+
61+
Also, you can provide the theme right in the template tag which will dynamically override the value of
62+
the `MERMAID_THEME` variable.
5163

5264
```jinja2
5365
{% mermaid "graph LR; A-->B;" "dark" %}
5466
```
5567

56-
Also, you can set the `MERMAID_THEME` variable in your Django project's **settings.py** file as a default theme.
57-
However, Django Mermaid uses the
58-
[default](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-default.js) theme of
59-
mermaid by default.
68+
### Mermaid theme variables
69+
70+
You can define your custom theme by overriding the `MERMAID_THEME_VARIABLES` variable. You will need to use
71+
the [base](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-base.js) theme as it is
72+
the only modifiable theme. Check out the mermaid [docs](https://mermaid.js.org/config/theming.html?#theme-variables) for
73+
the complete and up-to-date list of available theme variables.
6074

6175
```python
62-
MERMAID_THEME = 'neutral'
76+
MERMAID_THEME_VARIABLES = {
77+
'primaryColor': '#BB2528',
78+
'primaryTextColor': '#FFF',
79+
}
6380
```
6481

65-
The available themes supported by mermaid are listed at mermaid [docs](https://mermaid.js.org/config/theming).
66-
6782
## Contribute
6883

6984
Any contribution is welcome. If you have any ideas or suggestions, feel free to open an issue or a pull request. And

0 commit comments

Comments
 (0)