Skip to content

Commit

Permalink
Site final backport 2.2 (#2295)
Browse files Browse the repository at this point in the history
* Fixed merge conflicts

Signed-off-by: Fanit Kolchina <[email protected]>

* Backports final UI changes to 2.2

Signed-off-by: Fanit Kolchina <[email protected]>

Signed-off-by: Fanit Kolchina <[email protected]>
  • Loading branch information
kolchfa-aws authored Dec 27, 2022
1 parent e300a80 commit 2c3249d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 67 deletions.
16 changes: 7 additions & 9 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
{% endif %}
{% endfor %}
{% endif %}
</nav>
</nav>
</div>
<div class="copy-banner">
<div class="container">
Expand Down Expand Up @@ -124,7 +124,7 @@ <h1><a href="#">Documentation</a></h1>
</div>
<div class="search-overlay"></div>
</div>
<div class="main" id="top">
<div class="main">
<div id="main-content-wrap" class="main-content-wrap">
{% unless page.url == "/" %}
{% if page.parent %}
Expand Down Expand Up @@ -154,7 +154,7 @@ <h1><a href="#">Documentation</a></h1>

{% if page.has_children == true and page.has_toc != false %}
<hr>
<h2 class="text-delta">Table of contents</h2>
<h2>Related articles</h2>
<ul>
{% for child in toc_list %}
<li>
Expand All @@ -163,7 +163,7 @@ <h2 class="text-delta">Table of contents</h2>
{% endfor %}
</ul>
{% endif %}

{% capture footer_custom %}
{%- include footer_custom.html -%}
{% endcapture %}
Expand Down Expand Up @@ -208,7 +208,6 @@ <h2 class="text-delta">Table of contents</h2>
</div>
{% include feedback.html %}
</div>
{% comment %}{% include feedback.html %}{% endcomment %}
</div>
{% if site.search_enabled != false %}
{% if site.search.button %}
Expand All @@ -231,9 +230,8 @@ <h2 class="text-delta">Table of contents</h2>
{% if site.search_enabled == false and site.use_custom_search == true %}
<script src="{{ '/assets/js/search.js' | relative_url }}"></script>
{% endif %}
<script src="{{ '/assets/js/copy.js' | relative_url }}"></script>
<script src="{{ '/assets/js/copy-button.js' | relative_url }}"></script>
<script src="{{ '/assets/js/nav-scroll.js' | relative_url }}"></script>
<script src="{{ '/assets/js/feedback.js' | relative_url }}"></script>
<script src="{{ '/assets/js/link-feedback.js' | relative_url }}"></script>
<script src="{{ '/assets/js/listener.js' | relative_url }}"></script>
</body>
</html>
</html>
10 changes: 7 additions & 3 deletions _sass/custom/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ code {

.site-nav {
padding-top: 1rem;

display: static;
position: sticky;
top: 1rem;
max-height: calc(100vh - 2rem);
Expand Down Expand Up @@ -229,11 +227,12 @@ img {
width: 2.5rem;
height: 2.5rem;
color: $blue-dk-100;
background-color: white;
border-width:2px;
border-style:solid;
border-color: $grey-lt-300;
border-radius: 10px;
box-shadow: 1px 2px 3px $grey-lt-300;
box-shadow: 1px 1px 1px $grey-lt-300;
padding: 0.2rem;
position: fixed;
bottom: 30px;
Expand All @@ -252,6 +251,7 @@ img {
.copy-button-wrap {
background-color: $sidebar-color;
padding: 0 2rem 0.5rem 2rem;
margin-bottom: 0.75rem;
display: flex;
justify-content: flex-end;
}
Expand Down Expand Up @@ -565,6 +565,10 @@ main {
.container {
box-sizing: content-box;

@include mq(xs) {
padding: 0 calc(#{$top-button-margin} + 1rem);
}

@include mq(md) {
margin: 0 auto;
max-width: 1400px;
Expand Down
14 changes: 4 additions & 10 deletions assets/js/copy.js → assets/js/copy-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ function createButton(textToCopy, buttonText, buttonAriaLabel, curl) {
copyButton.ariaLabel = buttonAriaLabel;

if (curl) {
copyButton.addEventListener('click', function onClick() {
// Copy snippet as curl
window.navigator.clipboard.writeText(addCurl(textToCopy));
});
copyButton.setAttribute('data-text', addCurl(textToCopy));
}
else {
copyButton.addEventListener('click', function onClick() {
// Copy snippet to clipboard
window.navigator.clipboard.writeText(textToCopy);
});
copyButton.setAttribute('data-text', textToCopy);
}

return copyButton;
Expand All @@ -50,8 +44,8 @@ function addCurl(textToCopy) {
const httpMethod = textToCopy.substring(0, firstSpaceIndex);

const firstCurlyIndex = textToCopy.indexOf("{");
var body;
var path;
let body;
let path;
if (firstCurlyIndex == -1) {
body = "";
path = textToCopy.substring(firstSpaceIndex + 1);
Expand Down
32 changes: 0 additions & 32 deletions assets/js/feedback.js

This file was deleted.

13 changes: 0 additions & 13 deletions assets/js/link-feedback.js

This file was deleted.

30 changes: 30 additions & 0 deletions assets/js/listener.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
document.addEventListener('click', function(event) {
const { target } = event;
if (target.matches('.feedback-issue')) {
gtag('event', 'submit_issue_click');
}
else if (target.matches('.feedback-edit')) {
gtag('event', 'edit_page_click');
}
else if (target.matches('.feedback-button')) {
sendFeedback(target);
}
else if (target.matches('.copy-button')) {
window.navigator.clipboard.writeText(target.getAttribute('data-text'));
}
});

function sendFeedback(button) {
gtag('event', 'feedback_click', {
'helpful': button.value
});
// show the hidden feedback text
const parent = button.parentElement;
const index = [...parent.children].indexOf(button) + 1;
const sibling = parent.querySelector(`:nth-child(${index}) ~ .text-small.hidden`);
sibling?.classList.remove('hidden');

// disable the feedback buttons
button.disabled = true;
button[button.id === 'yes' ? 'nextElementSibling' : 'previousElementSibling']?.setAttribute('disabled', true);
}

0 comments on commit 2c3249d

Please sign in to comment.