-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds events page, updates convert-template script adds proper filter logic to events page, adds moment converts history page converts impact and xrpl-ledger-overview page try getting animation on impact to work converts xrp overview page and logic adds contribute page, still needs typeform integration and animations converts developer funding page adds dev tools page add missing image adds code samples py conversion to js adds hook to read current theme, adds animations to impact page adds careers animations adds correct animations for contribute page adds light mode v of animations on contribute page adds animations to uses page adds modal logos and uses modal logic completes uses page more changes Fix casing issues with use case files fix grid issue on uses
- Loading branch information
Showing
28 changed files
with
209,800 additions
and
200 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 |
---|---|---|
@@ -1,14 +1,53 @@ | ||
/** | ||
* Slugify function, has to match the formula used in interactive-tutorial.js | ||
*/ | ||
import { useEffect, useState } from 'react'; | ||
|
||
export const useThemeFromClassList = (classNames) => { | ||
const [currentTheme, setCurrentTheme] = useState(null); | ||
|
||
useEffect(() => { | ||
// Function to update the theme based on the class list | ||
const updateTheme = () => { | ||
for (const className of classNames) { | ||
if (document.documentElement.classList.contains(className)) { | ||
setCurrentTheme(className); | ||
return; | ||
} | ||
} | ||
}; | ||
|
||
// Initial update | ||
updateTheme(); | ||
|
||
// Create an observer instance linked to the callback function | ||
const observer = new MutationObserver(() => { | ||
updateTheme(); | ||
}); | ||
|
||
// Start observing the target node for configured mutations | ||
observer.observe(document.documentElement, { | ||
attributes: true, // Listen for attribute changes | ||
attributeFilter: ['class'], // Specifically, listen only to "class" attribute changes | ||
}); | ||
|
||
// Cleanup: Disconnect the observer | ||
return () => { | ||
observer.disconnect(); | ||
}; | ||
}, [classNames]); | ||
|
||
return currentTheme; | ||
}; | ||
|
||
export function slugify(s) { | ||
const unacceptable_chars = /[^A-Za-z0-9._ ]+/g; | ||
const whitespace_regex = /\s+/g; | ||
s = s.replace(unacceptable_chars, ''); | ||
s = s.replace(whitespace_regex, '_'); | ||
s = s.replace(unacceptable_chars, ""); | ||
s = s.replace(whitespace_regex, "_"); | ||
s = s.toLowerCase(); | ||
if (!s) { | ||
s = '_'; | ||
s = "_"; | ||
} | ||
return s; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.