Extract applySymbolState function from RatingWidget.ts

This commit is contained in:
Filip Noetzel 2025-06-10 11:49:09 +02:00
parent 2e53c1e164
commit 784e2f905e

View file

@ -0,0 +1,10 @@
/**
* Apply the appropriate CSS class to a symbol based on its state
*/
export function applySymbolState(span: HTMLElement, state: 'rated' | 'unrated' | 'normal'): void {
// Remove all state classes
span.classList.remove('interactive-rating-symbol--rated', 'interactive-rating-symbol--unrated', 'interactive-rating-symbol--normal');
// Add the appropriate state class
span.classList.add(`interactive-rating-symbol--${state}`);
}