import { Controller } from '@hotwired/stimulus'; /** * Stimulus 컨트롤러로, 특정 요소의 클래스를 토글합니다. * 이 컨트롤러는 이벤트 파라미터를 통해 추가할 클래스와 제거할 클래스를 지정합니다. */ export default class extends Controller { static targets = ['box']; toggle(event) { const classToAdd = event.params.add; const classToRemove = event.params.remove; this.boxTargets.forEach((box) => { box.classList.remove(classToRemove); box.classList.add(classToAdd); }); } }

AltStyle によって変換されたページ (->オリジナル) /