Skip to content

Commit

Permalink
Backports final UI changes to 2.3 (#2293)
Browse files Browse the repository at this point in the history
* Backports final UI changes to 2.3

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

* Removes previous version of script

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>
  • Loading branch information
kolchfa-aws authored Dec 27, 2022
1 parent 8b0f4e2 commit b487598
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 71 deletions.
18 changes: 5 additions & 13 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@
{% endif %}
{% endfor %}
{% endif %}
<div class="site-footer">
<p class="text-small text-grey-dk-100">See a problem? Submit <a href="https://github.com/opensearch-project/documentation-website/issues">issues</a> or <a href="https://github.com/opensearch-project/documentation-website/edit/main/{{ page.path }}">edit this page</a> on <a href="https://github.com/opensearch-project/documentation-website/">GitHub</a>.</p>
</div>
</nav>
</nav>
</div>
<div class="copy-banner">
<div class="container">
Expand Down Expand Up @@ -157,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 @@ -166,10 +163,7 @@ <h2 class="text-delta">Table of contents</h2>
{% endfor %}
</ul>
{% endif %}
<!--
<hr>
{% include feedback.html %}
-->

{% capture footer_custom %}
{%- include footer_custom.html -%}
{% endcapture %}
Expand Down Expand Up @@ -214,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 @@ -237,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>
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 @@ -560,6 +560,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 b487598

Please sign in to comment.