Skip to content

Commit ce6527b

Browse files
committed
customize: how to change colors
1 parent 7542145 commit ce6527b

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

docs/develop/customize.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
As we just saw, overriding configured values is an easy and common way of customizing your instance to your needs. Sometimes, however, you need to provide custom files too: logos, templates... We show how to perform these custom changes.
44

5+
## Update the logo
6+
57
We are going to change the logo, take an *svg* file and update your **local** static files (You can use the [invenio color logo](https://github.com/inveniosoftware/invenio-theme/blob/master/invenio_theme/static/images/invenio-color.svg)):
68

79
``` console
@@ -25,3 +27,66 @@ Go to the browser [*https://localhost:5000/*](https://localhost:5000) or refresh
2527
If you do not see it changing, check in an incognito window; the browser might have cached the logo.
2628

2729
Need further customizations? Have you thought of creating your own extensions? How to add them to your InvenioRDM instance is explained in the next section - [here](../extensions/custom.md).
30+
31+
## Change colors
32+
33+
You might also be wondering: *How do I change the colors so I can make my instance look like my institution's theme?*
34+
35+
We are going to change the top header section in the frontpage to apply our custom background color. Open the `assets/scss/<your instance shortname>/variables.scss` file and edit it as below:
36+
37+
``` console
38+
$navbar_background_image: unset;
39+
$navbar_background_color: #000000; // Note this hex value is an example. Choose yours.
40+
```
41+
42+
Then, run the `invenio-cli update` command as above and refresh the page! You should be able to see your top header's color changed! You can find all the available variables that you can change [here](https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/assets/scss/invenio_app_rdm/variables.scss).
43+
44+
## Change search results
45+
46+
Changing how your results are presented in the search page is also something quite common.
47+
48+
We are going to update the search result template so we can show more text in the result's description. Create a file called `ResultsItemTemplate.jsx` inside `assets/templates/search` folder and then edit it as below:
49+
50+
```console
51+
import React from 'react';
52+
import {Item} from 'semantic-ui-react';
53+
import _truncate from 'lodash/truncate';
54+
55+
export function ResultsItemTemplate(record, index) {
56+
return (
57+
<Item key={index} href={`/records/${record.id}`}>
58+
<Item.Content>
59+
<Item.Header>{record.metadata.titles[0].title}</Item.Header>
60+
<Item.Description>
61+
{_truncate(record.metadata.descriptions[0].description, { length: 400 })}
62+
</Item.Description>
63+
</Item.Content>
64+
</Item>
65+
)
66+
};
67+
```
68+
69+
Then, run the `invenio-cli update` command as above and refresh the page! You should be able to see more text in each result's description! You can find all the available templates [here](https://github.com/inveniosoftware/invenio-app-rdm/tree/master/invenio_app_rdm/theme/assets/templates/search).
70+
71+
## Change the record landing page
72+
73+
When you click on a search result, you navigate in the details page of a specific record. This section shows you how to change the way the information is displayed in the details page.
74+
75+
We are going to configure our instance to use our template for displaying the information in the record's landing page. Open the `invenio.cfg` file and add the below:
76+
77+
```console
78+
from invenio_rdm_records.config import RECORDS_UI_ENDPOINTS
79+
RECORDS_UI_ENDPOINTS['recid'].update(template='my_record_landing_page.html')
80+
```
81+
82+
Then, we create a file `my_record_landing_page.html` inside the `templates` folder and edit it as below:
83+
84+
```console
85+
{%- extends 'invenio_rdm_records/record_landing_page.html' %}
86+
87+
{%- block page_body %}
88+
<!-- // Paste your code here -->
89+
{%- endblock page_body %}
90+
```
91+
92+
Inside the `page_body` block you can restructure the page as you want! You can check the default record landing page template [here](https://github.com/inveniosoftware/invenio-rdm-records/blob/master/invenio_rdm_records/theme/templates/invenio_rdm_records/record_landing_page.html).

0 commit comments

Comments
 (0)