Skip to content

Commit adda856

Browse files
committed
Support for external glossary
1 parent 960b5d7 commit adda856

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ npm run serve
2424
4. The Component directory must includes `Component.vue` and `Component.stories.js`
2525
5. `config.js` will automatically import all files ending in `*.stories.js`
2626

27-
## Copywriter's notes
27+
## Notes
2828

29-
This repository contains the golden source for the [Cosmos Glossary](https://cosmos.network/glossary).
29+
See below for component-specific notes.
3030

31-
Head to the [Tooltip](./src/Tooltip) component for more details.
31+
* [Tooltip](./src/Tooltip)

src/Tooltip/README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Tooltips & Glossary
22

33
## Structure
4-
File [dict.json](./dict.json) contains the source for hover tooltips and the [Cosmos Glossary](https://cosmos.network/glossary).
4+
The component presents a tooltip (title & description) based on a dictionary.
55

6-
Each item in the file has the following components:
7-
* **Identifier**: Not seen by readers, used as a lookup when defining tooltips (e.g. `application-layer`)
8-
* **Text**: Formatted in [Markdown](https://www.markdownguide.org/basic-syntax/), has a *title* and a *description*.
9-
These two are separated by a newline character `\n`.
10-
11-
## Making tooltip/glossary changes
6+
It tries to use an external Vuex dictionary (`$store.state.glossary`). If it cannot be found, it falls back to [dict.json](./dict.json).
127

13-
* Use an online Markdown editor (e.g. [LivePreview](https://markdownlivepreview.com/)).
14-
* Keep the description in a single line. Otherwise you might break auto-wrapping of text.
15-
* If you add hyperlinks, make sure they work in the preview.
16-
* Paste back into [dict.json](./dict.json) in a single line. Do not forget the separating `\n`.
17-
* Create a pull request for review.
8+
The external dictionary must have the following structure and fields:
9+
```
10+
{
11+
"lookup-key":
12+
{
13+
"title": "Application layer",
14+
"description": "Yada yada yada"
15+
}
16+
}
17+
```
18+
where `lookup-key` is the entry-specific lookup key (e.g. *application-layer*, *blockchain*), `title` and `description`
19+
are expected key names.

src/Tooltip/Tooltip.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,16 @@ export default {
9191
},
9292
computed: {
9393
definition() {
94-
return new MarkdownIt().render(dict[this.value]);
94+
var glossary = this.$store.state.glossary;
95+
if (!glossary) {
96+
return new MarkdownIt().render(dict[this.value]);
97+
} else {
98+
var slug = this.value;
99+
var title = glossary.dict[slug].title;
100+
var description = glossary.dict[slug].description;
101+
var value = '# ' + title + '\n' + description;
102+
return new MarkdownIt().render(value);
103+
}
95104
}
96105
},
97106
methods: {

0 commit comments

Comments
 (0)