Skip to content

Add Luma embed for Community Day events & facade iframes #38845

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

Merged
merged 14 commits into from
May 1, 2025

Conversation

mrdarrengriffin
Copy link
Contributor

@mrdarrengriffin mrdarrengriffin commented May 1, 2025

Proposed change

This PR adds add the Luma iframe to allow for registering for events within the blog.

This PR also adds the initial iframe facade logic to defer iframes from loading until user interaction for performance reasons. This does not include any breaking changes but requires an iframe to use data-src which will then be replaced with src upon interaction. This will eventually replace lite-youtube in a future PR

Before:
image

After:
image

Type of change

  • Spelling, grammar or other readability improvements (current branch).
  • Adjusted missing or incorrect information in the current documentation (current branch).
  • Added documentation for a new integration I'm adding to Home Assistant (next branch).
  • Added documentation for a new feature I'm adding to Home Assistant (next branch).
  • Removed stale or deprecated documentation.

Additional information

  • Link to parent pull request in the codebase:
  • Link to parent pull request in the Brands repository:
  • This PR fixes or closes issue: fixes #

Checklist

  • This PR uses the correct branch, based on one of the following:
    • I made a change to the existing documentation and used the current branch.
    • I made a change that is related to an upcoming version of Home Assistant and used the next branch.
  • The documentation follows the Home Assistant documentation standards.

Summary by CodeRabbit

  • New Features

    • Embedded an interactive calendar for Community Day events, allowing users to view up-to-date event details directly on the page.
  • Improvements

    • Implemented lazy loading for embedded iframes, improving page load performance by loading iframe content only upon user interaction.
  • Content Updates

    • Updated event information to direct users to the interactive calendar and Luma website for the latest details, replacing the previous static event list.

@home-assistant home-assistant bot added the current This PR goes into the current branch label May 1, 2025
@mrdarrengriffin mrdarrengriffin marked this pull request as draft May 1, 2025 14:33
Copy link

netlify bot commented May 1, 2025

Deploy Preview for home-assistant-docs ready!

Name Link
🔨 Latest commit 50b8502
🔍 Latest deploy log https://app.netlify.com/sites/home-assistant-docs/deploys/6813df5c61fc210008e2dad0
😎 Deploy Preview https://deploy-preview-38845--home-assistant-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@frenck
Copy link
Member

frenck commented May 1, 2025

Does this require us to set up an consent for European visitors now?

../Frenck

@mrdarrengriffin
Copy link
Contributor Author

mrdarrengriffin commented May 1, 2025

Why would it require consent? It doesn't use cookies

@frenck
Copy link
Member

frenck commented May 1, 2025

Why would it require consent? It doesn't use cookies

That was the question. If it doesn't I guess it is fine 👍
We need to be compliant with GDPR and make sure we are still compliant once you add this.

../Frenck

@mrdarrengriffin
Copy link
Contributor Author

Sorry, I misread. My bad!

It just waits for a scroll, touch or mouse move before loading any iframes in.

@mrdarrengriffin mrdarrengriffin requested a review from balloob May 1, 2025 16:34
@mrdarrengriffin mrdarrengriffin marked this pull request as ready for review May 1, 2025 16:38
Copy link
Contributor

coderabbitai bot commented May 1, 2025

📝 Walkthrough

Walkthrough

The changes introduce a new lazy loading mechanism for iframes within articles by adding a script that sets the src attribute of iframes with a data-src attribute only after user interaction. Additionally, the Community Day events page is updated to replace a static list of event locations with an embedded interactive calendar, allowing users to view and interact with event information dynamically. No modifications were made to exported or public function or variable declarations.

Changes

File(s) Change Summary
source/_includes/javascripts/scripts.html Reformatted existing scripts and added a new script for lazy loading iframes in articles with class post.
source/_posts/2025-04-24-community-day.markdown Replaced static event location list with an embedded Luma calendar iframe and updated descriptive text.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant ArticleIframe

    User->>Browser: Loads article page
    Browser->>ArticleIframe: Iframes with data-src (no src set)
    User-->>Browser: Triggers mousemove/touchmove/scroll (first time)
    Browser->>ArticleIframe: Sets src = data-src, removes data-src
    ArticleIframe->>Browser: Loads iframe content
Loading
sequenceDiagram
    participant User
    participant Browser
    participant LumaCalendar

    User->>Browser: Loads Community Day page
    Browser->>LumaCalendar: Displays embedded interactive calendar iframe
    User->>LumaCalendar: Interacts with calendar to view event details
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 33fddea and 50b8502.

📒 Files selected for processing (1)
  • source/_includes/javascripts/scripts.html (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • source/_includes/javascripts/scripts.html
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - home-assistant-docs
  • GitHub Check: Header rules - home-assistant-docs
  • GitHub Check: Pages changed - home-assistant-docs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
source/_includes/javascripts/scripts.html (1)

14-17: Scope the contextmenu handler
Previous feedback pointed out the need to avoid hoisting top-level declarations into the global scope. Wrapping this listener logic in an IIFE or waiting for DOMContentLoaded will prevent unintended globals and guarantee the element exists before querying.

🧹 Nitpick comments (4)
source/_includes/javascripts/scripts.html (2)

8-13: Defer DocSearch initialization to avoid race conditions
The inline docsearch({...}) call can execute before the external DocSearch script has loaded. Consider adding defer to the <script> tag that loads @docsearch/js@3 or wrapping this block in a DOMContentLoaded/load event to ensure the library is available when you call docsearch().


38-62: Enhance iframe lazy-loading robustness

  • querySelectorAll returns an (empty) NodeList even if no matches exist, so if (iframes) is always truthy. Change to if (iframes.length > 0) to skip event listener registration when there are no lazy frames.
  • Inline scripts without defer or DOM-ready guards can run before the DOM is parsed; wrap this block in a DOMContentLoaded or use a deferred script tag.
  • For a more semantic, view-based approach, you might explore the Intersection Observer API to load iframes when they scroll into view rather than on any user movement.
source/_posts/2025-04-24-community-day.markdown (2)

26-26: Clarify link branding
The link text “[Home Assistant Community Day]” points to Luma’s calendar. Consider updating it to “Luma Community Day calendar” (or similar) so users know they’re navigating to a third-party embed.


39-39: Revisit preposition for clarity
“We also have people who work full-time on Home Assistant attending these events” may read more naturally as “work full-time at Home Assistant.”

🧰 Tools
🪛 LanguageTool

[uncategorized] ~39-~39: The preposition “as” seems more likely in this position.
Context: ... We also have people who work full-time on Home Assistant attending these events. ...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0834e9a and f14dcf8.

📒 Files selected for processing (2)
  • source/_includes/javascripts/scripts.html (2 hunks)
  • source/_posts/2025-04-24-community-day.markdown (1 hunks)
🧰 Additional context used
🪛 LanguageTool
source/_posts/2025-04-24-community-day.markdown

[uncategorized] ~39-~39: The preposition “as” seems more likely in this position.
Context: ... We also have people who work full-time on Home Assistant attending these events. ...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)

Comment on lines +28 to +37
<iframe
data-src="https://lu.ma/embed/calendar/cal-QXZXEJrvB3UaI63/events?lt=light"
width="100%"
height="600"
frameborder="0"
style="border: 1px solid #bfcbda88; border-radius: 4px;"
allowfullscreen=""
aria-hidden="false"
tabindex="0"
></iframe>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve iframe accessibility and markup hygiene

  • Add a title attribute (e.g. title="Home Assistant Community Day Calendar") for screen readers.
  • Remove the deprecated frameborder="0"—rely on CSS for styling (you already have border: 1px solid …).
  • As a progressive enhancement, you could include loading="lazy" on the <iframe>; your JS will still swap data-src, and browsers that support lazy loading will handle it natively.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
source/_includes/javascripts/scripts.html (4)

23-36: Enhance Scroll Listener Performance
Consider marking the scroll listener as passive to improve performance and prevent scroll jank:

-window.addEventListener("scroll", () => changeNavColor());
+window.addEventListener("scroll", () => changeNavColor(), { passive: true });

41-44: Ensure DOM Readiness
The lazy-load script executes immediately, which may run before the DOM is fully parsed and lead to article.post being null. Wrap the block in a DOMContentLoaded listener or add defer to the <script> tag to guarantee the element exists:

-<script type="text/javascript">
-  {
+<script defer>
+document.addEventListener('DOMContentLoaded', () => {
+  {

45-49: Optimize Lazy-Load Event Binding & Accessibility
Switch the iframes check to iframes.length > 0 to bind listeners only when there are iframes to load, and add a keydown listener so keyboard-only users can trigger the load:

-      if (iframes) {
+      if (iframes.length > 0) {
         document.addEventListener('mousemove', loadLazyFrames, { passive: true, once: true });
         document.addEventListener('touchmove', loadLazyFrames, { passive: true, once: true });
         document.addEventListener('scroll', loadLazyFrames, { passive: true, once: true });
+        document.addEventListener('keydown', loadLazyFrames, { passive: true, once: true });

51-62: Use Block-Scoped Function Expression
Block-level function declarations can be inconsistent across some browsers. Replace function loadLazyFrames() with a block-scoped arrow function:

-        function loadLazyFrames() {
+        const loadLazyFrames = () => {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f14dcf8 and 33fddea.

📒 Files selected for processing (1)
  • source/_includes/javascripts/scripts.html (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - home-assistant-docs
  • GitHub Check: Header rules - home-assistant-docs
  • GitHub Check: Pages changed - home-assistant-docs
🔇 Additional comments (1)
source/_includes/javascripts/scripts.html (1)

8-17: Review: DocSearch & Context Menu
The Algolia DocSearch setup and the contextmenu handler on .site-title are implemented correctly. Ensure that .site-title is present on every page to avoid a null-reference error when attaching the listener.

@balloob balloob merged commit af1fe88 into current May 1, 2025
9 checks passed
@balloob balloob deleted the add-luma-embed branch May 1, 2025 20:59
@github-actions github-actions bot locked and limited conversation to collaborators May 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
current This PR goes into the current branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants