From f34489af02720407c0cd09908230d1e4c52e3a73 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 29 Sep 2019 14:09:47 -0500 Subject: [PATCH] css: factor out shared forum post / comment css. --- .../src/styles/common/messages.scss | 53 +++++++++++++++++++ .../src/styles/specific/comments.scss | 52 ------------------ app/javascript/src/styles/specific/forum.scss | 43 --------------- app/views/comments/_index_by_comment.html.erb | 2 +- .../comments/partials/index/_list.html.erb | 2 +- .../comments/partials/show/_comment.html.erb | 2 +- app/views/comments/show.html.erb | 2 +- app/views/forum_posts/_forum_post.html.erb | 2 +- app/views/forum_posts/_listing.html.erb | 2 +- app/views/forum_posts/show.html.erb | 2 +- 10 files changed, 60 insertions(+), 102 deletions(-) create mode 100644 app/javascript/src/styles/common/messages.scss diff --git a/app/javascript/src/styles/common/messages.scss b/app/javascript/src/styles/common/messages.scss new file mode 100644 index 000000000..9519801ed --- /dev/null +++ b/app/javascript/src/styles/common/messages.scss @@ -0,0 +1,53 @@ +div.list-of-messages { + margin: 1em 0; + + article.message { + display: flex; + margin-top: 2em; + word-wrap: break-word; + padding: 5px; + + &:first-of-type { + margin-top: 1em; + } + + div.author { + flex-basis: 12em; + margin-right: 1em; + + time { + font-style: italic; + } + } + + div.content { + flex: 1; + + menu { + li { + margin-right: 1em; + } + } + } + + @media (max-width: 660px) { + display: block; + margin-top: 3em; + + div.author { + margin: 0 0 1em; + + h4 { + display: inline; + margin-right: 0.5em; + } + + time { + display: inline; + color: var(--muted-text-color); + font-size: 0.8em; + } + } + } + } +} diff --git a/app/javascript/src/styles/specific/comments.scss b/app/javascript/src/styles/specific/comments.scss index 284fe4baa..b0f3b849d 100644 --- a/app/javascript/src/styles/specific/comments.scss +++ b/app/javascript/src/styles/specific/comments.scss @@ -7,16 +7,8 @@ div.comments-for-post { div.list-of-comments { article.comment { - display: flex; - margin-top: 2em; - word-wrap: break-word; - padding: 5px; flex: 1; - &:first-of-type { - margin-top: 1em; - } - &[data-is-sticky="true"] { background: var(--comment-sticky-background-color); } @@ -40,25 +32,6 @@ div.comments-for-post { opacity: 1.0; } } - - div.author { - flex-basis: 12em; - margin-right: 1em; - - time { - font-style: italic; - } - } - - div.content { - flex: 1; - - menu { - li { - margin-right: 1em; - } - } - } } } } @@ -126,27 +99,6 @@ form.edit_comment div.input.boolean { } @media screen and (max-width: 660px) { - div.comments-for-post div.list-of-comments article.comment { - display: block; - margin-top: 3em; - padding: 5px; - - div.author { - margin: 0 0 1em; - - h4 { - display: inline; - margin-right: 0.5em; - } - - time { - display: inline; - color: var(--muted-text-color); - font-size: 0.8em; - } - } - } - div#c-comments div#a-index, div#c-comments div#a-show { margin: 0 0.5em; @@ -171,8 +123,4 @@ form.edit_comment div.input.boolean { } } } - - div.new-comment { - margin: 1em 0; - } } diff --git a/app/javascript/src/styles/specific/forum.scss b/app/javascript/src/styles/specific/forum.scss index b293c0f7e..4b304ab6e 100644 --- a/app/javascript/src/styles/specific/forum.scss +++ b/app/javascript/src/styles/specific/forum.scss @@ -1,13 +1,5 @@ div.list-of-forum-posts { article.forum-post { - display: flex; - margin-top: 2em; - word-wrap: break-word; - - &:first-of-type { - margin-top: 1em; - } - a.voted { font-weight: bold; } @@ -24,18 +16,7 @@ div.list-of-forum-posts { color: var(--forum-vote-down-color); } - div.author { - flex-basis: 12em; - margin-right: 1em; - - time { - font-style: italic; - } - } - div.content { - flex: 1; - .edit_forum_post, .edit_forum_topic { display: none; } @@ -44,10 +25,6 @@ div.list-of-forum-posts { ul.votes { margin: 0.5em 0; } - - li { - margin-right: 1em; - } } } } @@ -86,24 +63,4 @@ div#c-forum-topics { #c-forum-topics #a-show { padding: 0 0.5em; } - - div.list-of-forum-posts article.forum-post { - display: block; - margin-top: 3em; - - div.author { - margin: 0 0 1em; - - h4 { - display: inline; - margin-right: 0.5em; - } - - time { - display: inline; - color: var(--muted-text-color); - font-size: 0.8em; - } - } - } } diff --git a/app/views/comments/_index_by_comment.html.erb b/app/views/comments/_index_by_comment.html.erb index d79f9ead2..03a321ed4 100644 --- a/app/views/comments/_index_by_comment.html.erb +++ b/app/views/comments/_index_by_comment.html.erb @@ -1,5 +1,5 @@
-
+
<% @comments.each do |comment| %> <% if CurrentUser.is_moderator? || (params[:search] && params[:search][:is_deleted] =~ /t/) || !comment.is_deleted? %> <%= content_tag(:div, { id: "post_#{comment.post.id}", class: ["post", *PostPresenter.preview_class(comment.post)].join(" ") }.merge(PostPresenter.data_attributes(comment.post))) do %> diff --git a/app/views/comments/partials/index/_list.html.erb b/app/views/comments/partials/index/_list.html.erb index 480bea2db..a7a712058 100644 --- a/app/views/comments/partials/index/_list.html.erb +++ b/app/views/comments/partials/index/_list.html.erb @@ -11,7 +11,7 @@
<% end %> -
+
<% if comments.present? %> <%= render partial: "comments/partials/show/comment", collection: comments %> <% elsif post.last_commented_at.present? %> diff --git a/app/views/comments/partials/show/_comment.html.erb b/app/views/comments/partials/show/_comment.html.erb index 2dfcf2fae..4a296ff16 100644 --- a/app/views/comments/partials/show/_comment.html.erb +++ b/app/views/comments/partials/show/_comment.html.erb @@ -1,6 +1,6 @@ <% if CurrentUser.is_moderator? || (params[:search] && params[:search][:is_deleted] =~ /t/) || !comment.is_deleted? %> -
-
+
<%= content_tag(:div, { id: "post_#{@comment.post_id}", class: ["post", *PostPresenter.preview_class(@comment.post)].join(" ") }.merge(PostPresenter.data_attributes(@comment.post))) do %>
<% if @comment.post.visible? %> diff --git a/app/views/forum_posts/_forum_post.html.erb b/app/views/forum_posts/_forum_post.html.erb index 0c5826b53..280f1c962 100644 --- a/app/views/forum_posts/_forum_post.html.erb +++ b/app/views/forum_posts/_forum_post.html.erb @@ -1,5 +1,5 @@ <% if forum_post.visible?(CurrentUser.user, ActiveModel::Type::Boolean.new.cast(params.dig(:search, :is_deleted))) %> -
+

<%= link_to_user forum_post.creator %> diff --git a/app/views/forum_posts/_listing.html.erb b/app/views/forum_posts/_listing.html.erb index c2ea69521..93d9e3768 100644 --- a/app/views/forum_posts/_listing.html.erb +++ b/app/views/forum_posts/_listing.html.erb @@ -1,7 +1,7 @@ <%- # forum_post %> <%- # original_forum_post_id %> -
+
<% forum_posts.each do |forum_post| %> <%= render "forum_posts/forum_post", :forum_post => forum_post, :original_forum_post_id => original_forum_post_id %> <% end %> diff --git a/app/views/forum_posts/show.html.erb b/app/views/forum_posts/show.html.erb index 44c844784..b7f6102c8 100644 --- a/app/views/forum_posts/show.html.erb +++ b/app/views/forum_posts/show.html.erb @@ -1,5 +1,5 @@
-
+

Topic: <%= @forum_post.topic.title %>

<%= render "forum_post", :forum_post => @forum_post, :original_forum_post_id => @forum_post.topic.original_post.id %>