Spaces:
Sleeping
Sleeping
File size: 4,626 Bytes
43a06dc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
<script lang="ts">
import { device } from "$lib/device";
import { t } from "$lib/i18n/translations";
import type { Optional } from "$lib/types/generic";
import type { DialogButton } from "$lib/types/dialog";
import type { DialogPickerItem } from "$lib/types/dialog";
import DialogContainer from "$components/dialog/DialogContainer.svelte";
import PickerItem from "$components/dialog/PickerItem.svelte";
import DialogButtons from "$components/dialog/DialogButtons.svelte";
import IconBoxMultiple from "@tabler/icons-svelte/IconBoxMultiple.svelte";
export let id: string;
export let items: Optional<DialogPickerItem[]> = undefined;
export let buttons: Optional<DialogButton[]> = undefined;
export let dismissable = true;
let dialogDescription = "dialog.picker.description.";
if (device.is.iOS) {
dialogDescription += "ios";
} else if (device.is.mobile) {
dialogDescription += "phone";
} else {
dialogDescription += "desktop";
}
let close: () => void;
</script>
<DialogContainer {id} {dismissable} bind:close>
<div
class="dialog-body picker-dialog"
class:three-columns={items && items.length <= 3}
>
<div class="popup-header">
<div class="popup-title-container">
<IconBoxMultiple />
<h2 class="popup-title" tabindex="-1">
{$t("dialog.picker.title")}
</h2>
</div>
<div class="subtext popup-description">
{$t(dialogDescription)}
</div>
</div>
<div class="picker-body">
{#if items}
{#each items as item, i}
{#if item?.url}
<PickerItem {item} number={i + 1} />
{/if}
{/each}
{/if}
</div>
{#if buttons}
<DialogButtons {buttons} closeFunc={close} />
{/if}
</div>
</DialogContainer>
<style>
.picker-dialog {
--picker-item-size: 120px;
gap: var(--padding);
max-height: calc(
90% - env(safe-area-inset-bottom) - env(safe-area-inset-top)
);
width: auto;
}
.popup-header {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 3px;
max-width: calc(var(--picker-item-size) * 4);
}
.popup-title-container {
display: flex;
flex-direction: row;
align-items: center;
gap: calc(var(--padding) / 2);
color: var(--secondary);
}
.popup-title-container :global(svg) {
height: 21px;
width: 21px;
}
.popup-title {
font-size: 18px;
line-height: 1.1;
}
.popup-description {
font-size: 13px;
padding: 0;
}
.popup-title:focus-visible {
box-shadow: none !important;
}
.picker-body {
overflow-y: scroll;
display: grid;
justify-items: center;
grid-template-columns: 1fr 1fr 1fr 1fr;
}
.three-columns .picker-body {
grid-template-columns: 1fr 1fr 1fr;
}
.three-columns .popup-header {
max-width: calc(var(--picker-item-size) * 3);
}
:global(.picker-item) {
width: var(--picker-item-size);
height: var(--picker-item-size);
}
@media screen and (max-width: 535px) {
.picker-body {
grid-template-columns: 1fr 1fr 1fr;
}
.popup-header {
max-width: calc(var(--picker-item-size) * 3);
}
}
@media screen and (max-width: 400px) {
.picker-dialog {
--picker-item-size: 115px;
}
}
@media screen and (max-width: 380px) {
.picker-dialog {
--picker-item-size: 110px;
}
}
@media screen and (max-width: 365px) {
.picker-dialog {
--picker-item-size: 105px;
}
}
@media screen and (max-width: 350px) {
.picker-dialog {
--picker-item-size: 100px;
}
}
@media screen and (max-width: 335px) {
.picker-body,
.three-columns .picker-body {
grid-template-columns: 1fr 1fr;
}
.popup-header {
max-width: calc(var(--picker-item-size) * 3);
}
}
@media screen and (max-width: 255px) {
.picker-dialog {
--picker-item-size: 120px;
}
.picker-body,
.three-columns .picker-body {
grid-template-columns: 1fr;
}
}
</style>
|