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

collapse block fix #5463

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
33 changes: 33 additions & 0 deletions assets/js/preview-fade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// assets/js/preview-fade.js
console.log('Preview fade script loaded');

document.addEventListener('DOMContentLoaded', () => {
console.log('DOM Content Loaded');

const previewFades = document.querySelectorAll('.preview-fade');
console.log('Found preview fades:', previewFades.length);

previewFades.forEach(container => {
const button = container.querySelector('.expand-button');
const buttonText = button.querySelector('.expand-text');

if (!button) {
console.error('Button not found in container:', container);
return;
}

if (!buttonText) {
console.error('Button text element not found in button:', button);
return;
}

button.addEventListener('click', () => {
console.log('Button clicked');
const currentState = container.getAttribute('data-state');
const newState = currentState === 'collapsed' ? 'expanded' : 'collapsed';
console.log('State changing from', currentState, 'to', newState);
container.setAttribute('data-state', newState);
buttonText.textContent = newState === 'expanded' ? 'Show Less' : 'Show More';
});
});
});
51 changes: 51 additions & 0 deletions assets/scss/_preview-fade.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// assets/scss/components/_preview-fade.scss
.preview-fade {
position: relative;
margin: 1rem 0;

&__content {
max-height: 200px;
overflow: hidden;
transition: max-height 0.3s ease-out;

&--expanded {
max-height: none;
}
}

&__overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 100px;
background: linear-gradient(
to bottom,
rgba(255, 255, 255, 0),
rgba(255, 255, 255, 1)
);
display: flex;
align-items: flex-end;
justify-content: center;
padding-bottom: 1rem;

&--hidden {
display: none;
}
}

&__button {
padding: 0.5rem 1rem;
border-radius: 20px;
background-color: white;
border: 1px solid #0366d6;
color: #0366d6;
cursor: pointer;
font-size: 0.875rem;
transition: all 0.2s;

&:hover {
background-color: #f6f8fa;
}
}
}
55 changes: 54 additions & 1 deletion assets/scss/_styles_project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
@import 'tabs';
@import 'external_link';
@import 'td/code-dark';
@import 'preview-fade';

.td-home {
.otel-logo {
margin-top: 2rem;
margin-top: 2rem;
margin-bottom: 3rem;
max-height: 12rem;
}
Expand Down Expand Up @@ -327,3 +328,55 @@ details {
overflow-y: auto;
}
}


.preview-fade {
position: relative;
border: 1px solid var(--gray-200);
border-radius: 0.375rem;
background: var(--gray-100);
margin: 1rem 0;
}

.preview-content {
padding: 1rem;
margin: 0;
overflow-x: auto;
}

.preview-fade[data-state='collapsed'] .preview-content {
max-height: 150px;
}

.preview-fade[data-state='expanded'] .preview-content {
max-height: none;
}

.fade-overlay {
position: absolute;
bottom: 2.5rem;
left: 0;
right: 0;
height: 4rem;
background: linear-gradient(to top, var(--gray-100), transparent);
pointer-events: none;
}

.preview-fade[data-state='expanded'] .fade-overlay {
display: none;
}

.expand-button {
width: 100%;
padding: 0.5rem;
border: none;
border-top: 1px solid var(--gray-200);
background: var(--gray-100);
color: var(--gray-700);
cursor: pointer;
font-size: 0.875rem;
}

.expand-button:hover {
background: var(--gray-200);
}
22 changes: 15 additions & 7 deletions content/en/docs/languages/js/getting-started/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ app.get('/rolldice', (req, res) => {

app.listen(PORT, () => {
console.log(`Listening for requests on http://localhost:${PORT}`);
});
});
```

{{% /tab %}} {{% tab JavaScript %}}
Expand Down Expand Up @@ -251,8 +251,10 @@ Open <http://localhost:8080/rolldice> in your web browser and reload the page a
few times. After a while you should see the spans printed in the console by the
`ConsoleSpanExporter`.

<details>
<summary>View example output</summary>
<!-- <details>
<summary>View example output</summary> -->

{{% preview-fade %}}

```json
{
Expand Down Expand Up @@ -333,15 +335,19 @@ few times. After a while you should see the spans printed in the console by the
}
```

</details>
{{% /preview-fade %}}

<!-- </details> -->

The generated span tracks the lifetime of a request to the `/rolldice` route.

Send a few more requests to the endpoint. After a moment, you'll see metrics in
the console output, such as the following:

<details>
<summary>View example output</summary>
<!-- <details>
<summary>View example output</summary> -->

{{% preview-fade %}}

```yaml
{
Expand Down Expand Up @@ -466,7 +472,9 @@ the console output, such as the following:
}
```

</details>
{{% /preview-fade %}}

<!-- </details> -->

## Next Steps

Expand Down
3 changes: 3 additions & 0 deletions layouts/partials/hooks/body-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
{{ partial "script.html" (dict "src" "js/tracing.js") -}}
{{ end -}}
{{ partial "script.html" (dict "src" "js/navScroll.js") -}}
{{ partial "script.html" (dict "src" "js/preview-fade.js") -}}


9 changes: 9 additions & 0 deletions layouts/shortcodes/preview-fade.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="preview-fade" data-state="collapsed">
<div class="preview-content">
{{ .Inner | markdownify }}
</div>
<div class="fade-overlay"></div>
<button class="expand-button">
<span class="expand-text">Show More</span>
</button>
</div>
Loading