diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be794..b2ddb195 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,10 @@ module ApplicationHelper + def classes_for_flash(flash_type) + case flash_type.to_sym + when :error + 'bg-red-100 text-red-700 border-red-300' + else + 'bg-blue-100 text-blue-700 border-blue-300' + end + end end diff --git a/app/javascript/application.js b/app/javascript/application.js index 22b4d7e5..caea8389 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,4 +1,5 @@ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails import "@rails/actioncable" +import "controllers" import "@hotwired/turbo-rails" diff --git a/app/javascript/controllers/application.js b/app/javascript/controllers/application.js new file mode 100644 index 00000000..1213e85c --- /dev/null +++ b/app/javascript/controllers/application.js @@ -0,0 +1,9 @@ +import { Application } from "@hotwired/stimulus" + +const application = Application.start() + +// Configure Stimulus development experience +application.debug = false +window.Stimulus = application + +export { application } diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js new file mode 100644 index 00000000..02977bf0 --- /dev/null +++ b/app/javascript/controllers/index.js @@ -0,0 +1,5 @@ +import { application } from "controllers/application" + +// Eager load all controllers defined in the import map under controllers/**/*_controller +import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" +eagerLoadControllersFrom("controllers", application) diff --git a/app/javascript/controllers/removals_controller.js b/app/javascript/controllers/removals_controller.js new file mode 100644 index 00000000..9d4172df --- /dev/null +++ b/app/javascript/controllers/removals_controller.js @@ -0,0 +1,7 @@ +import { Controller } from "@hotwired/stimulus" + +export default class extends Controller { + remove() { + this.element.remove() + } +} diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 1467b9ec..9400a564 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,5 +1,5 @@
-
+

Edit your account!

And change this text!

diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index c73cb58d..2088f026 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,5 +1,5 @@
-
+

Register now!

And change this text!

diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index d89afc2c..b0653930 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,5 +1,5 @@
-
+

Login now!

And change this text!

diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb index 7a75304b..7cea86dc 100644 --- a/app/views/devise/shared/_links.html.erb +++ b/app/views/devise/shared/_links.html.erb @@ -1,25 +1,37 @@ -<%- if controller_name != 'sessions' %> - <%= link_to "Log in", new_session_path(resource_name) %>
-<% end %> - -<%- if devise_mapping.registerable? && controller_name != 'registrations' %> - <%= link_to "Sign up", new_registration_path(resource_name) %>
-<% end %> - -<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> - <%= link_to "Forgot your password?", new_password_path(resource_name) %>
-<% end %> - -<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> - <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
-<% end %> - -<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> - <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
-<% end %> - -<%- if devise_mapping.omniauthable? %> - <%- resource_class.omniauth_providers.each do |provider| %> - <%= button_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), data: { turbo: false } %>
+
+ <%- if controller_name != 'sessions' %> +
+ <%= link_to "Log in", new_session_path(resource_name) %> +
<% end %> -<% end %> + + <%- if devise_mapping.registerable? && controller_name != 'registrations' %> +
+ <%= link_to "Sign up", new_registration_path(resource_name) %> +
+ <% end %> + + <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> +
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %> +
+ <% end %> + + <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> +
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %> +
+ <% end %> + + <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> +
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %> +
+ <% end %> + + <%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= button_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), data: { turbo: false } %>
+ <% end %> + <% end %> +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index fb9d097b..7a24777d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -44,6 +44,7 @@
<%= render 'shared/navbar' %> + <%= render 'shared/flash' %> <%= yield %>
diff --git a/app/views/shared/_flash.html.erb b/app/views/shared/_flash.html.erb new file mode 100644 index 00000000..5b01dbdd --- /dev/null +++ b/app/views/shared/_flash.html.erb @@ -0,0 +1,11 @@ +<% flash.each do |key, value| %> +
+
<%= value %>
+ + +
+<% end %> diff --git a/config/importmap.rb b/config/importmap.rb index 66b0f6ef..c9c7ca01 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -5,4 +5,6 @@ pin_all_from "app/javascript/channels", under: "channels" pin "application", preload: true pin "@rails/actioncable", to: "actioncable.esm.js" pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true - +pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true +pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true +pin_all_from "app/javascript/controllers", under: "controllers"