From 2b37f00960525bb86d44f525f63db83754ce8a3f Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Fri, 25 Nov 2016 11:39:10 -0500 Subject: [PATCH] add more styling to the notification pages --- app/assets/stylesheets/notifications.scss | 53 ++++++++++++++++++++-- app/views/notifications/index.html.erb | 18 ++++---- app/views/notifications/mark_read.js.erb | 3 ++ app/views/notifications/mark_unread.js.erb | 3 ++ app/views/notifications/show.html.erb | 10 ++-- 5 files changed, 68 insertions(+), 19 deletions(-) diff --git a/app/assets/stylesheets/notifications.scss b/app/assets/stylesheets/notifications.scss index 7c3d6bfa..95564a51 100644 --- a/app/assets/stylesheets/notifications.scss +++ b/app/assets/stylesheets/notifications.scss @@ -2,10 +2,53 @@ ul.notifications { list-style: none; } -} -$menu_bar_height: 6em; -.notificationsPage { - margin: 1em; - margin-top: 1em + $menu_bar_height; + $menu_bar_height: 6em; + .notificationPage, + .notificationsPage { + width: auto; + max-width: 100%; + box-sizing: border-box; + margin: 1em; + margin-top: 1em + $menu_bar_height; + + & > .title { + border-bottom: 1px solid #eee; + padding-bottom: 0.25em; + margin-bottom: 0.5em; + } + + .back { + margin-top: 1em; + } + } + + + .notification { + .notification-subject { + width: 25%; + } + .notification-body { + width: 50%; + } + .notification-read-unread { + width: 10%; + } + + .notification-body, + .notification-subject, + .notification-read-unread { + display: inline-block; + vertical-align: top; + font-weight: 300; + } + + &.unread { + .notification-body, + .notification-subject, + .notification-read-unread { + font-weight: bold; + } + } + } } diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb index 6a98c75b..50a455a3 100644 --- a/app/views/notifications/index.html.erb +++ b/app/views/notifications/index.html.erb @@ -3,24 +3,24 @@
-

Notifications

+

My Notifications

    <% @notifications.each do |notification| %> <% receipt = @receipts.find_by(notification_id: notification.id) %> -
  • - +
  • +
    <%= link_to notification.subject, notification_path(notification.id) %> - - - <%= notification.body.truncate(140) %> - - +
    +
    + <%= notification.body.truncate(70) %> +
    +
    <% if receipt.is_read? %> <%= link_to '(read)', mark_unread_notification_path(notification.id), remote: true, method: :put %> <% else %> <%= link_to '(unread)', mark_read_notification_path(notification.id), remote: true, method: :put %> <% end %> - +
  • <% end %>
diff --git a/app/views/notifications/mark_read.js.erb b/app/views/notifications/mark_read.js.erb index 2083516e..631f3f0d 100644 --- a/app/views/notifications/mark_read.js.erb +++ b/app/views/notifications/mark_read.js.erb @@ -1,3 +1,6 @@ $('#notification-<%= @notification.id %> .notification-read-unread > a') .text('(read)') .attr('href', '<%= mark_unread_notification_path(@notification.id) %>') +$('#notification-<%= @notification.id %>') + .removeClass('unread') + .addClass('read') diff --git a/app/views/notifications/mark_unread.js.erb b/app/views/notifications/mark_unread.js.erb index ca8267b9..cc17c4d1 100644 --- a/app/views/notifications/mark_unread.js.erb +++ b/app/views/notifications/mark_unread.js.erb @@ -1,3 +1,6 @@ $('#notification-<%= @notification.id %> .notification-read-unread > a') .text('(unread)') .attr('href', '<%= mark_read_notification_path(@notification.id) %>') +$('#notification-<%= @notification.id %>') + .removeClass('read') + .addClass('unread') diff --git a/app/views/notifications/show.html.erb b/app/views/notifications/show.html.erb index 922668c3..206e8df0 100644 --- a/app/views/notifications/show.html.erb +++ b/app/views/notifications/show.html.erb @@ -2,12 +2,12 @@ <% content_for :mobile_title, 'Notifications' %>
-
-

<%= @notification.subject %>

-
+
+

<%= @notification.subject %>

<%= @notification.body %> -
- <%= link_to 'Back', notifications_path %> +
+ <%= link_to 'Back', notifications_path %> +