-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix accordion block. Prepare for description block and teaser block. …
…Make TooltipPopup customizable via component registry.
- Loading branch information
Showing
5 changed files
with
173 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Optionally show tooltips in accordion block panel. Default is false. @ksuess | ||
Prepare for tooltips in description block. Add intructions to README. @ksuess | ||
Prepare for tooltips in teaser block. Add intructions to README. @ksuess | ||
Make TooltipPopup customizable via component registry. @ksuess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,17 @@ export const tooltippedTextsAtom = atom({ pathname: undefined, texts: [] }); | |
|
||
export const MY_NAMESPACE = '4549d0a3-5fc2-4a94-bf96-eb7ddf5363a4'; | ||
|
||
/** | ||
* TextWithGlossaryTooltips | ||
* | ||
* returns enhanced markup from Jotai store if | ||
* - location should show tooltips | ||
* - current user has not opted out | ||
* - page is in view mode | ||
* | ||
* @param {String} text | ||
* @returns String | ||
*/ | ||
export const TextWithGlossaryTooltips = ({ text }) => { | ||
const location = useSelector((state) => state.router?.location); | ||
const pathname = location?.pathname; | ||
|
@@ -40,16 +51,16 @@ export const TextWithGlossaryTooltips = ({ text }) => { | |
return text; | ||
} | ||
|
||
let uid; | ||
try { | ||
uuidv5(text, MY_NAMESPACE); | ||
uid = uuidv5(text, MY_NAMESPACE); | ||
} catch (error) { | ||
// "RangeError: offset is out of bounds" | ||
// generateUUID | ||
// node_modules/.pnpm/[email protected]/node_modules/uuid/dist/esm-browser/v35.js:36 | ||
// console.error(error); | ||
return text; | ||
} | ||
let uid = uuidv5(text, MY_NAMESPACE); | ||
// No match in store if this location is not configured for tooltips. Return text unchanged. | ||
const newText = Object.keys(tooltippedTexts?.texts).includes(uid) | ||
? tooltippedTexts.texts[uid] | ||
|