Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCS-2965: Make expanders linkable #3485

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,38 @@ async function initAndClick() {
}

// Userflow END

// Open Anchor for expanders if hidden START
const openDetailsIfAnchorHidden = (evt) => {
const target = evt.currentTarget.getAttribute("href"); // "#anchored"
const elTarget = document.querySelector(target);
console.log(target)
console.log(elTarget)

if (!elTarget) return; // No such element in DOM. Do nothing
console.log(elTarget.offsetHeight)

// Open all <details> ancestors
let elDetails = elTarget.closest("details");
console.log(elDetails)

while (elDetails) {
if (elDetails.matches("details")) elDetails.open = true;
elDetails = elDetails.parentElement;
}
}

document.querySelectorAll("[href^='#']").forEach((el) => {
el.addEventListener("click", openDetailsIfAnchorHidden);
});

if (location.hash) {
console.log(location.hash)
element = document.getElementById(location.hash.substr(1));
console.log(element)
bbox = element.getBoundingClientRect();
console.log(bbox.x, bbox.y)
scrollTo(bbox.x, bbox.y - 0);
}

// Open Anchor for expanders if hidden END
19 changes: 19 additions & 0 deletions assets/scss/_styles_project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1993,3 +1993,22 @@ h3.body-header[style] {
.hs_email.hs-email.hs-fieldtype-text.field.hs-form-field label, .hs_email.hs-email.hs-fieldtype-text.field.hs-form-field .input {
margin-right: 1rem;
}

// Expander anchor styling START
.expander-anchor {
display: block;
position: relative;
top: -130px;
visibility: hidden;
}

.expand-link-icon {
float: right;
visibility: hidden;
}

.expand .expand-label:hover .expand-link-icon {
color: blue;
visibility: visible;
}
// Expander anchor styling END
2 changes: 0 additions & 2 deletions docs/fleet/control.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ If you have configured a camera component, a window in the **CONTROL** tab displ
If you use remote control in the [Viam app](https://app.viam.com) UI, all communication to the machine uses [WebRTC](https://pkg.go.dev/go.viam.com/utils@v0.0.3/rpc#hdr-Connection).
For local communication between [parts](/architecture/parts/#machine-parts) Viam uses gRPC or WebRTC.

npentrel marked this conversation as resolved.
Show resolved Hide resolved
{{<gif webm_src="/fleet/control.webm" mp4_src="/fleet/control.mp4" alt="Using the control tab" max-width="800px">}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this meant to be a part of this? just checking


You can also switch between different machine parts and control the selected machine part directly from the **CONTROL** tab.

{{< imgproc src="/fleet/app-usage/control-machine-part-dropdown.png" alt="The expanded Machine part dropdown menu with the main part selected on the Control tab." resize="650x" class="aligncenter" >}}
Expand Down
8 changes: 5 additions & 3 deletions layouts/shortcodes/expand.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
<i style="font-size:x-small;" class="fas fa-chevron-right"></i>
<i style="font-size:x-small;" class="fas fa-chevron-down"></i>
<span>
{{- if .IsNamedParams -}}
{{- if .IsNamedParams -}}
{{.Get "default" | default "Click to expand"}}
{{- else -}}
{{.Get 0 | default "Click to expand"}}
{{- end -}}
</span>
<a aria-hidden="false" class="expand-link-icon" href="#{{ urls.Anchorize (.Get 0) }}" > <svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"></path><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a>
</span>
</summary>
<div class="expand-content">
<span class="expander-anchor" id="{{ urls.Anchorize (.Get 0) }}"></span>
{{ $.Inner | markdownify | safeHTML }}
</div>
</details>
</details>
Loading