Add nsfw banner to attachments

This commit is contained in:
Sol Fisher Romanoff 2022-10-25 14:02:07 +03:00 committed by Sam Therapy
parent 3289b410b3
commit 037baa6e58
Signed by: sam
GPG Key ID: 4D8B07C18F31ACBD
3 changed files with 25 additions and 1 deletions

View File

@ -1,4 +1,9 @@
<a class="attachment" href="<%= @url %>">
<%= if @nsfw do %>
<div class="nsfw-banner" alt="<%= @name %>" title="<%= @name %>">
<div>Hover to show content</div>
</div>
<% end %>
<%= case @mediaType do %>
<% "audio" -> %>
<audio class="u-audio" src="<%= @url %>" controls="controls"></audio>

View File

@ -54,7 +54,7 @@
<div class="attachments">
<%= for %{"name" => name, "url" => [url | _]} <- @attachment do %>
<%= render("_attachment.html", %{name: name, url: url["href"],
mediaType: fetch_media_type(url)}) %>
mediaType: fetch_media_type(url), nsfw: @sensitive}) %>
<% end %>
</div>
<% end %>

View File

@ -442,6 +442,7 @@ .attachment {
display: flex;
flex-grow: 1;
justify-content: center;
position: relative;
min-width: 0;
}
@ -464,3 +465,21 @@ .fa-icon {
.status-actions .fa-icon {
height: 1.1em;
}
.nsfw-banner {
position: absolute;
height: 100%;
display: flex;
align-items: center;
}
.nsfw-banner div {
width: 100%;
text-align: center;
}
.nsfw-banner:not(:hover) {
background-color: var(--background);
}
.nsfw-banner:hover div {
display: none;
}