Migrate marketing pages to Redocly

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
This commit is contained in:
akcodez
2023-10-11 18:06:42 -07:00
committed by mDuo13
parent 65106dd0b5
commit ec28d8fee8
28 changed files with 209800 additions and 200 deletions

View File

@@ -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;
}