feat: Add festive visual effects (#2252)
<!-- CURSOR_SUMMARY --> > [!NOTE] > Introduces an effects system (fireworks, ghost, hearts, shamrocks, snow), a new `effect` action, and optional date-based loading effects, integrated into the card with docs, schema, editor, and tests. > > - **Effects System**: > - Add `EffectsController` and `advanced-camera-card-effects` host with lazy-loaded effect modules (`fireworks`, `ghost`, `hearts`, `shamrocks`, `snow`). > - New base effect component with fade-in/out; SCSS and z-index updates. > - **Actions**: > - New custom action `advanced_camera_card_action: effect` with `effect_action` (`start`|`stop`|`toggle`). > - Wire into `ActionFactory` and add `EffectAction` executor. > - **Card Integration**: > - Mount effects host in `advanced-camera-card` and expose `getEffectsControllerAPI()` via `CardController`. > - Loading component can trigger date-based effects (e.g., New Year fireworks) when enabled. > - **Configuration & Editor**: > - Add `performance.features.card_loading_effects` (default `true`) alongside `card_loading_indicator`. > - Update schemas, defaults, low-performance profile (disables effects), and editor toggles. > - **Docs & Examples**: > - Document `effect` action parameters and add menu example. > - Update performance docs with new option. > - **Localization & Tests**: > - Update i18n strings for new performance option. > - Add comprehensive tests for effects controller, action, factory, config defaults/profiles, and utilities. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit cffd4304fe3bd22340316f9cec53e341379b1756. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import { CSSResultGroup, html, LitElement, TemplateResult, unsafeCSS } from 'lit';
|
||||
import { customElement, property } from 'lit/decorators.js';
|
||||
import heartStyle from '../../scss/heart.scss';
|
||||
|
||||
@customElement('advanced-camera-card-heart')
|
||||
export class AdvancedCameraCardHeart extends LitElement {
|
||||
@property({ type: String })
|
||||
public char = '❤️';
|
||||
|
||||
@property({ type: String })
|
||||
public size = '1em';
|
||||
|
||||
@property({ type: Number })
|
||||
public hue = 340;
|
||||
|
||||
@property({ type: Number })
|
||||
public saturation = 80;
|
||||
|
||||
@property({ type: Number })
|
||||
public lightness = 55;
|
||||
|
||||
@property({ type: Number })
|
||||
public maxOpacity = 1;
|
||||
|
||||
@property({ type: String })
|
||||
public pulseDuration = '3s';
|
||||
|
||||
@property({ type: String })
|
||||
public pulseDelay = '0s';
|
||||
|
||||
@property({ type: String })
|
||||
public startX = '0%';
|
||||
|
||||
@property({ type: String })
|
||||
public startY = '0%';
|
||||
|
||||
public connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
this.addEventListener('animationiteration', this._handleAnimationIteration);
|
||||
}
|
||||
|
||||
public disconnectedCallback(): void {
|
||||
super.disconnectedCallback();
|
||||
this.removeEventListener('animationiteration', this._handleAnimationIteration);
|
||||
}
|
||||
|
||||
private _handleAnimationIteration = (ev: AnimationEvent): void => {
|
||||
if (ev.animationName === 'pulse') {
|
||||
this.startX = `${Math.random() * 100}%`;
|
||||
this.startY = `${Math.random() * 100}%`;
|
||||
}
|
||||
};
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`${this.char}`;
|
||||
}
|
||||
|
||||
protected updated(): void {
|
||||
this.style.setProperty('--size', this.size);
|
||||
this.style.setProperty('--hue', `${this.hue}`);
|
||||
this.style.setProperty('--saturation', `${this.saturation}`);
|
||||
this.style.setProperty('--lightness', `${this.lightness}`);
|
||||
this.style.setProperty('--max-opacity', `${this.maxOpacity}`);
|
||||
this.style.setProperty('--pulse-duration', this.pulseDuration);
|
||||
this.style.setProperty('--pulse-delay', this.pulseDelay);
|
||||
this.style.setProperty('--start-x', this.startX);
|
||||
this.style.setProperty('--start-y', this.startY);
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return unsafeCSS(heartStyle);
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'advanced-camera-card-heart': AdvancedCameraCardHeart;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user