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

conditionally load EventBrite <iframe> embed at desktop breakpoints #2

Open
thescientist13 opened this issue May 14, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers integration

Comments

@thescientist13
Copy link

Summary

As part of the EventBrite integration in AnalogStudiosRI#73 , based on a mobile / tablet breakpoint vs a >= desktop breaking, we either show a button to load a modal, or directly embed the checkout on the page. However, we are just loading both at the same no matter what, so ideally it would be great to only load the <iframe> widget code only if on a desktop browser, since we don't have want to have load a an entire <iframe> embed if we don't have to.

Details

Currently we just load both widgets, and would be good to find a way to conditionally load the

<script>
  globalThis.document.addEventListener('DOMContentLoaded', () => {
    globalThis.EBWidgets.createWidget({
      widgetType: 'checkout',
      eventId: '631211098387',
      modal: true,
      modalTriggerElementId: 'eventbrite-widget-modal-trigger-631211098387'
    });

    // TODO would be great if this could be conditionally loaded based on breakpoint
    globalThis.EBWidgets.createWidget({
       // Required
       widgetType: 'checkout',
       eventId: '631211098387',
       iframeContainerId: 'eventbrite-widget-container-631211098387',

       // Optional
       iframeContainerHeight: 700,  // Widget height in pixels. Defaults to a minimum of 425px if not provided
     });
  });
</script>

Maybe we could use a MutationObserver against the target element, which we're controlling via Tailwind breakpoint classes?

<div
  id="eventbrite-widget-container-631211098387"
  class="hidden lg:inline-block w-1/3 float-right -mt-72 mr-24"
></div>
@thescientist13 thescientist13 added enhancement New feature or request integration labels May 14, 2023
@thescientist13 thescientist13 changed the title conditionally load EventBrite embed on Desktop conditionally load EventBrite <iframe> embed at desktop breakpoints May 14, 2023
@thescientist13 thescientist13 added the good first issue Good for newcomers label May 14, 2023
@thescientist13 thescientist13 transferred this issue from AnalogStudiosRI/www.blissfestri.com Apr 11, 2024
@thescientist13
Copy link
Author

Maybe we could use some sort of resize observer to conditionally load the right integration based on breakpoint and align with Tailwind values so the styles stay in sync with the behavior of the UI.

We can load both if needed, and then only make sure it has been loaded once per.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers integration
Projects
No open projects
Status: 🔖 Ready
Development

No branches or pull requests

1 participant