docbrown/app/views/articles/_sticky_nav.html.erb
Suzanne Aitchison 1a417174c3
Profile Preview Cards (RFC #222): Article page author byline (#13990)
* move current profile card content to shared view, create profile preview card shared view

* article page: show link in small screens, button with preview card in larger

* initialize the hover and click functionality

* tweak class names

* make sure modals sit at highest elevation level

* add cypress tests

* add a test to make sure mobile view unaffected

* make sure follow buttons initialized in test before asserting on them
2021-06-21 08:38:47 +01:00

57 lines
2.8 KiB
Text

<% @actor = @article.organization || @article.user %>
<div class="crayons-article-sticky grid gap-4 break-word" id="article-show-primary-sticky-nav">
<div class="crayons-card crayons-card--secondary branded-7 p-4 pt-0 gap-4 grid" style="border-top-color: <%= Color::CompareHex.new([user_colors(@actor)[:bg], user_colors(@actor)[:text]]).brightness(0.88) %>;">
<%= render "shared/profile_card_content", actor: @actor, context: "sidebar" %>
</div>
<% cache("article-sticky-nav-articles-#{@article.id}-#{@actor.latest_article_updated_at}", expires_in: 48.hours) do %>
<% if (user_stickies = Articles::GetUserStickies.call(@article, @actor)).present? %>
<div class="crayons-card crayons-card--secondary">
<header class="crayons-card__header">
<h3 class="crayons-subtitle-2">
More from <a href="<%= @actor.path %>"><%= @actor.name %></a>
</h3>
</header>
<div>
<% user_stickies.each_with_index do |article, index| %>
<a class="crayons-link crayons-link--contentful" href="<%= article.path %>">
<%= article.title %>
<div class="crayons-link__secondary -ml-1">
<% article.decorate.cached_tag_list_array.each do |tag| %>
<span class="crayons-tag"><span class="crayons-tag__prefix">#</span><%= tag %></span>
<% end %>
</div>
</a>
<% end %>
</div>
</div>
<% elsif (sticky_articles = Articles::SuggestStickies.call(@article)).present? %>
<div class="crayons-card crayons-card--secondary">
<header class="crayons-card__header">
<h3 class="crayons-subtitle-2">
Trending on <a href="<%= app_url %>"><%= community_name %></a>
<%= inline_svg_tag("twemoji/fire.svg", aria: true, class: "crayons-icon crayons-icon--default", title: "Hot") %>
</h3>
</header>
<div>
<% sticky_articles.each_with_index do |article, index| %>
<a class="crayons-link crayons-link--contentful flex" href="<%= article.path %>">
<span class="crayons-avatar mr-2 shrink-0">
<img src="<%= Images::Profile.call(article.cached_user.profile_image_url, length: 90) %>" class="crayons-avatar__image" loading="lazy" alt="<%= article.cached_user.name %> profile image">
</span>
<div>
<%= article.title %>
<div class="crayons-link__secondary -ml-1">
<% article.decorate.cached_tag_list_array.each do |tag| %>
<span class="crayons-tag"><span class="crayons-tag__prefix">#</span><%= tag %></span>
<% end %>
</div>
</div>
</a>
<% end %>
</div>
</div>
<% end %>
<% end %>
</div>