Skip to content

Commit 1a3709c

Browse files
authored
Merge pull request #17 from shellui-dev/feat/animation-polish
feat: animation polish — view-transitions, sidebar collapse animation, reduced-motion guard, copy-icon bounce
2 parents 03fbcc2 + e0f2548 commit 1a3709c

5 files changed

Lines changed: 55 additions & 3 deletions

File tree

src/ShellDocs.Components/Chrome/DocsSidebar.razor.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@
120120
transform: rotate(90deg);
121121
}
122122

123+
/* Toggleable section content — grid-rows 0fr→1fr animates to natural height
124+
without needing a fixed max-height. The inner wrapper carries the actual
125+
items and MUST have `min-height: 0` so it can collapse cleanly. */
126+
::deep .sidebar-section-shell {
127+
display: grid;
128+
grid-template-rows: 0fr;
129+
transition: grid-template-rows 220ms cubic-bezier(0.16, 1, 0.3, 1);
130+
}
131+
::deep .sidebar-section-shell[data-open="true"] {
132+
grid-template-rows: 1fr;
133+
}
134+
::deep .sidebar-section-shell > .sidebar-section-items {
135+
overflow: hidden;
136+
min-height: 0;
137+
}
138+
123139
::deep .sidebar-section-items {
124140
display: flex;
125141
flex-direction: column;

src/ShellDocs.Components/Chrome/DocsSidebarNode.razor

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ else if (Node.Kind == NodeKind.Section)
2323
</div>
2424
}
2525
}
26-
@if (!_isToggleable || _isOpen)
26+
@if (_isToggleable)
27+
{
28+
<div class="sidebar-section-shell" data-open="@(_isOpen ? "true" : "false")">
29+
<div class="sidebar-section-items">
30+
@foreach (var child in Node.Children)
31+
{
32+
<DocsSidebarNode Node="child" Depth="@(Depth + 1)" CurrentPath="@CurrentPath" />
33+
}
34+
</div>
35+
</div>
36+
}
37+
else
2738
{
2839
<div class="sidebar-section-items">
2940
@foreach (var child in Node.Children)

src/ShellDocs.Components/Content/ComponentPreview.razor.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,5 @@
127127
border-color: color-mix(in oklch, var(--border) 60%, var(--foreground));
128128
}
129129
.component-preview-copy.copied { color: var(--success, oklch(0.723 0.219 149.579)); }
130-
.component-preview-copy svg { width: 0.8125rem; height: 0.8125rem; }
130+
.component-preview-copy svg { width: 0.8125rem; height: 0.8125rem; transition: transform 150ms cubic-bezier(0.34, 1.56, 0.64, 1); }
131+
.component-preview-copy.copied svg { transform: scale(1.15); }

src/ShellDocs.Components/Content/PreviewFrame.razor.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,5 @@
116116
border-color: color-mix(in oklch, var(--border) 60%, var(--foreground));
117117
}
118118
.preview-copy.copied { color: var(--success, oklch(0.723 0.219 149.579)); }
119-
.preview-copy svg { width: 0.8125rem; height: 0.8125rem; }
119+
.preview-copy svg { width: 0.8125rem; height: 0.8125rem; transition: transform 150ms cubic-bezier(0.34, 1.56, 0.64, 1); }
120+
.preview-copy.copied svg { transform: scale(1.15); }

src/ShellDocs.Components/wwwroot/shelldocs-theme.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,26 @@ pre.shiki,
193193
pre.shiki span { color: var(--shiki-light); }
194194
:root.dark pre.shiki,
195195
:root.dark pre.shiki span { color: var(--shiki-dark); }
196+
197+
/* View-transitions — the browser diffs old vs new page and cross-fades
198+
automatically when Blazor enhanced navigation swaps the DOM. Progressive:
199+
Chromium supports today; other engines just no-op the pseudo rules. */
200+
@view-transition { navigation: auto; }
201+
::view-transition-old(root),
202+
::view-transition-new(root) { animation-duration: 180ms; animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
203+
204+
/* Global reduced-motion guard — respects the OS preference so animations
205+
collapse to instant while transitions still fire (kept at 0.01ms so JS
206+
`transitionend` handlers still trigger). */
207+
@media (prefers-reduced-motion: reduce) {
208+
*,
209+
*::before,
210+
*::after {
211+
animation-duration: 0.01ms !important;
212+
animation-iteration-count: 1 !important;
213+
transition-duration: 0.01ms !important;
214+
scroll-behavior: auto !important;
215+
}
216+
::view-transition-old(root),
217+
::view-transition-new(root) { animation: none !important; }
218+
}

0 commit comments

Comments
 (0)