Expandable fixes

This commit is contained in:
2022-01-17 13:36:00 +01:00
parent cfee28a762
commit deba5060a9
5 changed files with 29 additions and 13 deletions

View File

@@ -154,7 +154,7 @@
</div> </div>
<div> <div>
<div class="feat_label">Size limit per file</div> <div class="feat_label">Size limit per file</div>
<div class="feat_normal">5 GB per file (4.66 GiB)</div> <div class="feat_normal">10 GB per file (9.31 GiB)</div>
<div class="feat_pro"> <div class="feat_pro">
<span class="text_highlight">20 GB</span> per file (18.63 GiB) <span class="text_highlight">20 GB</span> per file (18.63 GiB)
</div> </div>

View File

@@ -5,7 +5,6 @@ import { createEventDispatcher } from "svelte";
let dispatch = createEventDispatcher() let dispatch = createEventDispatcher()
export let report export let report
let expandable
let preview = false let preview = false
let set_status = async (action, report_type) => { let set_status = async (action, report_type) => {
@@ -31,8 +30,8 @@ let set_status = async (action, report_type) => {
} }
</script> </script>
<Expandable bind:this={expandable} expanded={report.status === "pending" && report.reports.length > 2}> <Expandable expanded={report.status === "pending" && report.reports.length > 2} click_expand>
<div slot="header" class="header" on:click={expandable.toggle}> <div slot="header" class="header">
<div class="icon_cell"> <div class="icon_cell">
<img class="file_icon" src={"/api/file/"+report.file.id+"/thumbnail"} alt="File thumbnail"/> <img class="file_icon" src={"/api/file/"+report.file.id+"/thumbnail"} alt="File thumbnail"/>
</div> </div>
@@ -118,7 +117,7 @@ let set_status = async (action, report_type) => {
} }
.stats { .stats {
flex: 0 0 auto; flex: 0 0 auto;
padding: 3px 4px; padding: 0 4px;
border-left: 1px solid var(--layer_3_color_border); border-left: 1px solid var(--layer_3_color_border);
text-align: center; text-align: center;
} }

View File

@@ -142,7 +142,7 @@ onMount(get_bans);
{/if} {/if}
{#each rows as row (row.address)} {#each rows as row (row.address)}
<Expandable expanded={expanded}> <Expandable expanded={expanded} click_expand>
<div slot="header" class="header"> <div slot="header" class="header">
<div class="title">{row.address}</div> <div class="title">{row.address}</div>
<div class="stats"> <div class="stats">
@@ -153,7 +153,7 @@ onMount(get_bans);
Date<br/> Date<br/>
{formatDate(row.offences[0].ban_time, false, false, false)} {formatDate(row.offences[0].ban_time, false, false, false)}
</div> </div>
<button on:click|preventDefault={() => {delete_ban(row.address)}} class="button button_red" style="align-self: center;"> <button on:click|stopPropagation={() => {delete_ban(row.address)}} class="button button_red" style="align-self: center;">
<i class="icon">delete</i> <i class="icon">delete</i>
</button> </button>
</div> </div>
@@ -218,7 +218,7 @@ onMount(get_bans);
} }
.stats { .stats {
flex: 0 0 auto; flex: 0 0 auto;
padding: 3px 4px; padding: 0 4px;
border-left: 1px solid var(--layer_3_color_border); border-left: 1px solid var(--layer_3_color_border);
text-align: center; text-align: center;
} }

View File

@@ -29,7 +29,7 @@ const delete_bucket = async () => {
</script> </script>
<Expandable> <Expandable highlight>
<div slot="header"> <div slot="header">
<a href={'/d/' + bucket.id} class="bucket_title"> <a href={'/d/' + bucket.id} class="bucket_title">
<img class="bucket_icon" src="/res/img/mime/folder-remote.png" alt="Bucket icon"/> <img class="bucket_icon" src="/res/img/mime/folder-remote.png" alt="Bucket icon"/>

View File

@@ -1,17 +1,31 @@
<script> <script>
// Whether the Expandable is expanded by default
export let expanded = false export let expanded = false
export const toggle = () => { export const toggle = () => {
expanded = !expanded expanded = !expanded
} }
// 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
</script> </script>
<div class="expandable"> <div class="expandable">
<div class="header"> <div class="header" class:click_expand class:highlight on:click={header_click}>
<div class="title"> <div class="title">
<slot name="header"></slot> <slot name="header"></slot>
</div> </div>
<button class="bucket_expand" on:click={toggle}> <button class="bucket_expand" on:click|stopPropagation={toggle}>
{#if expanded} {#if expanded}
<i class="icon">expand_less</i> <i class="icon">expand_less</i>
{:else} {:else}
@@ -28,7 +42,7 @@ export const toggle = () => {
.expandable { .expandable {
text-decoration: none; text-decoration: none;
background-color: var(--layer_3_color); background-color: var(--layer_3_color);
margin: 0.8em 0; margin: 0.6em 0;
border-radius: 6px; border-radius: 6px;
overflow: hidden; overflow: hidden;
} }
@@ -37,9 +51,12 @@ export const toggle = () => {
flex-direction: row; flex-direction: row;
color: var(--text_color); color: var(--text_color);
} }
.header:hover { .click_expand:hover, .highlight:hover {
background-color: var(--input_color_dark) background-color: var(--input_color_dark)
} }
.click_expand {
cursor: pointer;
}
.title { .title {
flex: 1 1 auto; flex: 1 1 auto;
text-align: left; text-align: left;