Skip to content

Commit ab93450

Browse files
committed
clarification
1 parent abaac5f commit ab93450

4 files changed

Lines changed: 195 additions & 66 deletions

File tree

src/components/SmoothTabs.astro

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
3+
---
4+
5+
<script>
6+
import { mayStartViewTransition } from "@vtbag/utensil-drawer/may-start-view-transition";
7+
const proto = customElements.get("starlight-tabs")?.prototype;
8+
const originalSwitchTab = proto.switchTab;
9+
proto.switchTab = function (
10+
newTab: HTMLAnchorElement | null | undefined,
11+
index: number,
12+
shouldSync = true
13+
) {
14+
document.querySelectorAll("starlight-tabs").forEach((t,idx) => {
15+
t.querySelectorAll<HTMLElement>('[role="tabpanel"]').forEach((p) => {
16+
p.style.setProperty("--vtbag-tabs-vtn", `tab${idx}`);
17+
});
18+
});
19+
mayStartViewTransition(
20+
{
21+
update: () => originalSwitchTab.call(this, newTab, index, shouldSync),
22+
types: ["tabs"],
23+
},
24+
{ collisionBehavior: "chaining", useTypesPolyfill: "auto" }
25+
);
26+
};
27+
</script>
28+
<style is:global>
29+
.tablist-wrapper a {
30+
text-decoration: none;
31+
}
32+
:active-view-transition-type(tabs) {
33+
&, *, *:after {
34+
view-transition-name: none !important;
35+
}
36+
main {
37+
view-transition-name: main;
38+
}
39+
[style*="--vtbag-tabs-vtn:"] {
40+
view-transition-name: var(--vtbag-tabs-vtn) !important;
41+
}
42+
}
43+
</style>

0 commit comments

Comments
 (0)