diff --git a/Gemfile b/Gemfile index bbd483bf..c30c9ea9 100644 --- a/Gemfile +++ b/Gemfile @@ -7,11 +7,11 @@ gem "rails", github: "rails/rails", branch: "main" gem "bcrypt", "~> 3.1.20" gem "bootsnap", require: false -gem "bootstrap", github: 'twbs/bootstrap-rubygem' # v 5.3.3 should fix the problem, but not released yet -gem "dartsass-rails", "~> 0.5.0" +gem "dartsass-rails" gem "importmap-rails" gem "jbuilder" gem "pg", "~> 1.5" +gem "primer_view_components", "~> 0.27" gem "propshaft" gem "puma", "~> 6.4" gem "rails-i18n" diff --git a/Gemfile.lock b/Gemfile.lock index 2af7b565..fcb98ceb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,31 +1,31 @@ GIT remote: https://github.com/rails/rails.git - revision: e98f4d8496fbc6dd9ffb93202981b4f804e388c1 + revision: 4bb73233413f30fd7217bd7f08af44963f5832b1 branch: main specs: - actioncable (8.0.0.alpha) - actionpack (= 8.0.0.alpha) - activesupport (= 8.0.0.alpha) + actioncable (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (8.0.0.alpha) - actionpack (= 8.0.0.alpha) - activejob (= 8.0.0.alpha) - activerecord (= 8.0.0.alpha) - activestorage (= 8.0.0.alpha) - activesupport (= 8.0.0.alpha) + actionmailbox (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + activejob (= 7.2.0.alpha) + activerecord (= 7.2.0.alpha) + activestorage (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) mail (>= 2.8.0) - actionmailer (8.0.0.alpha) - actionpack (= 8.0.0.alpha) - actionview (= 8.0.0.alpha) - activejob (= 8.0.0.alpha) - activesupport (= 8.0.0.alpha) + actionmailer (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + actionview (= 7.2.0.alpha) + activejob (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.0.0.alpha) - actionview (= 8.0.0.alpha) - activesupport (= 8.0.0.alpha) + actionpack (7.2.0.alpha) + actionview (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) nokogiri (>= 1.8.5) racc rack (>= 2.2.4) @@ -34,89 +34,78 @@ GIT rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (8.0.0.alpha) - actionpack (= 8.0.0.alpha) - activerecord (= 8.0.0.alpha) - activestorage (= 8.0.0.alpha) - activesupport (= 8.0.0.alpha) + actiontext (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + activerecord (= 7.2.0.alpha) + activestorage (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (8.0.0.alpha) - activesupport (= 8.0.0.alpha) + actionview (7.2.0.alpha) + activesupport (= 7.2.0.alpha) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (8.0.0.alpha) - activesupport (= 8.0.0.alpha) + activejob (7.2.0.alpha) + activesupport (= 7.2.0.alpha) globalid (>= 0.3.6) - activemodel (8.0.0.alpha) - activesupport (= 8.0.0.alpha) - activerecord (8.0.0.alpha) - activemodel (= 8.0.0.alpha) - activesupport (= 8.0.0.alpha) + activemodel (7.2.0.alpha) + activesupport (= 7.2.0.alpha) + activerecord (7.2.0.alpha) + activemodel (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) timeout (>= 0.4.0) - activestorage (8.0.0.alpha) - actionpack (= 8.0.0.alpha) - activejob (= 8.0.0.alpha) - activerecord (= 8.0.0.alpha) - activesupport (= 8.0.0.alpha) + activestorage (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + activejob (= 7.2.0.alpha) + activerecord (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) marcel (~> 1.0) - activesupport (8.0.0.alpha) + activesupport (7.2.0.alpha) base64 bigdecimal - concurrent-ruby (~> 1.0, >= 1.3.1) + concurrent-ruby (~> 1.0, >= 1.0.2) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) - logger (>= 1.4.2) - minitest (>= 5.1) + minitest (>= 5.1, < 5.22.0) tzinfo (~> 2.0, >= 2.0.5) - rails (8.0.0.alpha) - actioncable (= 8.0.0.alpha) - actionmailbox (= 8.0.0.alpha) - actionmailer (= 8.0.0.alpha) - actionpack (= 8.0.0.alpha) - actiontext (= 8.0.0.alpha) - actionview (= 8.0.0.alpha) - activejob (= 8.0.0.alpha) - activemodel (= 8.0.0.alpha) - activerecord (= 8.0.0.alpha) - activestorage (= 8.0.0.alpha) - activesupport (= 8.0.0.alpha) + rails (7.2.0.alpha) + actioncable (= 7.2.0.alpha) + actionmailbox (= 7.2.0.alpha) + actionmailer (= 7.2.0.alpha) + actionpack (= 7.2.0.alpha) + actiontext (= 7.2.0.alpha) + actionview (= 7.2.0.alpha) + activejob (= 7.2.0.alpha) + activemodel (= 7.2.0.alpha) + activerecord (= 7.2.0.alpha) + activestorage (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) bundler (>= 1.15.0) - railties (= 8.0.0.alpha) - railties (8.0.0.alpha) - actionpack (= 8.0.0.alpha) - activesupport (= 8.0.0.alpha) - irb (~> 1.13) + railties (= 7.2.0.alpha) + railties (7.2.0.alpha) + actionpack (= 7.2.0.alpha) + activesupport (= 7.2.0.alpha) + irb rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) -GIT - remote: https://github.com/twbs/bootstrap-rubygem.git - revision: f240cae79fb1dcb55abcb4fc9710544134ef8ec2 - specs: - bootstrap (5.3.3) - autoprefixer-rails (>= 9.1.0) - popper_js (>= 2.11.8, < 3) - GEM remote: https://rubygems.org/ specs: addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) - autoprefixer-rails (10.4.16.0) - execjs (~> 2) base64 (0.2.0) bcrypt (3.1.20) - bigdecimal (3.1.8) + bigdecimal (3.1.7) bindex (0.8.1) bootsnap (1.18.3) msgpack (~> 1.2) - builder (3.3.0) + builder (3.2.4) capybara (3.40.0) addressable matrix @@ -126,20 +115,20 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - concurrent-ruby (1.3.3) + concurrent-ruby (1.2.3) connection_pool (2.4.1) crass (1.0.6) dartsass-rails (0.5.0) railties (>= 6.0.0) sass-embedded (~> 1.63) date (3.3.4) - debug (1.9.2) + debug (1.9.1) irb (~> 1.10) reline (>= 0.3.8) diff-lcs (1.5.1) - drb (2.2.1) - erubi (1.13.0) - execjs (2.9.1) + drb (2.2.0) + ruby2_keywords + erubi (1.12.0) factory_bot (6.4.5) activesupport (>= 5.0.0) factory_bot_rails (6.4.3) @@ -147,21 +136,22 @@ GEM railties (>= 5.0.0) globalid (1.2.1) activesupport (>= 6.1) - google-protobuf (3.23.4) - i18n (1.14.5) + google-protobuf (4.27.2) + bigdecimal + rake (>= 13) + i18n (1.14.1) concurrent-ruby (~> 1.0) importmap-rails (2.0.1) actionpack (>= 6.0.0) activesupport (>= 6.0.0) railties (>= 6.0.0) io-console (0.7.2) - irb (1.14.0) - rdoc (>= 4.0.0) + irb (1.11.2) + rdoc reline (>= 0.4.2) - jbuilder (2.12.0) + jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) - logger (1.6.0) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -174,23 +164,30 @@ GEM matrix (0.4.2) method_source (1.1.0) mini_mime (1.1.5) - minitest (5.24.1) + mini_portile2 (2.8.5) + minitest (5.21.2) msgpack (1.7.2) - net-imap (0.4.14) + net-imap (0.4.10) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.5.0) + net-smtp (0.4.0.1) net-protocol - nio4r (2.7.3) - nokogiri (1.16.6-x86_64-linux) + nio4r (2.7.0) + nokogiri (1.16.2) + mini_portile2 (~> 2.8.2) racc (~> 1.4) - pg (1.5.6) - popper_js (2.11.8) - propshaft (0.9.0) + octicons (19.10.0) + pg (1.5.4) + primer_view_components (0.27.0) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) + octicons (>= 18.0.0) + view_component (>= 3.1, < 4.0) + propshaft (0.8.0) actionpack (>= 7.0.0) activesupport (>= 7.0.0) rack @@ -200,8 +197,8 @@ GEM public_suffix (5.0.4) puma (6.4.2) nio4r (~> 2.0) - racc (1.8.0) - rack (3.1.7) + racc (1.7.3) + rack (3.0.9) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -219,51 +216,50 @@ GEM rails-i18n (7.0.9) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - rake (13.2.1) - rdoc (6.7.0) + rake (13.1.0) + rdoc (6.6.2) psych (>= 4.0.0) redis (5.2.0) redis-client (>= 0.22.0) - redis-client (0.22.1) + redis-client (0.22.2) connection_pool regexp_parser (2.9.0) - reline (0.5.9) + reline (0.4.2) io-console (~> 0.5) - rexml (3.3.0) - strscan + rexml (3.2.6) rspec-core (3.13.0) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) + rspec-mocks (3.13.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (6.1.3) + rspec-rails (6.1.1) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) - rspec-core (~> 3.13) - rspec-expectations (~> 3.13) - rspec-mocks (~> 3.13) - rspec-support (~> 3.13) - rspec-support (3.13.1) + rspec-core (~> 3.12) + rspec-expectations (~> 3.12) + rspec-mocks (~> 3.12) + rspec-support (~> 3.12) + rspec-support (3.13.0) + ruby2_keywords (0.0.5) rubyzip (2.3.2) - sass-embedded (1.63.6-x86_64-linux-gnu) - google-protobuf (~> 3.23) - selenium-webdriver (4.22.0) + sass-embedded (1.77.5) + google-protobuf (>= 3.25, < 5.0) + rake (>= 13) + selenium-webdriver (4.17.0) base64 (~> 0.2) - logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) stimulus-rails (1.3.3) railties (>= 6.0.0) - stringio (3.1.1) - strscan (3.1.0) - thor (1.3.1) + stringio (3.1.0) + thor (1.3.0) timeout (0.4.1) - turbo-rails (2.0.5) + turbo-rails (2.0.0) actionpack (>= 6.0.0) activejob (>= 6.0.0) railties (>= 6.0.0) @@ -286,22 +282,22 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.16) + zeitwerk (2.6.13) PLATFORMS - x86_64-linux + ruby DEPENDENCIES bcrypt (~> 3.1.20) bootsnap - bootstrap! capybara - dartsass-rails (~> 0.5.0) + dartsass-rails debug factory_bot_rails importmap-rails jbuilder pg (~> 1.5) + primer_view_components (~> 0.27) propshaft puma (~> 6.4) rails! diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 4028c22a..7d4505c5 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -2,3 +2,6 @@ //= link_tree ../../javascript .js //= link_tree ../../../vendor/javascript .js //= link_tree ../builds + +//= link application.css +//= link primer_view_components.css diff --git a/app/assets/stylesheets/application.bootstrap.scss b/app/assets/stylesheets/application.bootstrap.scss deleted file mode 100644 index 070ef4c0..00000000 --- a/app/assets/stylesheets/application.bootstrap.scss +++ /dev/null @@ -1,3 +0,0 @@ -// @import url("https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"); - -@import "bootstrap"; diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index d193a343..e56bec95 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,3 +1,4 @@ // Entry point for your Sass build -@import "./application.bootstrap.scss" +//= link primer_view_components.css +@import url("https://unpkg.com/@primer/css@^21.1.1/dist/primer.css") diff --git a/app/components/alert_component.html.erb b/app/components/alert_component.html.erb index 6486d3a7..b3ce7a9d 100644 --- a/app/components/alert_component.html.erb +++ b/app/components/alert_component.html.erb @@ -1,4 +1 @@ -<% alert_name = @message_type.to_sym == :alert ? 'danger' : 'success' %> -
- <%= @message %> -
+<%= render(Primer::Alpha::Banner.new(scheme: @message_type)) { @message } %> diff --git a/app/components/alert_component.rb b/app/components/alert_component.rb index f93e3887..b28ef1d1 100644 --- a/app/components/alert_component.rb +++ b/app/components/alert_component.rb @@ -2,7 +2,7 @@ class AlertComponent < ViewComponent::Base def initialize(message_type:, message:) - @message_type = message_type + @message_type = message_type.to_sym @message = message end end diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index b0378f8a..c1e1b298 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -26,8 +26,10 @@ def create @event.organizer_id = current_user.id if @event.save - redirect_to @event, notice: 'Event was successfully created.' + flash[:success] = 'Event was successfully created.' + redirect_to @event else + flash.now[:warning] = @event.errors.full_messages.join(', ') render :new end end @@ -35,8 +37,10 @@ def create # PATCH/PUT /events/1 def update if @event.update(event_params) - redirect_to @event, notice: 'Event was successfully updated.' + flash[:success] = 'Event was successfully updated.' + redirect_to @event else + flash.now[:warning] = @event.errors.full_messages.join(', ') render :edit end end @@ -44,7 +48,8 @@ def update # DELETE /events/1 def destroy @event.destroy - redirect_to events_url, notice: 'Event was successfully destroyed.' + flash[:success] = 'Event was successfully destroyed.' + redirect_to events_url end private diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 4a43f9f3..4f9b62c7 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -9,10 +9,10 @@ def create @user = User.new(user_params) if @user.save - flash[:notice] = 'ユーザー登録しました' + flash[:success] = 'ユーザー登録しました' redirect_to login_path else - flash.now[:alert] = @user.errors.full_messages.join(", ") + flash.now[:warning] = @user.errors.full_messages.join(", ") render :new, status: :unprocessable_entity end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 503d2a51..7e7dd23c 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -8,16 +8,17 @@ def create if user session[:user_id] = user.id - flash[:notice] = 'ログインに成功しました' + flash[:success] = 'ログインに成功しました' redirect_to events_path else - flash.now[:alert] = 'ログインに失敗しました' + flash.now[:warning] = 'ログインに失敗しました' render :new, status: :unauthorized end end def destroy session[:user_id] = nil + flash[:success] = 'ログアウトしました' redirect_to login_path end end diff --git a/app/forms/application_form.rb b/app/forms/application_form.rb new file mode 100644 index 00000000..43ba29c1 --- /dev/null +++ b/app/forms/application_form.rb @@ -0,0 +1,2 @@ +class ApplicationForm < Primer::Forms::Base +end diff --git a/app/forms/event_form.rb b/app/forms/event_form.rb new file mode 100644 index 00000000..9d1469fd --- /dev/null +++ b/app/forms/event_form.rb @@ -0,0 +1,56 @@ +class EventForm < ApplicationForm + form do |event_form| + event_form.text_field( + name: :name, + type: "text", + label: 'タイトル', + required: true, + ) + + event_form.text_field( + name: :description, + type: "text", + label: '説明', + required: true, + ) + + event_form.text_field( + name: :location, + type: "text", + label: '場所', + ) + + event_form.text_field( + name: :max_size, + type: "number", + label: '最大人数', + ) + + event_form.text_field( + name: :budget, + type: "text", + label: '予算', + ) + + event_form.text_field( + name: :start_at, + type: "datetime-local", + label: '開始日時', + required: true, + ) + + event_form.text_field( + name: :end_at, + type: "datetime-local", + label: '終了日時', + required: true, + ) + + event_form.submit( + name: :submit, + label: "登録", + scheme: :primary, + mb: 3 + ) + end +end diff --git a/app/forms/login_form.rb b/app/forms/login_form.rb new file mode 100644 index 00000000..4540dde3 --- /dev/null +++ b/app/forms/login_form.rb @@ -0,0 +1,24 @@ +class LoginForm < ApplicationForm + form do |login_form| + login_form.text_field( + name: :email, + type: "email", + label: 'メールアドレス', + required: true, + ) + + login_form.text_field( + name: :password, + type: "password", + label: 'パスワード', + required: true, + ) + + login_form.submit( + name: :submit, + label: 'ログイン', + scheme: :primary, + mb: 3 + ) + end +end diff --git a/app/forms/participant_form.rb b/app/forms/participant_form.rb new file mode 100644 index 00000000..87471822 --- /dev/null +++ b/app/forms/participant_form.rb @@ -0,0 +1,9 @@ +class ParticipantForm < ApplicationForm + form do |participant_form| + participant_form.submit( + name: :submit, + label: "参加する", + scheme: :primary, + ) + end +end diff --git a/app/forms/signup_form.rb b/app/forms/signup_form.rb new file mode 100644 index 00000000..7e2ff0fe --- /dev/null +++ b/app/forms/signup_form.rb @@ -0,0 +1,41 @@ +class SignupForm < ApplicationForm + form do |signup_form| + signup_form.text_field( + name: :name, + type: "text", + label: '名前', + required: true, + ) + + signup_form.text_field( + name: :email, + type: "email", + label: 'メールアドレス', + required: true, + ) + + signup_form.text_field( + name: :password, + type: "password", + label: 'パスワード', + required: true, + ) + + signup_form.text_field( + name: :password_confirmation, + type: "password", + label: 'パスワード(確認用)', + required: true, + ) + + signup_form.submit( + name: :submit, + label: '登録', + scheme: :primary, + mb: 3 + ) + end + + def initialize() + end +end diff --git a/app/javascript/application.js b/app/javascript/application.js index e4c65a4d..9c3b25a6 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,4 +1,2 @@ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails -import * as Popper from "@popperjs/core"; -import * as Bootstrap from "bootstrap"; import "@hotwired/turbo-rails"; diff --git a/app/views/events/_form.erb b/app/views/events/_form.erb index 4912df2e..23f34bac 100644 --- a/app/views/events/_form.erb +++ b/app/views/events/_form.erb @@ -1,32 +1,3 @@ -<%= form_with model: @event do |form| %> -
- <%= form.label :start_at %> - <%= form.datetime_select :start_at, {}, class: "form-control" %> -
- -
- <%= form.label :end_at %> - <%= form.datetime_select :end_at, {}, class: "form-control" %> -
-
- <%= form.label :location %> - <%= form.text_field :location, class: "form-control" %> -
-
- <%= form.label :name %> - <%= form.text_field :name, class: "form-control" %> -
-
- <%= form.label :max_size %> - <%= form.number_field :max_size, class: "form-control" %> -
-
- <%= form.label :budget %> - <%= form.text_field :budget, class: "form-control" %> -
-
- <%= form.label :description %> - <%= form.text_area :description, class: "form-control" %> -
- <%= form.submit nil, class: "btn btn-primary" %> +<%= render(Primer::Box.new(m: 3)) do %> + <%= render(EventForm.new(f)) %> <% end %> diff --git a/app/views/events/edit.html.erb b/app/views/events/edit.html.erb index c97f6612..bcceddb1 100644 --- a/app/views/events/edit.html.erb +++ b/app/views/events/edit.html.erb @@ -1,6 +1,11 @@ -

編集

+<%= render(Primer::Box.new(m: 3)) do %> +

編集

-<%= render 'form' %> - -
<%= link_to 'トップへ戻る', root_path %>
+ <%= primer_form_with local: true, model: @event do |f| %> + <%= render 'form', { f: f } %> + <% end %> + <%= render(Primer::Beta::Link.new(href: root_path)) do %> + トップへ戻る + <% end %> +<% end %> diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index 1a7d1985..d60d3d39 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -1,23 +1,34 @@ -

イベント一覧

+<%= render(Primer::Box.new(m: 3)) do %> +

イベント一覧

+ +
+
+
+ # +
+
+ イベント名 +
+
+ 説明 +
+
- - - - - - - - - <% @events.each do |event| %> - - - - - +
+
+ <%= event.id %> +
+
+ <%= link_to event.name, event %> +
+
+ <%= event.description %> +
+
<% end %> - -
#イベント名説明
<%= event.id %><%= link_to event.name, event %><%= event.description %>
+
+<% end %> <% if current_user %> <%= link_to '新規作成', new_event_path, class: "btn btn-primary" %> diff --git a/app/views/events/new.html.erb b/app/views/events/new.html.erb index 9f45aee8..a6fec379 100644 --- a/app/views/events/new.html.erb +++ b/app/views/events/new.html.erb @@ -1,5 +1,11 @@ -

新規作成

+<%= render(Primer::Box.new(m: 3)) do %> +

新規作成

-<%= render 'form' %> + <%= primer_form_with local: true, model: @event, url: events_path do |f| %> + <%= render 'form', { f: f } %> + <% end %> -
<%= link_to 'トップへ戻る', root_path %>
+ <%= render(Primer::Beta::Link.new(href: root_path)) do %> + トップへ戻る + <% end %> +<% end %> diff --git a/app/views/events/show.html.erb b/app/views/events/show.html.erb index 24b75eea..14249cdb 100644 --- a/app/views/events/show.html.erb +++ b/app/views/events/show.html.erb @@ -1,38 +1,98 @@ -

<%= @event.name %>

- - - - <% if @event.organizer?(current_user) %> -
<%= link_to '編集', edit_event_path(@event) %>
-
<%= link_to "このイベントを削除", event_path(@event), data: { turbo_method: :delete, turbo_confirm: "削除しますか?" } %>
+ + <%= render(Primer::Box.new(m: 3)) do %> +
+
+
+ 開催日時 +
+
+ <%= @event.start_at %> +
+
+ +
+
+ 終了日時 +
+
+ <%= @event.end_at %> +
+
+ +
+
+ 開催場所 +
+
+ <%= @event.location %> +
+
+ +
+
+ 主催者 +
+
+ <%= @event.organizer.name %> +
+
+ +
+
+ 定員 +
+
+ <%= @event.max_size %>人 +
+
+ +
+
+ 参加費 +
+
+ <%= @event.budget %>円 +
+
+ +
+
+ 詳細 +
+
+ <%= simple_format @event.description %> +
+
+ + <% if current_user && current_user.participatable?(@event) %> +
+
+
+ <%= primer_form_with local: true, url: event_participations_path(@event) do |f| %> + <%= render(ParticipantForm.new(f)) %> + <% end %> +
+
+ <% end %> +
+ <% end %> + + <%= render(Primer::Box.new(m: 3)) do %> + <% if @event.organizer?(current_user) %> + <%= render(Primer::Beta::Button.new(scheme: :link, tag: :a, href: edit_event_path(@event))) do %> + 編集 + <% end %> + <%= render(Primer::Beta::Button.new(scheme: :danger, tag: :a, href: event_path(@event), data: { turbo_method: :delete, turbo_confirm: "削除しますか?" })) do %> + イベントを削除する + <% end %> + <% end %> + + <%= render(Primer::Beta::Button.new(scheme: :link, tag: :a, href: root_path)) do %> + トップへ戻る + <% end %> <% end %> -
<%= link_to 'トップへ戻る', root_path %>
+<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index daefd6ab..058e0dbe 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,29 +6,35 @@ <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= favicon_link_tag('favicon.ico') %> + <%= stylesheet_link_tag("primer_view_components") %> <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> <%= javascript_importmap_tags %> + <%= javascript_include_tag("primer_view_components") %> - + -
+
<% flash.each do |message_type, message| %> <%= render(AlertComponent.new(message_type: message_type, message: message) ) %> <% end %> diff --git a/app/views/registrations/new.html.erb b/app/views/registrations/new.html.erb index 3ff629e9..6b847a5b 100644 --- a/app/views/registrations/new.html.erb +++ b/app/views/registrations/new.html.erb @@ -1,13 +1,6 @@ -<%= form_with url: "/signup", method: :post, model: @user do |form| %> -
- <%= form.label :name %> - <%= form.text_field :name %> - <%= form.label :email %> - <%= form.text_field :email %> - <%= form.label :password %> - <%= form.password_field :password %> - <%= form.label :password_confirmation %> - <%= form.password_field :password_confirmation %> -
- <%= form.submit 'Signup' %> +<%= primer_form_with local: true, model: @user, url: signup_path do |f| %> + <%= render(Primer::Box.new(m: 3)) do %> + <%= render(SignupForm.new(f)) %> + <% end %> <% end %> + diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index ecd032d8..c5e9e572 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,9 +1,5 @@ -<%= form_with local: true, url: sessions_path do |form| %> -
- <%= form.label :email %> - <%= form.text_field :email %> - <%= form.label :password %> - <%= form.password_field :password %> -
- <%= form.submit 'Login' %> +<%= primer_form_with local: true, url: sessions_path do |f| %> + <%= render(Primer::Box.new(m: 3)) do %> + <%= render(LoginForm.new(f)) %> + <% end %> <% end %> diff --git a/config/application.rb b/config/application.rb index 52caabcc..a29ebf87 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,6 +2,9 @@ require "rails/all" +require "view_component" +require "primer/view_components" + # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc deleted file mode 100644 index 55c427ad..00000000 --- a/config/credentials.yml.enc +++ /dev/null @@ -1 +0,0 @@ -e3qEqsxR38wpJ3N3DdGb0bTHkuqZFav4wohdbw+TkhDWYN+7aVg2EDIMjzMdwj4Ln18H/O1tzw9x8Z+KVYakL4+TH5p4jH+W1Z06yp8lPDIK8AugJnxTS488fFfR95OkqScLKS8FCf/kO37A0u3fiJnqIBujOW2qqTRZr4pYTHIiNX1II6G2VgUeuKppf4nXqVInw+3iEAtG9Pkw/PA6kioWOkPe64PoMrA2L6569CzgauBnGMKiOCTCgkNbB/SmeULqEV/+DgnT6MLu1ji9oGwrad1P1kLdWzurc+dkgJpHRo4FqWaVLbLVdNAe1H+3l6G2TMVFBfXLetl+4BDYs6lk+GZlItR6Lwt0NxRe/aRIdmlLyjwaYAUmK8V+aOPEHpHmrry/dNiKLPyZd0ZDCeksvkTy0pGbwmlk--egkZdlyGazur1xGm--gjnXVCoP9JSJu2EKGWFUvA== \ No newline at end of file diff --git a/config/environments/test.rb b/config/environments/test.rb index 6ea4d1e7..47d7bb85 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,6 +10,7 @@ # Turn false under Spring and add config.action_view.cache_template_loading = true. config.cache_classes = true + config.action_view.cache_template_loading = true # Eager loading loads your whole application. When running a single test locally, # this probably isn't necessary. It's a good idea to do in a continuous integration @@ -57,4 +58,10 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + + config.assets.css_compressor = nil + + # config.action_view.raise_on_missing_translations = true + config.primer_view_components.silence_deprecations = true + config.primer_view_components.raise_on_invalid_options = true end diff --git a/db/schema.rb b/db/schema.rb index 95f93e9f..bca6f084 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: 2022_05_12_122510) do +ActiveRecord::Schema[7.2].define(version: 2022_05_12_122510) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/spec/components/alert_component_spec.rb b/spec/components/alert_component_spec.rb index 6a8d1c3a..611480ad 100644 --- a/spec/components/alert_component_spec.rb +++ b/spec/components/alert_component_spec.rb @@ -5,17 +5,23 @@ RSpec.describe AlertComponent, type: :component do it 'render success alert' do render_inline( - described_class.new(message_type: "notice", message: "success message") + described_class.new(message_type: "success", message: "success message") ) - expect(page).to have_selector ".alert-success", text: "success message" - expect(page).not_to have_selector ".alert-danger" + expect(page).to have_selector ".flash-success", text: "success message" + expect(page).not_to have_selector ".flash-warning" + end + + it 'render warning alert' do + render_inline( + described_class.new(message_type: "warning", message: "warning message") + ) + expect(page).to have_selector ".flash-warn", text: "warning message" end it 'render danger alert' do render_inline( - described_class.new(message_type: "alert", message: "danger message") + described_class.new(message_type: "danger", message: "danger message") ) - expect(page).to have_selector ".alert-danger", text: "danger message" - expect(page).not_to have_selector ".alert-success" + expect(page).to have_selector ".flash-error", text: "danger message" end end diff --git a/spec/system/registrations_spec.rb b/spec/system/registrations_spec.rb index 1b5b1fd0..c3335105 100644 --- a/spec/system/registrations_spec.rb +++ b/spec/system/registrations_spec.rb @@ -8,7 +8,7 @@ fill_in :user_email, with: email fill_in :user_password, with: password fill_in :user_password_confirmation, with: password - click_on 'Signup' + click_on '登録' end context "when all in information" do @@ -17,7 +17,7 @@ let(:password) { "test1234" } it "succeed to signup with message" do - within "div.alert-success" do + within "div.flash-success" do expect(page).to have_content("ユーザー登録しました") end end @@ -29,7 +29,7 @@ let(:password) { "" } it "fails to signup with alert message" do - within "div.alert-danger" do + within "div.flash-warn" do expect(page).to have_content("Password を入力してください") expect(page).to have_content("Email を入力してください") expect(page).to have_content("Email の形式が不正です") diff --git a/spec/system/sessions_spec.rb b/spec/system/sessions_spec.rb index 64c073bb..0b176aba 100644 --- a/spec/system/sessions_spec.rb +++ b/spec/system/sessions_spec.rb @@ -8,7 +8,7 @@ visit "/login" fill_in :email, with: email fill_in :password, with: password - click_on 'Login' + find(".Button", :text => "ログイン").click end context "when both email and password are correct" do @@ -16,7 +16,7 @@ let(:password) { user.password } it "enables us to login with email and password" do - within "div.alert-success" do + within "div.flash-success" do expect(page).to have_content("ログインに成功しました") end end @@ -27,7 +27,7 @@ let(:password) { user.password } it "fails to login with alert message" do - within "div.alert-danger" do + within "div.flash-warn" do expect(page).to have_content("ログインに失敗しました") end end @@ -38,7 +38,7 @@ let(:password) { 'wrong_password' } it "fails to login with alert message" do - within "div.alert-danger" do + within "div.flash-warn" do expect(page).to have_content("ログインに失敗しました") end end