Skip to content

Commit 932a831

Browse files
committed
Add Splat model, controller, and views
1 parent bfbfef0 commit 932a831

File tree

16 files changed

+308
-5
lines changed

16 files changed

+308
-5
lines changed

app/assets/stylesheets/splats.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.windshield {
22
display: grid;
3-
grid-template-columns: repeat(auto-fit, minmax(15vw, 1fr));
4-
justify-content: center;
3+
grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
4+
justify-items: center;
55

66
> * {
77
flex-shrink: 1;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
class SplatsController < ApplicationController
2+
before_action :set_splat, only: [ :show, :edit, :update ]
3+
4+
def index
5+
@splats = Splat.all
6+
end
7+
8+
def new
9+
@splat = Splat.new
10+
end
11+
12+
def edit
13+
end
14+
15+
def update
16+
@splat.update(splat_params)
17+
18+
redirect_to splat_path(@splat)
19+
end
20+
21+
def create
22+
Splat.create! splat_params
23+
24+
redirect_to splats_path
25+
end
26+
27+
def show
28+
end
29+
30+
private
31+
def splat_params
32+
params.require(:splat).permit(:title, :body, :color)
33+
end
34+
35+
def set_splat
36+
@splat = Splat.find(params[:id])
37+
end
38+
end

app/helpers/splats_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module SplatsHelper
2+
end

app/models/splat.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Splat < ApplicationRecord
2+
attribute :tag, :string
3+
4+
enum :color, %w[ dodgerblue limegreen tomato mediumorchid ].index_by(&:itself), suffix: true, default: :dodgerblue
5+
enum :tag, %w[ Product UI Web Mobile Feature Support iOS Android ].index_by(&:itself), suffix: true
6+
end

app/views/splats/_form.html.erb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<%= form_with model: splat, class: "flex flex-column gap" do | form | %>
2+
<%= form.label :title, class: "flex flex-column justify-start align-start" do %>
3+
<%= form.text_field :title, class: "input full-width", required: true, placeholder: "Name it…" %>
4+
<% end %>
5+
6+
<fieldset class="flex flex-column unpad margin-block-end borderless justify-space-between">
7+
<legend class="for-screen-reader">Color</legend>
8+
9+
<div class="flex align-center gap">
10+
<% Splat.colors.keys.each do | color | %>
11+
<label class="btn btn--circle txt-medium" style="--btn-background: <%= color -%>" >
12+
<%= form.radio_button :color, color %>
13+
<%= image_tag "check.svg", aria: { hidden: "true" }, size: 24, class: "checked" %>
14+
<span class="for-screen-reader"><%= color %></span>
15+
</label>
16+
<% end %>
17+
</div>
18+
</fieldset>
19+
20+
<fieldset class="flex flex-column unpad margin-block-end borderless justify-space-between">
21+
<legend class="for-screen-reader">Tag</legend>
22+
23+
<div class="flex align-center gap">
24+
<% Splat.tags.keys.each do | tag | %>
25+
<label class="btn txt-medium" style="--btn-background: <%= tag -%>" >
26+
<span><%= tag %></span>
27+
</label>
28+
<% end %>
29+
</div>
30+
</fieldset>
31+
32+
<%= form.label :body, class: "flex flex-column justify-start align-start" do %>
33+
<%= form.text_area :body, class: "input full-width", rows: 10, placeholder: "Details…" %>
34+
<% end %>
35+
36+
<%= form.button class: "btn btn--reversed" do %>
37+
<%= image_tag "check.svg", aria: { hidden: "true" }, size: 24%>
38+
<span class="for-screen-reader">Save</span>
39+
<% end %>
40+
<% end %>

app/views/splats/edit.html.erb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<% content_for :header do %>
2+
<nav>
3+
<%= link_to splats_path, class: "btn flex-item-justify-start" do %>
4+
<%= image_tag "arrow-left.svg", aria: { hidden: true }, size: 24 %>
5+
<span class="for-screen-reader">All Splats</span>
6+
<% end %>
7+
</nav>
8+
<% end %>
9+
10+
<div class="panel borderless pad margin center">
11+
<%= render "splats/form", splat: @splat %>
12+
</div>

app/views/splats/index.html.erb

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<% content_for :header do %>
2+
<nav>
3+
<button class="btn flex-item-justify-start">
4+
<%= image_tag "settings.svg", aria: { hidden: true }, size: 24 %>
5+
<span class="for-screen-reader">Settings</span>
6+
</button>
7+
8+
<%= link_to new_splat_path, class: "btn flex-item-justify-end", style: "view-transition-name: new-splat" do %>
9+
<%= image_tag "add.svg", aria: { hidden: true }, size: 24 %>
10+
<span class="for-screen-reader">Create a new splat</span>
11+
<% end %>
12+
</nav>
13+
<% end %>
14+
15+
<section class="windshield">
16+
<% @splats.last(10).each do | splat | %>
17+
<div class="splat" style="view-transition-name: splat-<%= splat.id -%>; --splat-color: <%= splat.color %>; --splat-size: <%= [20, 18, 16, 14].sample %>cqi; --splat-rotate: <%= [90, 80, 75, 60, 45, 35, 25, 5, -45, -40, -75].sample %>deg;">
18+
<svg class="splat__svg" viewBox="0 0 934 914" xmlns="http://www.w3.org/2000/svg"><circle cx="485.2" cy="467.2" r="286.5"/><path d="m197.7 219.1c-.2-7.1 5.8-11.7 12.7-13.2 34-7.1 53.5 29.2 81.4 40 39.5 6.4 25.9-54 30.8-77.7 17.2-65.3 78.4 67.2 108.2 55.7 26.8-17.3 25.9-58.8 38.7-86.1 9.6-41.5 30.4-2.6 48.6 10.1 14.2 11.2 31.9 17.9 45.1 29.9 13 11.2 20 29.1 35.8 36.8 20.2 9.1 44.8 2.3 65.2 11.8 18.3 7.2 33.8 22.6 52.5 30.4 23 8.6 42.4 1.8 37.8 35.1 2.7 36.8 38.3 71.9 40.1 108.6-.2 21.1-30.1 21.7-22.4 36.3 22.1 32.5-7.7 51.1 21 93.3 7 43.2-91.2-7.2-14.3 78.2 13.2 13.7 22.3 28.2 4.5 40.2-18.7 18.4-19.5 18.4-45 13.8-15.5-1.2 1.8 16.5-4.6 22.7-21.1 8-6.7 22-14.6 34.9-6 3.2-14.7-2.6-21.1-4-17.2-6.2-11.5 17.5-15.3 25.7-4 7.3-15.6 1.5-22.2-.2-26.7-10.8-55.1-3.1-82.4-.2-14.2 1.1-26 2.2-30.2 18.3-8 20.8-7.5 87.5-41.5 68.5-15.3-7.2-29.8-51.7-45.3-26.4-2.8 3.9-6.4 9.3-11.2 5.9-20.7-27.6-17-71-54.3-25.6-29.6 29.4-32.5 2.5-48.8-20.5-18.9-17.1-48.4-20.5-61.6-44.6-18.5-27.6-35.8-54.6-60.2-77.9-10.5-10.8-60.9-17.2-34.7-35.6 42.5-23.5-50.6-14-19.6-30.8 33.5-11.7 12.7-23.2-10.3-28.1-6.2-1.9-22-3.3-22.7-8.2 2.9-11.2 13.8-26.5 22.6-35.7 38.3-20.1-7-33.5-23.6-48.2-4-4.4 4.8-2.9 5.5-5.8-7.4-11.8-11.8-10-.4-21.8 3.2-7.8-4.9-17.6-3.8-25.5 8.1-21 57.9-6.5 64.2-36.2-3.5-26.1-16.4-50.3 3.5-75 5.9-8.8 22.4-16.8 19.3-28.7-5.7-14.7-26.4-23.7-27.6-40.2z"/><path d="m573 256.7s29.6-24.9 55-64.4 40.3-158 88.1-127.9c44.4 28-27.7 97.3-60.3 143.3-32.6 45.9-14.3 85.7-14.3 85.7l-68.5-36.6z"/><path d="m606.4 674.7s-11.3 37-11.2 84c0 47 51.9 154.6-4.6 155.3-52.5.6-29.6-96.8-27.1-153.1s-34.5-79.7-34.5-79.7z"/><path d="m325.5 622.7s-34 16.1-71.9 44c-37.8 27.9-104.9 118.2-126.8 89.7-20.3-26.5 66.8-72.5 113.1-104.6s51.2-64.9 51.2-64.9l34.4 35.9z"/><path d="m225.7 388.5s-30.8-35.1-75.8-72.7c-45.1-37.5-169.2-98.3-146.9-126.5 20.8-26.1 104.8 63 157.6 109.3 52.9 46.2 90.4 46.9 90.4 46.9l-25.4 43z"/><path d="m327.7 593.7s-47.6 1.4-103.9 17.7c-56.3 16.2-170.6 104.9-187.6 48.8-15.8-52.2 107.7-62.8 175.9-79.7s85.8-61.9 85.8-61.9l29.9 75.1z"/><path d="m443.5 344.2s0-46.7-8.9-104.6c-9-57.9-62-185.6-26.7-192 32.9-5.9 37 116.5 46.2 186.2 9.2 69.6 36.9 95 36.9 95l-47.5 15.5z"/><path d="m433.2 340.9s-6.8-37-19.5-82.8c-12.8-45.8-56.9-146.5-40.8-151.7 15-4.8 34.8 92 49.3 147s31.6 74.9 31.6 74.9l-20.6 12.5z"/><path d="m496.8 298.1s10.8-45.7 13.6-104.2c2.8-58.6-29.9-194.6 12.9-193.4 39.8 1.1 16.5 121.7 11.2 191.8-5.3 70 21.3 100.6 21.3 100.6l-59.1 5.2z"/><path d="m647.8 525s22.1 41.1 57.6 87.8c35.4 46.7 142.8 133.8 114.7 156.2-26.1 20.8-88-84.9-129.1-141.8-41.2-56.9-77.6-66-77.6-66z"/><path d="m658.4 523s23.5 29.3 56.5 63.5 119.7 101.9 108 114.1c-10.9 11.4-74.3-64.4-113.3-105.9s-63.4-50.9-63.4-50.9z"/><path d="m622.8 591s12.2 45.3 37.6 98.2 118.8 157 80.6 176.3c-35.6 17.9-72.4-99.3-101.1-163.4-28.6-64.1-66.6-78.4-66.6-78.4l49.5-32.6z"/><path d="m613.7 441.6s43.3 17.5 100.4 30.7c57.1 13.3 195.4 11.6 188.1 46.8-6.8 32.7-121.9-9.1-189.9-26.6s-101.9-1.2-101.9-1.2l3.3-49.8z"/><path d="m666.2 496.5s38.4 27.1 91.7 51.5 191.7 44.8 174.6 84.1c-15.9 36.5-119.1-30.1-182.2-61.1-63-31-101.3-17.7-101.3-17.7l17.2-56.7z"/><path d="m57.2 500.1c-7.1-1.3-14.4-2-21.5-.7-13.9 2.4-27.3 11.4-31.7 25.2-5 15.2 2.5 30.2 12.9 41.7 7.5 8.5 16.3 16.5 27.6 16.6 19.9-.7 36.3-19.9 37.6-39 1.6-18.3-8.2-36.2-27.2-40.2-3.5-.8-7.2-1.2-10.8-1.5"/><path d="m796.1 362.9c5.4 21.4 22.7 41 44.2 46.3 16.7 4.5 33.7-3 43.2-17.2 24.3-38.2-3-125.5-53.2-116.5-8 1.5-15.8 5.8-21.4 11.6-18.2 19.3-19.3 51.3-12.8 75.6z"/><path d="m255.1 782.9c5.4 21.4 22.7 41 44.2 46.3 16.7 4.5 33.7-3 43.2-17.2 24.3-38.2-3-125.5-53.2-116.5-8 1.5-15.8 5.8-21.4 11.6-18.2 19.3-19.3 51.3-12.8 75.6z"/><path d="m771 224.4c-3.4-.5-6.8-1-10.2-1.1-23.8-1.1-36.1 23.5-16.7 36.4 9.4 6.3 22.2 2.4 26.7-7.7 5.2-11.6-.7-20.3-10.6-26.9"/><path d="m402 812.4c-3.4-.5-6.8-1-10.2-1.1-23.8-1.1-36.1 23.5-16.7 36.4 9.4 6.3 22.2 2.4 26.7-7.7 5.2-11.6-.7-20.3-10.6-26.9"/></svg>
19+
<%= link_to splat, class: "splat__link" do %>
20+
<h1 class="splat__title"><%= splat.title %></h1>
21+
<% end %>
22+
<time class="splat__date"><%= splat.updated_at.strftime("%B <br> %d").html_safe %></time>
23+
<span class="splat__tag"><%= ["product", "web", "mobile", "support", "bug", "UI"].sample %></span>
24+
</div>
25+
<% end %>
26+
</section>
27+
28+
<menu class="splats-filter flex align-center justify-center gap margin-block-start margin-none unpad position-relative">
29+
<li>
30+
<button class="btn">
31+
<%= image_tag "chart.svg", aria: { hidden: true }, size: 24 %>
32+
<span class="for-screen-reader">Activity</span>
33+
<input type="radio" name="view" checked>
34+
</button>
35+
</li>
36+
<li>
37+
<button class="btn">
38+
<%= image_tag "temperature.svg", aria: { hidden: true }, size: 24 %>
39+
<span class="for-screen-reader">Criticality</span>
40+
<input type="radio" name="view">
41+
</button>
42+
</li>
43+
<li>
44+
<button class="btn">
45+
<%= image_tag "inbox.svg", aria: { hidden: true }, size: 24 %>
46+
<span class="for-screen-reader">Newest</span>
47+
<input type="radio" name="view">
48+
</button>
49+
</li>
50+
<li>
51+
<button class="btn">
52+
<%= image_tag "hourglass.svg", aria: { hidden: true }, size: 24 %>
53+
<span class="for-screen-reader">Oldest</span>
54+
<input type="radio" name="view">
55+
</button>
56+
</li>
57+
</menu>
58+
59+
<section class="splats-list panel center borderless">
60+
<ul class="unpad margin-none flex flex-column txt-align-start center">
61+
<% @splats.each do | splat | %>
62+
<li class="flex align-center gap margin-none">
63+
<%= link_to splat, class: "flex align-center gap flex-item-grow" do %>
64+
<div class="splat" style="--splat-color: <%= splat.color %>; --splat-size: 1.5em; --splat-rotate: <%= [90, 80, 75, 60, 45, 35, 25, 5, -45, -40, -75].sample %>deg;">
65+
<svg class="splat__svg" viewBox="0 0 934 914" xmlns="http://www.w3.org/2000/svg"><circle cx="485.2" cy="467.2" r="286.5"/><path d="m197.7 219.1c-.2-7.1 5.8-11.7 12.7-13.2 34-7.1 53.5 29.2 81.4 40 39.5 6.4 25.9-54 30.8-77.7 17.2-65.3 78.4 67.2 108.2 55.7 26.8-17.3 25.9-58.8 38.7-86.1 9.6-41.5 30.4-2.6 48.6 10.1 14.2 11.2 31.9 17.9 45.1 29.9 13 11.2 20 29.1 35.8 36.8 20.2 9.1 44.8 2.3 65.2 11.8 18.3 7.2 33.8 22.6 52.5 30.4 23 8.6 42.4 1.8 37.8 35.1 2.7 36.8 38.3 71.9 40.1 108.6-.2 21.1-30.1 21.7-22.4 36.3 22.1 32.5-7.7 51.1 21 93.3 7 43.2-91.2-7.2-14.3 78.2 13.2 13.7 22.3 28.2 4.5 40.2-18.7 18.4-19.5 18.4-45 13.8-15.5-1.2 1.8 16.5-4.6 22.7-21.1 8-6.7 22-14.6 34.9-6 3.2-14.7-2.6-21.1-4-17.2-6.2-11.5 17.5-15.3 25.7-4 7.3-15.6 1.5-22.2-.2-26.7-10.8-55.1-3.1-82.4-.2-14.2 1.1-26 2.2-30.2 18.3-8 20.8-7.5 87.5-41.5 68.5-15.3-7.2-29.8-51.7-45.3-26.4-2.8 3.9-6.4 9.3-11.2 5.9-20.7-27.6-17-71-54.3-25.6-29.6 29.4-32.5 2.5-48.8-20.5-18.9-17.1-48.4-20.5-61.6-44.6-18.5-27.6-35.8-54.6-60.2-77.9-10.5-10.8-60.9-17.2-34.7-35.6 42.5-23.5-50.6-14-19.6-30.8 33.5-11.7 12.7-23.2-10.3-28.1-6.2-1.9-22-3.3-22.7-8.2 2.9-11.2 13.8-26.5 22.6-35.7 38.3-20.1-7-33.5-23.6-48.2-4-4.4 4.8-2.9 5.5-5.8-7.4-11.8-11.8-10-.4-21.8 3.2-7.8-4.9-17.6-3.8-25.5 8.1-21 57.9-6.5 64.2-36.2-3.5-26.1-16.4-50.3 3.5-75 5.9-8.8 22.4-16.8 19.3-28.7-5.7-14.7-26.4-23.7-27.6-40.2z"/><path d="m573 256.7s29.6-24.9 55-64.4 40.3-158 88.1-127.9c44.4 28-27.7 97.3-60.3 143.3-32.6 45.9-14.3 85.7-14.3 85.7l-68.5-36.6z"/><path d="m606.4 674.7s-11.3 37-11.2 84c0 47 51.9 154.6-4.6 155.3-52.5.6-29.6-96.8-27.1-153.1s-34.5-79.7-34.5-79.7z"/><path d="m325.5 622.7s-34 16.1-71.9 44c-37.8 27.9-104.9 118.2-126.8 89.7-20.3-26.5 66.8-72.5 113.1-104.6s51.2-64.9 51.2-64.9l34.4 35.9z"/><path d="m225.7 388.5s-30.8-35.1-75.8-72.7c-45.1-37.5-169.2-98.3-146.9-126.5 20.8-26.1 104.8 63 157.6 109.3 52.9 46.2 90.4 46.9 90.4 46.9l-25.4 43z"/><path d="m327.7 593.7s-47.6 1.4-103.9 17.7c-56.3 16.2-170.6 104.9-187.6 48.8-15.8-52.2 107.7-62.8 175.9-79.7s85.8-61.9 85.8-61.9l29.9 75.1z"/><path d="m443.5 344.2s0-46.7-8.9-104.6c-9-57.9-62-185.6-26.7-192 32.9-5.9 37 116.5 46.2 186.2 9.2 69.6 36.9 95 36.9 95l-47.5 15.5z"/><path d="m433.2 340.9s-6.8-37-19.5-82.8c-12.8-45.8-56.9-146.5-40.8-151.7 15-4.8 34.8 92 49.3 147s31.6 74.9 31.6 74.9l-20.6 12.5z"/><path d="m496.8 298.1s10.8-45.7 13.6-104.2c2.8-58.6-29.9-194.6 12.9-193.4 39.8 1.1 16.5 121.7 11.2 191.8-5.3 70 21.3 100.6 21.3 100.6l-59.1 5.2z"/><path d="m647.8 525s22.1 41.1 57.6 87.8c35.4 46.7 142.8 133.8 114.7 156.2-26.1 20.8-88-84.9-129.1-141.8-41.2-56.9-77.6-66-77.6-66z"/><path d="m658.4 523s23.5 29.3 56.5 63.5 119.7 101.9 108 114.1c-10.9 11.4-74.3-64.4-113.3-105.9s-63.4-50.9-63.4-50.9z"/><path d="m622.8 591s12.2 45.3 37.6 98.2 118.8 157 80.6 176.3c-35.6 17.9-72.4-99.3-101.1-163.4-28.6-64.1-66.6-78.4-66.6-78.4l49.5-32.6z"/><path d="m613.7 441.6s43.3 17.5 100.4 30.7c57.1 13.3 195.4 11.6 188.1 46.8-6.8 32.7-121.9-9.1-189.9-26.6s-101.9-1.2-101.9-1.2l3.3-49.8z"/><path d="m666.2 496.5s38.4 27.1 91.7 51.5 191.7 44.8 174.6 84.1c-15.9 36.5-119.1-30.1-182.2-61.1-63-31-101.3-17.7-101.3-17.7l17.2-56.7z"/><path d="m57.2 500.1c-7.1-1.3-14.4-2-21.5-.7-13.9 2.4-27.3 11.4-31.7 25.2-5 15.2 2.5 30.2 12.9 41.7 7.5 8.5 16.3 16.5 27.6 16.6 19.9-.7 36.3-19.9 37.6-39 1.6-18.3-8.2-36.2-27.2-40.2-3.5-.8-7.2-1.2-10.8-1.5"/><path d="m796.1 362.9c5.4 21.4 22.7 41 44.2 46.3 16.7 4.5 33.7-3 43.2-17.2 24.3-38.2-3-125.5-53.2-116.5-8 1.5-15.8 5.8-21.4 11.6-18.2 19.3-19.3 51.3-12.8 75.6z"/><path d="m255.1 782.9c5.4 21.4 22.7 41 44.2 46.3 16.7 4.5 33.7-3 43.2-17.2 24.3-38.2-3-125.5-53.2-116.5-8 1.5-15.8 5.8-21.4 11.6-18.2 19.3-19.3 51.3-12.8 75.6z"/><path d="m771 224.4c-3.4-.5-6.8-1-10.2-1.1-23.8-1.1-36.1 23.5-16.7 36.4 9.4 6.3 22.2 2.4 26.7-7.7 5.2-11.6-.7-20.3-10.6-26.9"/><path d="m402 812.4c-3.4-.5-6.8-1-10.2-1.1-23.8-1.1-36.1 23.5-16.7 36.4 9.4 6.3 22.2 2.4 26.7-7.7 5.2-11.6-.7-20.3-10.6-26.9"/></svg>
66+
</div>
67+
<strong><%= splat.title %></strong>
68+
<% end %>
69+
<small class="flex align-center gap flex-item-shrink">
70+
<span class="btn txt-small txt-nowrap">Web</span>
71+
<span class="avatar txt-small txt-nowrap fill-shade"><strong>JZ</strong></span>
72+
<time class="txt-nowrap flex-item-justify-end"><%= splat.updated_at.strftime("%B %d").html_safe %></time>
73+
</small>
74+
</li>
75+
<% end %>
76+
</ul>
77+
</section>

app/views/splats/new.html.erb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<% content_for :header do %>
2+
<nav>
3+
<%= link_to splats_path, class: "btn flex-item-justify-start" do %>
4+
<%= image_tag "arrow-left.svg", aria: { hidden: true }, size: 24 %>
5+
<span class="for-screen-reader">All Splats</span>
6+
<% end %>
7+
</nav>
8+
<% end %>
9+
10+
<div class="panel borderless pad margin center" style="view-transition-name: new-splat">
11+
<%= render "splats/form", splat: @splat %>
12+
</div>

0 commit comments

Comments
 (0)