2021-05-11 16:14:16 +02:00
|
|
|
<script>
|
2022-01-17 13:36:00 +01:00
|
|
|
// Whether the Expandable is expanded by default
|
2021-05-11 16:14:16 +02:00
|
|
|
export let expanded = false
|
|
|
|
export const toggle = () => {
|
|
|
|
expanded = !expanded
|
|
|
|
}
|
2022-01-17 13:36:00 +01:00
|
|
|
|
|
|
|
// Allow the user to expand the Expandable by clicking the title. Use
|
|
|
|
// stopPropagation if you want to use other interactive elements in the title
|
|
|
|
// bar
|
|
|
|
export let click_expand = false
|
|
|
|
const header_click = () => {
|
|
|
|
if (click_expand) {
|
|
|
|
toggle()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Highlight the title bar if the user moves their mouse over it
|
|
|
|
export let highlight = false
|
2021-05-11 16:14:16 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="expandable">
|
2022-01-17 13:36:00 +01:00
|
|
|
<div class="header" class:click_expand class:highlight on:click={header_click}>
|
2021-05-11 16:14:16 +02:00
|
|
|
<div class="title">
|
|
|
|
<slot name="header"></slot>
|
|
|
|
</div>
|
|
|
|
|
2022-01-17 13:36:00 +01:00
|
|
|
<button class="bucket_expand" on:click|stopPropagation={toggle}>
|
2021-05-11 16:14:16 +02:00
|
|
|
{#if expanded}
|
|
|
|
<i class="icon">expand_less</i>
|
|
|
|
{:else}
|
|
|
|
<i class="icon">expand_more</i>
|
|
|
|
{/if}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="body" class:hidden={!expanded}>
|
|
|
|
<slot></slot>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.expandable {
|
|
|
|
text-decoration: none;
|
2022-03-29 21:41:46 +02:00
|
|
|
background-color: var(--popout_color);
|
2022-01-17 13:36:00 +01:00
|
|
|
margin: 0.6em 0;
|
2022-01-11 13:28:22 +01:00
|
|
|
border-radius: 6px;
|
2021-08-18 13:00:07 +02:00
|
|
|
overflow: hidden;
|
2021-05-11 16:14:16 +02:00
|
|
|
}
|
|
|
|
.header {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
2022-03-29 21:41:46 +02:00
|
|
|
color: var(--body_text_color);
|
2021-05-11 16:14:16 +02:00
|
|
|
}
|
2022-01-17 13:36:00 +01:00
|
|
|
.click_expand:hover, .highlight:hover {
|
2022-03-29 21:41:46 +02:00
|
|
|
background: var(--input_background);
|
|
|
|
color: var(--input_text);
|
2021-05-11 16:14:16 +02:00
|
|
|
}
|
2022-01-17 13:36:00 +01:00
|
|
|
.click_expand {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2021-05-11 16:14:16 +02:00
|
|
|
.title {
|
|
|
|
flex: 1 1 auto;
|
|
|
|
text-align: left;
|
|
|
|
}
|
|
|
|
.bucket_expand {
|
|
|
|
flex: 0 0 auto;
|
|
|
|
align-self: center;
|
|
|
|
height: auto;
|
|
|
|
}
|
|
|
|
.body {
|
|
|
|
display: flex;
|
|
|
|
padding: 0.4em;
|
|
|
|
flex-direction: column;
|
|
|
|
text-decoration: none;
|
2022-03-29 21:41:46 +02:00
|
|
|
border-top: 1px solid var(--separator);
|
2021-05-11 16:14:16 +02:00
|
|
|
}
|
|
|
|
.hidden {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
</style>
|