-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-refinements Fcl 448/atom feed link refinements
- Loading branch information
Showing
14 changed files
with
296 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.atom-feed { | ||
&__list { | ||
margin: 0; | ||
padding: 0; | ||
list-style-type: none; | ||
|
||
li { | ||
margin-bottom: $space-4; | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
ds_judgements_public_ui/sass/includes/_copy_to_clipboard_link.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
.copy-to-clipboard-link { | ||
position: relative; | ||
|
||
&:hover { | ||
.copy-to-clipboard-link__tooltip { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
&__tooltip { | ||
position: absolute; | ||
top: 40px; | ||
left: -30px; | ||
|
||
width: 165px; | ||
padding: $space-1 $space-2; | ||
|
||
font-size: $typography-sm-text-size; | ||
text-align: center; | ||
text-decoration: underline; | ||
|
||
opacity: 0; | ||
background: $color-white; | ||
border: 1px solid $color-grey; | ||
border-radius: 5px; | ||
|
||
transition: opacity 0.3s ease; | ||
|
||
&::after { | ||
content: ""; | ||
|
||
position: absolute; | ||
top: -5px; | ||
right: 50%; | ||
transform: rotate(-45deg); | ||
|
||
width: 8px; | ||
height: 8px; | ||
margin-right: -5px; | ||
|
||
background: $color-white; | ||
border-top: 1px solid $color-grey; | ||
border-right: 1px solid $color-grey; | ||
} | ||
|
||
&--copied { | ||
left: 27px; | ||
width: auto; | ||
color: $color-dark-grey; | ||
text-decoration: none; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
ds_judgements_public_ui/static/js/src/modules/copy_link_tooltip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const copyLinkToClipboard = function (event, textToCopy) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
navigator.clipboard.writeText(textToCopy); | ||
}; | ||
|
||
const createTooltipElement = function (text) { | ||
const element = document.createElement("span"); | ||
|
||
element.classList.add("copy-to-clipboard-link__tooltip"); | ||
element.innerHTML = text; | ||
|
||
return element; | ||
}; | ||
|
||
const addCopyLinkTooltip = function (link) { | ||
if (!link || !(link instanceof HTMLElement)) return; | ||
|
||
const tooltipText = link.dataset.copyLinkTooltip; | ||
|
||
const tooltip = createTooltipElement(tooltipText); | ||
|
||
link.append(tooltip); | ||
|
||
link.addEventListener("click", function (event) { | ||
copyLinkToClipboard(event, link.href); | ||
tooltip.innerHTML = "Copied!"; | ||
tooltip.classList.add("copy-to-clipboard-link__tooltip--copied"); | ||
|
||
setTimeout(() => { | ||
tooltip.innerHTML = tooltipText; | ||
tooltip.classList.remove("copy-to-clipboard-link__tooltip--copied"); | ||
}, 3000); | ||
}); | ||
}; | ||
|
||
const setupCopyLinkTooltips = function () { | ||
const links = document.querySelectorAll("[data-copy-link-tooltip]"); | ||
|
||
links.forEach(function (link) { | ||
addCopyLinkTooltip(link); | ||
}); | ||
}; | ||
|
||
document.addEventListener("DOMContentLoaded", setupCopyLinkTooltips); |
7 changes: 5 additions & 2 deletions
7
ds_judgements_public_ui/templates/includes/result_atom_feed_button.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{% load static %} | ||
<div class="results__result-atom-feed-button"> | ||
<img src="{% static "fontawesome-svgs/rss.svg" %}" width="20" height="20" alt=""/> | ||
<a href="{% url 'search-feed' %}?{{ query_param_string }}" >Subscribe to these results</a> | ||
<label>Subscribe to these results</label> | ||
<a href="{% url 'search-feed' %}?{{ query_param_string }}" data-copy-link-tooltip="Copy link and paste into your Atom feed app" class="copy-to-clipboard-link"> | ||
<img src="{% static "fontawesome-svgs/rss.svg" %}" width="20" height="20" alt=""/> | ||
Atom feed | ||
</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{% extends "layouts/static_content.html" %} | ||
{% load query_filters court_utils %} | ||
|
||
{% block static_content %} | ||
<div class="atom-feed"> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-one-third"> | ||
<div class="anchor-links"> | ||
<details class="govuk-details--compact"> | ||
<summary class="govuk-details__summary"> | ||
<span class="govuk-details__summary-text">What is an Atom feed?</span> | ||
</summary> | ||
<div class="govuk-details__text"> | ||
<p>An Atom feed is a data format that contains the latest content from a website, blog, or podcast. You can use feeds to <strong>subscribe</strong> to websites and get the <strong>latest content in one place</strong>.</p> | ||
|
||
<p> | ||
<strong>Feeds put you in control</strong> | ||
<br/> | ||
|
||
Unlike social media apps, there is no algorithm deciding what you see or read. You always get the latest content. | ||
</p> | ||
|
||
<p> | ||
<strong>Feed are private by design</strong> | ||
<br/> | ||
|
||
No one owns web feeds, so no one is harvesting your personal information and profiting by selling it to advertisers. | ||
</p> | ||
|
||
<p> | ||
<strong>Feeds are spam-proof</strong> | ||
<br/> | ||
|
||
Had enough? Easy, just unsubscribe from the feed. | ||
</p> | ||
|
||
<p> | ||
All you need to do to get started is to add the URL (web address) for this feed to a special app called a newsreader. Visit <a href="">About Feeds</a> to get started with newsreaders and subscribing. It’s free. | ||
</p> | ||
|
||
<p> | ||
For more information on customising this feed, check our <a href="">API documentation</a>. | ||
</p> | ||
</div> | ||
</details> | ||
|
||
</div> | ||
|
||
</div> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<div class="govuk-warning-text govuk-warning-text--text-only govuk-warning-text--information"> | ||
<span class="govuk-warning-text__text"> | ||
<span class="govuk-visually-hidden">Information</span> | ||
<strong>Find Case Law Atom feed</strong><br/><br/> | ||
This is an Atom feed of documents in the Find Case Law service, sometimes also known as an RSS feed. Subscribe by copying the URL from the address bar into your newsreader app. | ||
</span> | ||
</div> | ||
<h1>Subscribe to your search results</h1> | ||
<h2> | ||
{% if query %} | ||
For "{{ query }}" | ||
{% endif %} | ||
|
||
{% for key, value in filters %} | ||
{% if key == 'court' or key == 'tribunal' %} | ||
{% for item in value %} | ||
<br/> | ||
From "{{ item|get_court_name }}" | ||
{% endfor %} | ||
{% elif key != 'query' %} | ||
<br/> | ||
From "{{ value }}" | ||
{% endif %} | ||
{% endfor %} | ||
</h2> | ||
|
||
<p>Sorted by date the document was first published by the court (newest first)</p> | ||
|
||
<p>This Atom feed will provide the latest updates from the Find Case Law service, operated by The National Archives.</p> | ||
|
||
<h3>Atom feed for your search results</h3> | ||
|
||
<p>This will dynamically update when the link has been added to your Atom feed app.</p> | ||
|
||
<ul class="atom-feed__list"> | ||
{% for result in search_results %} | ||
<li> | ||
<a href="{% url 'detail' result.uri %}?{{ query_param_string }}"> | ||
{{ result.name }} | ||
</a> | ||
<br/> | ||
{{ result.date|date:"d M Y" }} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock static_content %} |
Oops, something went wrong.