# css .spin { -webkit-animation: spin 2s linear infinite; } @-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); } } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
# show page <%= link_to reload_icon, weathers_feels_like_path, class: "float-end", data: { controller: 'refresh' } %>
# refresh_controller.js import { Controller } from "@hotwired/stimulus" // Connects to data-controller="refresh" export default class extends Controller { connect() { this.element.setAttribute("data-action", "click->refresh#click") } click(e) { this.element.classList.add("spin") } }
bin/rails g stimulus refresh