<!-- 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 -->
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { CSSResultGroup, LitElement, PropertyValues, unsafeCSS } from 'lit';
|
|
import { property } from 'lit/decorators.js';
|
|
import effectBaseStyle from '../../scss/effect-base.scss';
|
|
import { forceReflow } from '../../utils/basic';
|
|
|
|
export abstract class BaseEffectComponent extends LitElement {
|
|
@property({ type: Boolean })
|
|
public fadeIn = true;
|
|
|
|
protected firstUpdated(): void {
|
|
if (this.fadeIn) {
|
|
this._startFadeIn();
|
|
}
|
|
}
|
|
|
|
protected updated(changedProps: PropertyValues): void {
|
|
// Skip if this is the initial property setting (handled by firstUpdated).
|
|
if (changedProps.get('fadeIn') !== undefined) {
|
|
if (!this.fadeIn) {
|
|
this._setOpacity(1);
|
|
} else {
|
|
this._startFadeIn();
|
|
}
|
|
}
|
|
}
|
|
|
|
public startFadeOut(): Promise<void> {
|
|
return new Promise((resolve) => {
|
|
const handler = (ev: TransitionEvent) => {
|
|
if (ev.propertyName === 'opacity') {
|
|
this.removeEventListener('transitionend', handler);
|
|
resolve();
|
|
}
|
|
};
|
|
this.addEventListener('transitionend', handler);
|
|
this._setOpacity(0);
|
|
});
|
|
}
|
|
|
|
private _startFadeIn(): void {
|
|
this._setOpacity(0);
|
|
forceReflow(this);
|
|
this._setOpacity(1);
|
|
}
|
|
|
|
private _setOpacity(opacity: number): void {
|
|
this.style.opacity = `${opacity}`;
|
|
}
|
|
|
|
static get styles(): CSSResultGroup {
|
|
return unsafeCSS(effectBaseStyle);
|
|
}
|
|
}
|