From 419de4187d49ecea75803a70aa8dcd3013079120 Mon Sep 17 00:00:00 2001 From: Nikita Kholin Date: Tue, 31 Jan 2017 09:33:54 +0200 Subject: [PATCH] Add notifications styling --- .config.reek | 2 +- app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/notifications.sass | 4 ++++ app/helpers/application_helper.rb | 7 +++++++ app/views/layouts/_notifications.html.slim | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 app/assets/stylesheets/notifications.sass diff --git a/.config.reek b/.config.reek index 15b2ca1..397383a 100644 --- a/.config.reek +++ b/.config.reek @@ -31,7 +31,7 @@ UncommunicativeModuleName: IrresponsibleModule: enabled: false UtilityFunction: - enabled: fals + enabled: false "db/migrate": IrresponsibleModule: diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index cbd46a7..64bb297 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1 +1,2 @@ @import "bootstrap"; +@import "notifications" diff --git a/app/assets/stylesheets/notifications.sass b/app/assets/stylesheets/notifications.sass new file mode 100644 index 0000000..ba16c96 --- /dev/null +++ b/app/assets/stylesheets/notifications.sass @@ -0,0 +1,4 @@ +.notifications + position: fixed + bottom: 0px + left: 10px diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..255d0cf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,9 @@ module ApplicationHelper + def flash_key_alert_class(key) + flash_to_alert = { + 'notice' => 'info', + 'alert' => 'danger' + } + flash_to_alert[key] + end end diff --git a/app/views/layouts/_notifications.html.slim b/app/views/layouts/_notifications.html.slim index 22f12f7..c642507 100644 --- a/app/views/layouts/_notifications.html.slim +++ b/app/views/layouts/_notifications.html.slim @@ -1,5 +1,5 @@ .notifications - flash.each do |key, value| - div class="alert alert-#{key}" + div class="alert alert-#{flash_key_alert_class(key)}" = value a.close[href="#" data-dismiss="alert"] ×