UX: Layout issues with topic last visit line. (#13655)

UX: Layout issues with topic last visit line. (#13655)

Remove the calculation of width and instead switch to small action class that automatically sets the width based on the screen size.

diff --git a/app/assets/javascripts/discourse/app/widgets/topic-post-visited-line.js b/app/assets/javascripts/discourse/app/widgets/topic-post-visited-line.js
index 85f8ad9..243ed8c 100644
--- a/app/assets/javascripts/discourse/app/widgets/topic-post-visited-line.js
+++ b/app/assets/javascripts/discourse/app/widgets/topic-post-visited-line.js
@@ -3,16 +3,12 @@ import { createWidget } from "discourse/widgets/widget";
 import { h } from "virtual-dom";
 
 export default createWidget("topic-post-visited-line", {
-  tagName: "div.topic-post-visited-line",
+  tagName: "div.small-action.topic-post-visited",
 
-  buildClasses(attrs) {
-    return [`post-${attrs.post_number}`];
-  },
-
-  html() {
+  html(attrs) {
     return h(
-      "span.topic-post-visited-message",
-      I18n.t("topics.new_messages_marker")
+      `div.topic-post-visited-line.post-${attrs.post_number}}`,
+      h("span.topic-post-visited-message", I18n.t("topics.new_messages_marker"))
     );
   },
 });
diff --git a/app/assets/stylesheets/common/base/topic-post.scss b/app/assets/stylesheets/common/base/topic-post.scss
index 0422dc6..d96570a 100644
--- a/app/assets/stylesheets/common/base/topic-post.scss
+++ b/app/assets/stylesheets/common/base/topic-post.scss
@@ -911,6 +911,29 @@ blockquote > *:last-child {
       order: 8;
     }
   }
+
+  &.topic-post-visited {
+    border-top: none;
+
+    + .small-action {
+      border-top: none;
+    }
+
+    .topic-post-visited-line {
+      text-align: center;
+      border-bottom: 1px solid var(--danger-medium);
+      line-height: 0.1em;
+      margin: 1rem 0px;
+      width: 100%;
+
+      .topic-post-visited-message {
+        background-color: var(--secondary);
+        color: var(--danger-medium);
+        font-size: $font-down-1;
+        padding: 0 8px;
+      }
+    }
+  }
 }
 
 .whisper {
@@ -1030,25 +1053,6 @@ a.mention-group {
   }
 }
 
-.topic-post-visited-line {
-  border-bottom: 1px solid var(--danger-medium);
-  line-height: 0.1em;
-  text-align: center;
-  margin: 1rem 0px;
-
-  .topic-post-visited-message {
-    position: relative; // Chrome needs this, otherwise the line is above the text
-    background-color: var(--secondary);
-    color: var(--danger-medium);
-    font-size: $font-down-1;
-    padding: 0 8px;
-  }
-
-  + .small-action {
-    border-top: none;
-  }
-}
-
 // Select posts
 
 .topic-post {
diff --git a/app/assets/stylesheets/desktop/topic-post.scss b/app/assets/stylesheets/desktop/topic-post.scss
index 0fcaeea..7b29f7b 100644
--- a/app/assets/stylesheets/desktop/topic-post.scss
+++ b/app/assets/stylesheets/desktop/topic-post.scss
@@ -577,12 +577,7 @@ blockquote {
   }
 }
 
-.topic-post-visited-line {
-  width: calc(
-    #{$topic-body-width} + #{$topic-avatar-width} +
-      (#{$topic-body-width-padding} * 2)
-  );
-
+.topic-post-visited {
   + .topic-post {
     .topic-avatar,
     .topic-body {
diff --git a/app/assets/stylesheets/mobile/topic-post.scss b/app/assets/stylesheets/mobile/topic-post.scss
index 3ae4c7f..78ad0a6 100644
--- a/app/assets/stylesheets/mobile/topic-post.scss
+++ b/app/assets/stylesheets/mobile/topic-post.scss
@@ -9,7 +9,7 @@
   }
 }
 
-.topic-post-visited-line {
+.topic-post-visited {
   + .topic-post article {
     border-top: none;
   }

GitHub sha: f57d49ed01c0b3fad6cb68408297f6c22f33e1e0

This commit appears in #13655 which was approved by martin. It was merged by tgxworld.