Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
d20601dc
"src/git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "ea721feea901928477e3aa38925dda110b66aa76"
Commit
d20601dc
authored
Jul 04, 2024
by
rdavis
Browse files
feat: Add custom Collapsible component for collapsible content
parent
2c061777
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
src/lib/components/common/Collapsible.svelte
src/lib/components/common/Collapsible.svelte
+37
-0
No files found.
src/lib/components/common/Collapsible.svelte
0 → 100644
View file @
d20601dc
<script lang="ts">
import { afterUpdate } from 'svelte';
export let open = false;
// Manage the max-height of the collapsible content for snappy transitions
let contentElement: HTMLElement;
let maxHeight = '0px'; // Initial max-height
// After any state update, adjust the max-height for the transition
afterUpdate(() => {
if (open) {
// Ensure the element is visible before measuring
maxHeight = `${contentElement.scrollHeight}px`;
} else {
maxHeight = '0px';
}
});
</script>
<style>
.collapsible-content {
overflow: hidden;
transition: max-height 0.3s ease-out;
max-height: 0;
}
</style>
<div>
<button on:click={() => open = !open}>
<slot name="head"></slot>
</button>
<div bind:this={contentElement} class="collapsible-content" style="max-height: {maxHeight};">
<slot name="content"></slot>
</div>
</div>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment