Skip to content

Commit

Permalink
Make 'term in tooltip header' optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuess committed Oct 25, 2024
1 parent f734a75 commit c7724ce
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,17 @@ config.settings.glossary.matchOnlyFirstOccurence = true;

User can opt-out by setting glossarytooltips to false.
Add a boolean member field *glossarytooltips* for it.

## Further configurations

Hide alphabet navigation of glossary view:

```js
config.settings.glossary.showAlphabetNavigation = false;
```

Show glossary term in tooltips header:

```js
config.settings.glossary.mentionTermInTooltip = true;
```
1 change: 1 addition & 0 deletions packages/policy/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const applyConfig = (config) => {
config.settings.glossary.caseSensitive = false;
config.settings.glossary.matchOnlyFirstOccurence = false;
config.settings.glossary.showAlphabetNavigation = true;
config.settings.glossary.mentionTermInTooltip = false;

// Tooltips everywhere
config.settings.appExtras = [
Expand Down
4 changes: 1 addition & 3 deletions packages/volto-slate-glossary/news/12.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Show a header in the tooltip.
This repeats the term, which can look nice.
@mauritsvanrees
Mention the term in the header of its tooltip. @mauritsvanrees, @ksuess
8 changes: 5 additions & 3 deletions packages/volto-slate-glossary/src/components/Tooltips.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export const applyLineBreakSupport = (children) => {
*/
export const enhanceTextWithTooltips = (text, remainingGlossaryterms) => {
const caseSensitive = config.settings.glossary.caseSensitive;
const matchOnlyFirstOccurence =
config.settings.glossary.matchOnlyFirstOccurence;
const { matchOnlyFirstOccurence, mentionTermInTooltip } =
config.settings.glossary;
let result = [{ type: 'text', val: text }];
let matchedGlossaryTerms = [];
if (remainingGlossaryterms.length > 0) {
Expand Down Expand Up @@ -190,7 +190,9 @@ export const enhanceTextWithTooltips = (text, remainingGlossaryterms) => {
key={j}
className="tooltip"
>
<Popup.Header>{el.val}</Popup.Header>
{mentionTermInTooltip ? (
<Popup.Header>{el.val}</Popup.Header>
) : null}
<Popup.Content>
<div
className="tooltip_content"
Expand Down
1 change: 1 addition & 0 deletions packages/volto-slate-glossary/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const applyConfig = (config) => {
caseSensitive: false,
matchOnlyFirstOccurence: false,
showAlphabetNavigation: true,
mentionTermInTooltip: false,
};

config.settings.slate.leafs = {
Expand Down

0 comments on commit c7724ce

Please sign in to comment.