Skip to content

[light] Add scannable effects index with CSS-animated previews#6692

Open
bharvey88 wants to merge 2 commits into
esphome:currentfrom
bharvey88:effects-redesign
Open

[light] Add scannable effects index with CSS-animated previews#6692
bharvey88 wants to merge 2 commits into
esphome:currentfrom
bharvey88:effects-redesign

Conversation

@bharvey88
Copy link
Copy Markdown
Contributor

@bharvey88 bharvey88 commented May 26, 2026

Description

Adds a scannable index at the top of the Light Effects section of src/content/docs/components/light/index.mdx. Three grouped tables list every effect with a CSS-animated preview, anchor-linked name, one-line description, and parameter list. The existing per-effect reference subsections (prose, YAML examples, configuration variables) below the index are unchanged.

image

The change is one file, +300 lines, no new dependencies. Inline <style> block plus raw HTML tables; Goldmark already passes HTML through. Reduced-motion fallback included.

Discord context: discussed in the ESPHome Discord; this PR incorporates @jesserockz's feedback (open against upstream rather than fork, rebase onto current, fix the scan effect to bounce back and forth).

Related issue (if applicable): n/a

Pull request in esphome with YAML changes (if applicable): n/a

Checklist

  • I am merging into next because this is new documentation that has a matching pull-request in esphome as linked above.
    or

  • I am merging into current because this is a fix, change and/or adjustment in the current documentation and is not for a new component or feature.

  • Link added in /src/content/docs/components/index.mdx when creating new documents for new components or cookbook.

New Component Images

If you are adding a new component to ESPHome, you can automatically generate a standardized black and white component name image for the documentation.

To generate a component image:

  1. Comment on this pull request with the following command, replacing component_name with your component name in lower_case format with underscores (e.g., bme280, sht3x, dallas_temp):

    @esphomebot generate image component_name
    
  2. The ESPHome bot will respond with a downloadable ZIP file containing the SVG image.

  3. Extract the SVG file and place it in the /public/images/ folder of this repository.

  4. Use the image in your component's index table entry in /src/content/docs/components/index.mdx.

Example: For a component called "DHT22 Temperature Sensor", use:

@esphomebot generate image dht22

Note: All images used in ImgTable components must be placed in /public/images/ as the component resolves them to absolute paths.

@esphome esphome Bot added the current label May 26, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 26, 2026

Deploy Preview for esphome ready!

Name Link
🔨 Latest commit 2404c0d
🔍 Latest deploy log https://app.netlify.com/projects/esphome/deploys/6a156d2094a8530008b90047
😎 Deploy Preview https://deploy-preview-6692--esphome.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 05743e84-bbee-4240-94e5-4297bc4e7464

📥 Commits

Reviewing files that changed from the base of the PR and between 3cacc0e and 2404c0d.

📒 Files selected for processing (2)
  • src/components/LightEffectPreview.astro
  • src/content/docs/components/light/index.mdx
✅ Files skipped from review due to trivial changes (1)
  • src/content/docs/components/light/index.mdx

Walkthrough

Adds a new LightEffectPreview Astro component that renders animated single-bulb or addressable-strip previews and updates the light component documentation to embed these previews in new Basic Animations, Strip Animations, and External Control tables.

Changes

Light Effects Visual Documentation

Layer / File(s) Summary
LightEffectPreview component implementation
src/components/LightEffectPreview.astro
New Astro component with props { type, label }, conditional bulb vs. strip rendering, CSS classes, per-effect @keyframes, per-pixel delays for strips, and prefers-reduced-motion overrides.
Documentation integration and effect tables
src/content/docs/components/light/index.mdx
Import of LightEffectPreview and insertion of three subsections (“Basic Animations”, “Strip Animations”, “External Control”) each containing tables of effects with embedded preview cells, descriptions, and parameter lists.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a scannable index with CSS-animated previews for light effects, which aligns with the actual additions of documentation and a new preview component.
Description check ✅ Passed The description comprehensively explains the PR's purpose: adding a scannable effects index with grouped tables, CSS-animated previews, and updated documentation while preserving existing content.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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

🧹 Nitpick comments (1)
src/content/docs/components/light/index.mdx (1)

589-590: ⚡ Quick win

Consider using CSS custom properties for the scan animation.

The translateX(133px) value is hardcoded based on the current pixel sizing (19 positions × 7px). If the pixel count or sizing in the HTML changes, this animation will break.

♻️ Recommended approach using CSS variables

Define variables at the top of the style block:

:root {
  --fx-pixel-width: 6px;
  --fx-pixel-gap: 1px;
  --fx-strip-pixels: 20;
}

Then use calc():

`@keyframes` fx-scan {
  from { transform: translateX(0); }
  to   { transform: translateX(calc((var(--fx-strip-pixels) - 1) * (var(--fx-pixel-width) + var(--fx-pixel-gap)))); }
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/content/docs/components/light/index.mdx` around lines 589 - 590, Replace
the hardcoded translateX(133px) in the fx-scan keyframes with a calc()
expression using CSS variables so the animation adapts when pixel size/count
changes: introduce variables like --fx-pixel-width, --fx-pixel-gap and
--fx-strip-pixels (e.g., in :root or the component scope) and change the fx-scan
keyframe's to transform to use translateX(calc((var(--fx-strip-pixels) - 1) *
(var(--fx-pixel-width) + var(--fx-pixel-gap)))) so the animation moves by
(pixels - 1) times the pixel width+gap instead of a fixed 133px.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/content/docs/components/light/index.mdx`:
- Line 784: The anchor link for the E1.31 effect is broken because the table
link uses href="`#e131-effect`" while the actual section anchor is
id="e131-light-effect"; update the table link href (the anchor in the <td
class="fx-name"> that currently points to "`#e131-effect`") to
"`#e131-light-effect`" so it matches the existing explicit anchor id for the E1.31
effect (id="e131-light-effect").

---

Nitpick comments:
In `@src/content/docs/components/light/index.mdx`:
- Around line 589-590: Replace the hardcoded translateX(133px) in the fx-scan
keyframes with a calc() expression using CSS variables so the animation adapts
when pixel size/count changes: introduce variables like --fx-pixel-width,
--fx-pixel-gap and --fx-strip-pixels (e.g., in :root or the component scope) and
change the fx-scan keyframe's to transform to use
translateX(calc((var(--fx-strip-pixels) - 1) * (var(--fx-pixel-width) +
var(--fx-pixel-gap)))) so the animation moves by (pixels - 1) times the pixel
width+gap instead of a fixed 133px.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 16ed5d22-3cd3-469e-8388-9afb01aff568

📥 Commits

Reviewing files that changed from the base of the PR and between 5a457a8 and 3cacc0e.

📒 Files selected for processing (1)
  • src/content/docs/components/light/index.mdx

Comment thread src/content/docs/components/light/index.mdx Outdated
Move the inline <style> block and raw HTML effect tables into a
LightEffectPreview.astro component with scoped CSS, and replace the
three HTML tables with markdown tables that call the component. The
rendered output is equivalent; the MDX source goes from ~300 lines of
inline HTML/CSS to a handful of markdown rows.
@nagyrobi
Copy link
Copy Markdown
Member

nagyrobi commented May 26, 2026

What are the requirements for the animated representations to work?
I tried the preview in both Firefox (151.0.1) and Chrome (148.0.7778.179), the images don't animate.

@bharvey88
Copy link
Copy Markdown
Contributor Author

bharvey88 commented May 26, 2026 via email

@jesserockz
Copy link
Copy Markdown
Member

What are the requirements for the animated representations to work? I tried the preview in both Firefox (151.0.1) and Chrome (148.0.7778.179), the images don't animate.

They are css animations

Those browser versions work for me on Linux, and that chrome version on macOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants