Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function initialize changes for language switcher, modal, accordian, biocard and modal #1509

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

mihir880
Copy link

@mihir880 mihir880 commented Mar 3, 2025

No description provided.

@mihir880 mihir880 requested a review from Jura March 3, 2025 18:57
@Jura Jura requested a review from Copilot March 3, 2025 21:18
Copy link

cloudflare-workers-and-pages bot commented Mar 3, 2025

Deploying design-system with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9ec1954
Status: ✅  Deploy successful!
Preview URL: https://7dfedffd.design-system.pages.dev
Branch Preview URL: https://1499-optimize-js-loading.design-system.pages.dev

View logs

@@ -9,7 +9,7 @@ export const Accordion = ({ headerText, descriptionText }) => {
// }, []);

return (
<ul className="accordion" aria-label="accordion" data-component="accordion">
<ul className="accordion" aria-label="accordion" data-undps-component="accordion">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mihir880 , it has to be data-undpds- prefix (as in UNDP Design System) so it will be mnemonic

if (typeof window.UNDP?.langSwitch === 'function') {
window.UNDP.langSwitch();
} else {
// if (typeof window.UNDP?.langSwitch === 'function') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mihir880 , your original idea was great - to check if the module is already loaded and use it that way, opting for load dynamically only if the function is not present. I'd rather keep it that way to make script more versatile. The only issue you have to resolve is changing window.UNDP.functionName in the condition to simply functionName as it is defined in the global scope if loaded as a separate script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants