Boost splats
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<%= link_to splat.boosts.any? ? "+ #{splat.boosts.size}" : "+", new_splat_boost_path(splat) %>
|
||||
@@ -0,0 +1,3 @@
|
||||
<%= turbo_stream.update dom_id(@splat, "boosts") do %>
|
||||
<%= render "/boosts/boost", splat: @splat %>
|
||||
<% end %>
|
||||
@@ -0,0 +1,3 @@
|
||||
<turbo-frame id="<%= dom_id(@splat, "boosts") %>">
|
||||
<%= render "/boosts/boost", splat: @splat %>
|
||||
</turbo-frame>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user