From 277644f59d223f6b4081598e3ee5753c7b19b02f Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Mon, 25 Sep 2017 15:21:04 -0400 Subject: [PATCH] improve styling, fix index notifs page --- app/assets/stylesheets/notifications.scss.erb | 38 ++++++++--- app/controllers/notifications_controller.rb | 2 + app/decorators/notification_decorator.rb | 2 +- app/views/notifications/index.html.erb | 2 +- app/views/notifications/mark_read.js.erb | 7 ++ app/views/notifications/mark_unread.js.erb | 7 ++ .../src/Metamaps/GlobalUI/Notifications.js | 14 +++- frontend/src/Metamaps/GlobalUI/index.js | 1 + .../src/components/App/NotificationBox.js | 2 +- frontend/src/components/Notification.js | 68 ++++++++++++++++--- 10 files changed, 121 insertions(+), 22 deletions(-) create mode 100644 app/views/notifications/mark_read.js.erb create mode 100644 app/views/notifications/mark_unread.js.erb diff --git a/app/assets/stylesheets/notifications.scss.erb b/app/assets/stylesheets/notifications.scss.erb index 036652d3..3168f591 100644 --- a/app/assets/stylesheets/notifications.scss.erb +++ b/app/assets/stylesheets/notifications.scss.erb @@ -1,4 +1,6 @@ +$notifications-border-color: #DDDDDD; $unread_notifications_dot_size: 8px; + .unread-notifications-dot { width: $unread_notifications_dot_size; height: $unread_notifications_dot_size; @@ -22,6 +24,7 @@ $unread_notifications_dot_size: 8px; right: 0; top: 50px; box-shadow: 0 3px 6px rgba(0,0,0,0.16); + border: 1px solid $notifications-border-color; .notificationsBoxTriangle { min-width: 0 !important; @@ -31,9 +34,9 @@ $unread_notifications_dot_size: 8px; width: 20px !important; height: 20px !important; margin-left: -10px; - top: -10px; - border-top: 1px solid rgba(49, 72, 67, 0.11) !important; - border-left: 1px solid rgba(49, 72, 67, 0.11) !important; + top: -11px; + border-left: 1px solid $notifications-border-color; + border-top: 1px solid $notifications-border-color; border-bottom: 0 !important; border-right: 0 !important; background-color: #fff; @@ -42,6 +45,11 @@ $unread_notifications_dot_size: 8px; -ms-transform: rotate(45deg); } + ul.notifications { + max-height: 500px; + overflow-y: auto; + } + .notificationsBoxSeeAll { display: block; width: 100%; @@ -51,6 +59,14 @@ $unread_notifications_dot_size: 8px; color: #4fb5c0; border-top: 1px solid rgba(0, 0, 0, 0.1); } + + .notification { + font-size: 13px; + + .notification-body { + border-bottom: 1px solid $notifications-border-color; + } + } } } @@ -121,11 +137,18 @@ $unread_notifications_dot_size: 8px; ul.notifications { list-style: none; + + li:last-child { + .notification-body { + border-bottom: none !important; + } + } } .notification { - padding: 10px; + padding: 10px 10px 0 10px; position: relative; + font-family: 'din-regular', Sans-Serif; &:hover { background: #F6F6F6; @@ -157,9 +180,9 @@ ul.notifications { } .notification-body { - font-family: 'din-regular', Sans-Serif; margin-left: 50px; line-height: 20px; + padding-bottom: 10px; .in-bold { font-family: 'din-medium', Sans-Serif; @@ -180,8 +203,6 @@ ul.notifications { top: 50%; right: 10px; color: #607d8b; - font-size: 13px; - line-height: 13px; margin-top: -6px; } @@ -190,11 +211,12 @@ ul.notifications { float: left; width: 15%; - div { + a, div { position: absolute; top: 50%; margin-top: -10px; text-align: center; + cursor: pointer; } } diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 6f557428..15781a32 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -43,6 +43,7 @@ class NotificationsController < ApplicationController def mark_read @receipt.update(is_read: true) respond_to do |format| + format.js format.json do render json: NotificationDecorator.decorate(@notification, @receipt) end @@ -52,6 +53,7 @@ class NotificationsController < ApplicationController def mark_unread @receipt.update(is_read: false) respond_to do |format| + format.js format.json do render json: NotificationDecorator.decorate(@notification, @receipt) end diff --git a/app/decorators/notification_decorator.rb b/app/decorators/notification_decorator.rb index 5669fb9c..a2f7584b 100644 --- a/app/decorators/notification_decorator.rb +++ b/app/decorators/notification_decorator.rb @@ -38,7 +38,7 @@ class NotificationDecorator id: topic1&.id, name: topic1&.name } - resul[:data][:topic2] = { + result[:data][:topic2] = { id: topic2&.id, name: topic2&.name } diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb index ec9987f6..3efbcb45 100644 --- a/app/views/notifications/index.html.erb +++ b/app/views/notifications/index.html.erb @@ -8,7 +8,7 @@