Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Upload modal: smoothly animate expander open/close (and the modal resize that follows)

Murtaza Nasir304ebdcea4f3
diff --git a/static/css/primitives.css b/static/css/primitives.css
index 45ebb650..a0b4b2a7 100644
--- a/static/css/primitives.css
+++ b/static/css/primitives.css
@@ -1647,13 +1647,9 @@ textarea:focus-visible {
/* When expanded, the whole group reads as ONE contained card: the
summary becomes the card header (connected to the body, no gap) and
the body sits visibly INSIDE the bordered box. Closed, it's just the
- summary chip. This gives the contents clear visual ownership instead
- of floating at the same level as the summary. */
-.upload-options-group[open] {
- border: 1px solid var(--border-secondary);
- border-radius: var(--radius-md);
- background: var(--bg-secondary);
-}
+ summary chip. The card border/background + radius are declared (and
+ transitioned) in the Expand/collapse animation section below, shared
+ with .disclosure-card. */
/* Summary as the card header: square off its bottom corners and add a
divider so it reads as attached to the body below. Specificity
@@ -1746,12 +1742,9 @@ input[type="checkbox"].checkbox:disabled {
Same idea as .upload-options-group but reusable on any <details>:
when open the whole element is one bordered card with the summary as
its header and the body padded inside. Put .disclosure-card on the
- <details> and .disclosure-card-body on the body wrapper. */
-details.disclosure-card[open] {
- border: 1px solid var(--border-secondary);
- border-radius: var(--radius-md);
- background: var(--bg-secondary);
-}
+ <details> and .disclosure-card-body on the body wrapper. The card
+ border/background + radius are declared (and transitioned) in the
+ Expand/collapse animation section below. */
details.disclosure-card[open] > summary {
border-radius: var(--radius-md) var(--radius-md) 0 0;
border-bottom: 1px solid var(--border-secondary);
@@ -1765,6 +1758,88 @@ details.disclosure-card[open] > .disclosure-card-body > *:first-child {
}
+/* ---- Expand / collapse animation ---------------------------------------
+ *
+ * Two mechanisms, one feel (0.25s ease). When an expander animates its
+ * height, the modal — which sizes to its content — grows/shrinks in step
+ * automatically, so the whole panel resize looks smooth without animating
+ * the modal itself.
+ *
+ * (A) Native <details> (.upload-options-group, .disclosure-card):
+ * animate the ::details-content box. interpolate-size lets height
+ * transition to/from the `auto` keyword; content-visibility with
+ * allow-discrete keeps the content painted through the collapse.
+ * Supported in current Chromium; older browsers ignore it and the
+ * expander just snaps open/closed (no regression).
+ *
+ * The card border/background is given a transparent resting state and
+ * transitioned so it fades in/out in step with the height instead of
+ * snapping the moment the [open] attribute flips.
+ *
+ * (B) v-show panels (.disclosure-anim): the grid-template-rows 0fr→1fr
+ * trick. Works in every browser. The body stays in the DOM and the
+ * inner wrapper clips overflow, so the row collapses to zero height
+ * smoothly. Toggle .is-open on the grid container.
+ */
+/* Scoped to the disclosure elements (not :root) so enabling keyword
+ interpolation doesn't affect height transitions elsewhere. */
+.upload-options-group,
+details.disclosure-card {
+ interpolate-size: allow-keywords;
+}
+
+.upload-options-group::details-content,
+details.disclosure-card::details-content {
+ block-size: 0;
+ overflow: clip;
+ transition: block-size 0.25s ease, content-visibility 0.25s allow-discrete;
+}
+.upload-options-group[open]::details-content,
+details.disclosure-card[open]::details-content {
+ block-size: auto;
+}
+
+/* Transition the card chrome so it fades with the height rather than
+ snapping when [open] toggles. Resting border is transparent (keeps the
+ closed chip the same size; no layout shift). */
+.upload-options-group,
+details.disclosure-card {
+ border: 1px solid transparent;
+ border-radius: var(--radius-md);
+ transition: border-color 0.25s ease, background-color 0.25s ease;
+}
+.upload-options-group[open],
+details.disclosure-card[open] {
+ border-color: var(--border-secondary);
+ background: var(--bg-secondary);
+}
+
+/* Grid-rows animation wrapper for the v-show panels. */
+.disclosure-anim {
+ display: grid;
+ grid-template-rows: 0fr;
+ transition: grid-template-rows 0.25s ease;
+}
+.disclosure-anim.is-open {
+ grid-template-rows: 1fr;
+}
+.disclosure-anim__inner {
+ overflow: hidden;
+ min-height: 0;
+}
+
+/* Respect users who ask for reduced motion: snap instead of animate. */
+@media (prefers-reduced-motion: reduce) {
+ .upload-options-group::details-content,
+ details.disclosure-card::details-content,
+ .upload-options-group,
+ details.disclosure-card,
+ .disclosure-anim {
+ transition: none !important;
+ }
+}
+
+
/* ---- Mobile editor flat corners ----------------------------------------
On phones the EasyMDE editor spans screen-edge to screen-edge inside
the mobile-summary-panel / mobile-notes-panel editing shells (no
diff --git a/templates/components/upload-view.html b/templates/components/upload-view.html
index 63e2f434..2297eec0 100644
--- a/templates/components/upload-view.html
+++ b/templates/components/upload-view.html
@@ -647,7 +647,9 @@
</div>
</details>
</div>
- <div v-show="showPromptVariablesPanel" class="mt-2 p-3 bg-[var(--bg-tertiary)] rounded-md space-y-3 border border-[var(--border-secondary)]">
+ <div class="disclosure-anim mt-2" :class="{ 'is-open': showPromptVariablesPanel }">
+ <div class="disclosure-anim__inner">
+ <div class="p-3 bg-[var(--bg-tertiary)] rounded-md space-y-3 border border-[var(--border-secondary)]">
<div v-for="variable in selectedPromptVariables" :key="variable.name" class="space-y-1">
<label class="block text-xs font-medium text-[var(--text-secondary)]" :for="'pv-' + variable.name">
${ variable.label }
@@ -676,6 +678,8 @@
</div>
</div>
</div>
+ </div><!-- end .disclosure-anim__inner -->
+ </div><!-- end .disclosure-anim -->
</div>
<!-- Advanced Options for diarization-enabled connectors (collapsible) -->
@@ -689,7 +693,9 @@
<i :class="['fas text-[var(--text-muted)]', showAdvancedOptions ? 'fa-chevron-up' : 'fa-chevron-down']"></i>
</button>
- <div v-show="showAdvancedOptions" class="disclosure-panel p-3 bg-[var(--bg-tertiary)] space-y-3 border border-[var(--border-secondary)]">
+ <div class="disclosure-anim" :class="{ 'is-open': showAdvancedOptions }">
+ <div class="disclosure-anim__inner">
+ <div class="disclosure-panel p-3 bg-[var(--bg-tertiary)] space-y-3 border border-[var(--border-secondary)]">
<!-- Language Selection -->
<div>
<label class="block text-xs font-medium text-[var(--text-secondary)] mb-1">
@@ -766,9 +772,11 @@
${ t('upload.settingsApplyToAll') }
</p>
</div>
+ </div><!-- end .disclosure-anim__inner -->
+ </div><!-- end .disclosure-anim -->
</div>
- </div><!-- end .mt-2 wrapper inside details -->
+ </div><!-- end .upload-options-body wrapper inside details -->
</details><!-- end Options progressive-disclosure group -->
</div>