Boost splats

This commit is contained in:
Jason Zimdars
2024-08-19 17:33:12 -05:00
parent b5c9f7affd
commit 642e8bcd27
11 changed files with 64 additions and 3 deletions
+5
View File
@@ -52,6 +52,7 @@
@media (hover: hover) {
.windshield &:hover {
scale: 1.1;
z-index: 999;
.splat__svg {
transform: rotate(calc(var(--splat-rotate) + 10deg));
@@ -83,6 +84,10 @@
aspect-ratio: 1;
inset: 50cqi -1cqi auto auto;
a {
text-decoration: none;
}
.windshield .splat:hover & {
transform: translate(0, 1rem) !important;
}
+26
View File
@@ -0,0 +1,26 @@
class BoostsController < ApplicationController
before_action :set_splat
def new
@boost = @splat.boosts.build
end
def create
@boost = @splat.boosts.new
@boost.save
respond_to do |format|
format.turbo_stream { render }
format.html { head :no_content }
end
end
def index
@boosts = @splat.boosts
end
private
def set_splat
@splat = Splat.find(params[:splat_id])
end
end
+2
View File
@@ -0,0 +1,2 @@
module BoostsHelper
end
@@ -0,0 +1,7 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
this.element.requestSubmit()
}
}
+1
View File
@@ -0,0 +1 @@
<%= link_to splat.boosts.any? ? "+ #{splat.boosts.size}" : "+", new_splat_boost_path(splat) %>
+3
View File
@@ -0,0 +1,3 @@
<%= turbo_stream.update dom_id(@splat, "boosts") do %>
<%= render "/boosts/boost", splat: @splat %>
<% end %>
+3
View File
@@ -0,0 +1,3 @@
<turbo-frame id="<%= dom_id(@splat, "boosts") %>">
<%= render "/boosts/boost", splat: @splat %>
</turbo-frame>
+5
View File
@@ -0,0 +1,5 @@
<turbo-frame id="<%= dom_id(@splat, "boosts") %>">
<%= form_with model: [@splat, @boost], data: { controller: "auto-submit" } do |form| %>
<%= form.submit "Boost this", hidden: true %>
<% end %>
</turbo-frame>
+4 -3
View File
@@ -21,7 +21,8 @@
</span>
<% end %>
<% if splat.boosts.any? %>
<div class="splat__bubble splat__meta splat__boosts"><%= splat.boosts.size %></div>
<% end %>
<div class="splat__bubble splat__meta splat__boosts">
<turbo-frame id="<%= dom_id(splat, "boosts") %>" src="<%= splat_boosts_path(splat) %>" />
</div>
</div>
+1
View File
@@ -4,6 +4,7 @@ Rails.application.routes.draw do
resource :session
resources :splats do
resources :boosts
resources :categories, shallow: true
resources :comments
end
@@ -0,0 +1,7 @@
require "test_helper"
class BoostsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end