diff --git a/app/assets/stylesheets/splats.css b/app/assets/stylesheets/splats.css index 8d69e1c42..4e9343389 100644 --- a/app/assets/stylesheets/splats.css +++ b/app/assets/stylesheets/splats.css @@ -1,7 +1,7 @@ .windshield { display: grid; - grid-template-columns: repeat(auto-fit, minmax(15vw, 1fr)); - justify-content: center; + grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); + justify-items: center; > * { flex-shrink: 1; diff --git a/app/controllers/splats_controller.rb b/app/controllers/splats_controller.rb new file mode 100644 index 000000000..2ee68961a --- /dev/null +++ b/app/controllers/splats_controller.rb @@ -0,0 +1,38 @@ +class SplatsController < ApplicationController + before_action :set_splat, only: [ :show, :edit, :update ] + + def index + @splats = Splat.all + end + + def new + @splat = Splat.new + end + + def edit + end + + def update + @splat.update(splat_params) + + redirect_to splat_path(@splat) + end + + def create + Splat.create! splat_params + + redirect_to splats_path + end + + def show + end + + private + def splat_params + params.require(:splat).permit(:title, :body, :color) + end + + def set_splat + @splat = Splat.find(params[:id]) + end +end diff --git a/app/helpers/splats_helper.rb b/app/helpers/splats_helper.rb new file mode 100644 index 000000000..403fba86f --- /dev/null +++ b/app/helpers/splats_helper.rb @@ -0,0 +1,2 @@ +module SplatsHelper +end diff --git a/app/models/splat.rb b/app/models/splat.rb new file mode 100644 index 000000000..7415ccfab --- /dev/null +++ b/app/models/splat.rb @@ -0,0 +1,6 @@ +class Splat < ApplicationRecord + attribute :tag, :string + + enum :color, %w[ dodgerblue limegreen tomato mediumorchid ].index_by(&:itself), suffix: true, default: :dodgerblue + enum :tag, %w[ Product UI Web Mobile Feature Support iOS Android ].index_by(&:itself), suffix: true +end diff --git a/app/views/splats/_form.html.erb b/app/views/splats/_form.html.erb new file mode 100644 index 000000000..6f238b2e2 --- /dev/null +++ b/app/views/splats/_form.html.erb @@ -0,0 +1,40 @@ +<%= form_with model: splat, class: "flex flex-column gap" do | form | %> + <%= form.label :title, class: "flex flex-column justify-start align-start" do %> + <%= form.text_field :title, class: "input full-width", required: true, placeholder: "Name it…" %> + <% end %> + +
+ Color + +
+ <% Splat.colors.keys.each do | color | %> + + <% end %> +
+
+ +
+ Tag + +
+ <% Splat.tags.keys.each do | tag | %> + + <% end %> +
+
+ + <%= form.label :body, class: "flex flex-column justify-start align-start" do %> + <%= form.text_area :body, class: "input full-width", rows: 10, placeholder: "Details…" %> + <% end %> + + <%= form.button class: "btn btn--reversed" do %> + <%= image_tag "check.svg", aria: { hidden: "true" }, size: 24%> + Save + <% end %> +<% end %> diff --git a/app/views/splats/edit.html.erb b/app/views/splats/edit.html.erb new file mode 100644 index 000000000..147c6fbad --- /dev/null +++ b/app/views/splats/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :header do %> + +<% end %> + +
+ <%= render "splats/form", splat: @splat %> +
diff --git a/app/views/splats/index.html.erb b/app/views/splats/index.html.erb new file mode 100644 index 000000000..a538cc065 --- /dev/null +++ b/app/views/splats/index.html.erb @@ -0,0 +1,77 @@ +<% content_for :header do %> + +<% end %> + +
+ <% @splats.last(10).each do | splat | %> +
+ + <%= link_to splat, class: "splat__link" do %> +

<%= splat.title %>

+ <% end %> + + <%= ["product", "web", "mobile", "support", "bug", "UI"].sample %> +
+ <% end %> +
+ + +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
    + +
    + +
    diff --git a/app/views/splats/new.html.erb b/app/views/splats/new.html.erb new file mode 100644 index 000000000..aa8fa010a --- /dev/null +++ b/app/views/splats/new.html.erb @@ -0,0 +1,12 @@ +<% content_for :header do %> + +<% end %> + +
    + <%= render "splats/form", splat: @splat %> +
    diff --git a/app/views/splats/show.html.erb b/app/views/splats/show.html.erb new file mode 100644 index 000000000..4c2ee3bdf --- /dev/null +++ b/app/views/splats/show.html.erb @@ -0,0 +1,66 @@ +<% content_for :header do %> + +<% end %> + + +
    + + <%= link_to @splat, class: "splat__link" do %> +

    <%= @splat.title %>

    + <% end %> + + <%= ["product", "web", "mobile", "support", "bug", "UI"].sample %> +
    + +
    + <%= simple_format @splat.body %> +
    + +
    +
    + JZ +
    +
    + Jason Zimdars +
    +
    +

    I'll be speaking in Chicago early next month at the ABA convention and they'll be sharing this resource with all State Bar Presidents. I mentioned Writebook in the intro towards the bottom. The platform is awesome!

    +
    +
    +
    + +
    + JF +
    +
    + Jason Fried +
    +
    +

    Never mind, I nipped home and tried it on Browser Stack. It's working correctly on Windows with Edge, Chrome & Firefox.

    +
    +
    +
    + +
    + JF +
    +
    + Kevin McConnell +
    +
    +

    If this is only happening to one site, and potentially has already resolved itself, then I'll just dig into this on Monday and see if I can find an explanation or a way to reproduce it. Hopefully this isn't a sign of something more common, but so far doesn't sound like it.

    +

    But if you hear about something similar happening to anyone else, please flag it here and I'll look more urgently.

    +
    +
    +
    +
    diff --git a/config/application.rb b/config/application.rb index b05391cae..8c02913c2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -6,7 +6,7 @@ require "rails/all" # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -module Splat +module SplatApp class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.1 diff --git a/config/routes.rb b/config/routes.rb index 899385096..f75e6b678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,8 @@ Rails.application.routes.draw do - root "sessions#show" + root "splats#index" resource :session + resources :splats get "up" => "rails/health#show", as: :rails_health_check end diff --git a/db/migrate/20240723192954_create_splats.rb b/db/migrate/20240723192954_create_splats.rb new file mode 100644 index 000000000..3cb276548 --- /dev/null +++ b/db/migrate/20240723192954_create_splats.rb @@ -0,0 +1,11 @@ +class CreateSplats < ActiveRecord::Migration[8.0] + def change + create_table :splats do |t| + t.string :title + t.text :body + t.string :color + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index e785beea5..1e3f77621 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2024_06_21_150944) do +ActiveRecord::Schema[8.0].define(version: 2024_07_23_192954) do create_table "organizations", force: :cascade do |t| t.string "name", null: false t.datetime "created_at", null: false @@ -30,6 +30,14 @@ ActiveRecord::Schema[8.0].define(version: 2024_06_21_150944) do t.index ["user_id"], name: "index_sessions_on_user_id" end + create_table "splats", force: :cascade do |t| + t.string "title" + t.text "body" + t.string "color" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "users", force: :cascade do |t| t.integer "organization_id", null: false t.string "name", null: false diff --git a/test/controllers/splats_controller_test.rb b/test/controllers/splats_controller_test.rb new file mode 100644 index 000000000..d1d94a8ee --- /dev/null +++ b/test/controllers/splats_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class SplatsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/fixtures/splats.yml b/test/fixtures/splats.yml new file mode 100644 index 000000000..e2299fbd6 --- /dev/null +++ b/test/fixtures/splats.yml @@ -0,0 +1,16 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: The logo isn't big enough + body: Make the logo bigger. + color: dodgerblue + +two: + title: Layout is broken + body: The page scrolls horizontally on mobile devices. + color: tomato + +three: + title: The text is too small + body: Increase the font size. + color: limegreen diff --git a/test/models/splat_test.rb b/test/models/splat_test.rb new file mode 100644 index 000000000..4e0da5054 --- /dev/null +++ b/test/models/splat_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class SplatTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end