From c72144ff22123d7dc57f7c00efafebc17dd37a11 Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Sun, 2 Apr 2023 00:54:18 +0200 Subject: [PATCH] Add app menu with sign in/out links --- app/assets/stylesheets/application.css | 21 ++++++++++++++++ app/views/layouts/application.html.erb | 14 +++++++++++ app/views/users/index.html.erb | 2 -- config/locales/en.yml | 34 ++------------------------ 4 files changed, 37 insertions(+), 34 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 288b9ab..cb36b90 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -13,3 +13,24 @@ *= require_tree . *= require_self */ + +.app-menu { + height: 2.1em; +} +.app-menu a { + color: black; + float: right; + font-size: 0.9em; + padding: 0.6em; +} +.app-menu a:hover { + background-color: #009ade; + border-radius: 0.2em; + color: white; + cursor: pointer; + text-decoration: none; +} + +a:not(:hover) { + text-decoration: none; +} diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 54c0824..26fa10e 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,6 +11,20 @@ +
+ <%= link_to_if user_signed_in?, t(:sign_out), destroy_user_session_path, + data: { turbo_method: :delete } do + link_to t(:sign_in), new_user_session_path + end %> +
+ + <% if flash[:notice] %> +
<%= flash[:notice] %>
+ <% end %> + <% if flash[:alert] %> +
<%= flash[:alert] %>
+ <% end %> + <%= yield %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index fe4dd5c..e963a40 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,5 +1,3 @@ -

<%= notice %>

-

Users

diff --git a/config/locales/en.yml b/config/locales/en.yml index 8ca56fc..8a1cd48 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,33 +1,3 @@ -# Files in the config/locales directory are used for internationalization -# and are automatically loaded by Rails. If you want to use locales other -# than English, add the necessary files in this directory. -# -# To use the locales, use `I18n.t`: -# -# I18n.t "hello" -# -# In views, this is aliased to just `t`: -# -# <%= t("hello") %> -# -# To use a different locale, set it with `I18n.locale`: -# -# I18n.locale = :es -# -# This would use the information in config/locales/es.yml. -# -# The following keys must be escaped otherwise they will not be retrieved by -# the default I18n backend: -# -# true, false, on, off, yes, no -# -# Instead, surround them with single quotes. -# -# en: -# "true": "foo" -# -# To learn more, please read the Rails Internationalization guide -# available at https://guides.rubyonrails.org/i18n.html. - en: - hello: "Hello world" + sign_in: "Sign in" + sign_out: "Sign out"