Skip to content

Commit

Permalink
fix: use interpolate-size for height animation
Browse files Browse the repository at this point in the history
  • Loading branch information
HEIGE-PCloud committed Dec 19, 2024
1 parent d3d5fe2 commit 4b787cb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
6 changes: 6 additions & 0 deletions assets/css/_core/_base.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* Opt-in the whole page to interpolate sizes to/from keywords */
// https://developer.chrome.com/docs/css-ui/animate-to-height-auto
:root {
interpolate-size: allow-keywords;
}

html {
font-family: $global-font-family;
font-weight: $global-font-weight;
Expand Down
2 changes: 1 addition & 1 deletion assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
}

/*
! tailwindcss v3.4.16 | MIT License | https://tailwindcss.com
! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com
*/

/*
Expand Down
7 changes: 3 additions & 4 deletions assets/js/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,15 @@ function initDetails() {
)[0] as HTMLDivElement;
const content = $summary.nextElementSibling as HTMLDivElement;
if ($details.classList.contains("open")) {
content.style.maxHeight = content.scrollHeight + "px";
content.style.maxHeight = "fit-content";
}
$summary.addEventListener(
"click",
() => {
if ($details.classList.contains("open")) {
content.style.maxHeight = "0px";
} else {
content.style.maxHeight = content.scrollHeight + "px";
content.style.maxHeight = "fit-content";
}
$details.classList.toggle("open");
},
Expand Down Expand Up @@ -893,7 +893,7 @@ function initCodeblocks() {
"button.line-number-button",
) as HTMLButtonElement;

chroma.style.maxHeight = chroma.scrollHeight + 10 + "px";
chroma.style.maxHeight = "fit-content";

// handle expanding and collapsing code blocks
titleBar.addEventListener("click", () => {
Expand All @@ -917,7 +917,6 @@ function initCodeblocks() {
wrapCodeButton?.addEventListener("click", () => {
chroma.style.maxHeight = "fit-content";
codeBlock.classList.toggle("is-wrap");
chroma.style.maxHeight = chroma.scrollHeight + 10 + "px";
});

toggleLineNumbersButton.addEventListener("click", () => {
Expand Down
35 changes: 35 additions & 0 deletions exampleSite/content/posts/tests/tab-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,41 @@ Content 2

{{% /tab %}}

{{< /tabs >}}

## Tabs with Codeblock

{{< tabs >}}

{{% tab title="Tab 1" %}}

```python
def hello():
print("Hello World!")
print("Hello World!")
print("Hello World!")
print("Hello World!")
print("Hello World!")
print("Hello World!")
```

{{% /tab %}}

{{% tab title="Tab 2" %}}

```python
def hello():
print("Hello World!")
print("Hello World!")
print("Hello World!")
print("Hello World!")
print("Hello World!")
print("Hello World!")
```

{{% /tab %}}


{{< /tabs >}}

## Single Tab
Expand Down

0 comments on commit 4b787cb

Please sign in to comment.