docbrown/app/views/articles/_actions.html.erb
zeotuan 9dcb332f4a
Fix Bugs in the "Copy article URL to clipboard" feature #14242 (#14243)
* change readonly input to p tag

* add pointer cursor and focus on copy post url option

* add Enter keypress eventListener to copy post url option

* add test for enter press event, refractor some test to click on copy post url option instead of just the image

* make copy post url font bold

* add scss class sidebar for dropdown && fix sidebar dropdown reaching under topheader in large screen resolution

* resolve conflict with main

* Update _actions.html.erb

* changin markup to improve accessibility

* make variable name appropriate, switch cypress to imitate user interaction

* remove dump file, fix test to use alias
2021-07-20 15:09:24 +01:00

107 lines
4.9 KiB
Text

<div class="crayons-article-actions print-hidden">
<div class="crayons-article-actions__inner">
<% if @article.published? %>
<%= render partial: "articles/reaction_button",
locals: {
category: :like,
description: "Heart",
image_path: "heart.svg",
image_active_path: "heart-filled.svg",
aria_label: "Like"
} %>
<%= render partial: "articles/reaction_button",
locals: {
category: :unicorn,
description: "Unicorn",
image_path: "unicorn.svg",
image_active_path: "unicorn-filled.svg",
aria_label: "React with unicorn"
} %>
<%= render partial: "articles/reaction_button",
locals: {
category: :readinglist,
description: "Saved",
image_path: "save.svg",
image_active_path: "save-filled.svg",
aria_label: "Add to reading list"
} %>
<% end %>
<div class="align-center m:relative">
<button id="article-show-more-button" aria-controls="article-show-more-dropdown" aria-expanded="false" aria-haspopup="true" class="dropbtn crayons-btn crayons-btn--ghost-dimmed crayons-btn--icon-rounded" aria-label="Share post options">
<%= inline_svg_tag("overflow-horizontal.svg", aria_hidden: true, class: "dropdown-icon crayons-icon", title: "More...") %>
</button>
<div id="article-show-more-dropdown" class="crayons-dropdown side-bar left-1 s:left-auto m:left-100">
<div>
<button
id="copy-post-url-button"
class="flex justify-between crayons-link crayons-link--block w-100 bg-transparent border-0"
data-postUrl="<%= article_url(@article) %>">
<span class="fw-bold">Copy Post URL</span>
<%= inline_svg_tag("copy.svg", aria_hidden: true, id: "article-copy-icon", class: "crayons-icon mx-2 shrink-0", title: "Copy article link to the clipboard") %>
</button>
<div id="article-copy-link-announcer" aria-live="polite" class="crayons-notice crayons-notice--success my-2 p-1" aria-live="polite" hidden>Copied to Clipboard</div>
</div>
<div class="Desktop-only">
<a
target="_blank"
class="crayons-link crayons-link--block"
rel="noopener"
href='https://twitter.com/intent/tweet?text=<%= u "\"#{@article.title.strip}\" by " %><%= u @article.user.twitter_username ? "@#{@article.user.twitter_username}" : @article.user.name %><%= u " #{Settings::General.twitter_hashtag} " %><%= u " #{article_url(@article)}" %>'>
Share to Twitter
</a>
<a
target="_blank"
class="crayons-link crayons-link--block"
rel="noopener"
href="https://www.linkedin.com/shareArticle?mini=true&url=<%= u article_url(@article) %>&title=<%= u @article.title %>&summary=<%= u @article.description %>&source=<%= u community_name %>">
Share to LinkedIn
</a>
<a
target="_blank"
class="crayons-link crayons-link--block"
rel="noopener"
href="https://www.reddit.com/submit?url=<%= u article_url(@article) %>&title=<%= u @article.title %>">
Share to Reddit
</a>
<a
target="_blank"
class="crayons-link crayons-link--block"
rel="noopener"
href="https://news.ycombinator.com/submitlink?u=<%= u article_url(@article) %>&t=<%= u @article.title %>">
Share to Hacker News
</a>
<a
target="_blank"
class="crayons-link crayons-link--block"
rel="noopener"
href="https://www.facebook.com/sharer.php?u=<%= u article_url(@article) %>">
Share to Facebook
</a>
</div>
<web-share-wrapper shareurl="<%= article_url(@article) %>" sharetitle="<%= @article.title %>" sharetext="<%= @article.description %>" template="web-share-button">
</web-share-wrapper>
<template id="web-share-button">
<a href="#" class="dropdown-link-row crayons-link crayons-link--block">Share Post via...</a>
</template>
<a href="/report-abuse" class="crayons-link crayons-link--block">Report Abuse</a>
</div>
</div>
</div>
</div>
<% if !user_signed_in? && @article.body_markdown.size > 900 %>
<% cache("below-article-html-variant-#{rand(20)}", expires_in: 8.hours) do %>
<% @html_variant = HtmlVariant.find_for_test(@article.cached_tag_list_array, "article_show_below_article_cta") %>
<% if @html_variant %>
<div class="html-variant-wrapper" id="html-variant-article-show-below-article" data-variant-id="<%= @html_variant.id %>">
<%= @html_variant.html.html_safe %>
</div>
<% end %>
<% end %>
<% end %>