feature/tauri-v2
svelte 117 lines 2.84 KB
Raw
1 <script lang="ts">
2 import { createEventDispatcher } from "svelte";
3
4 export let title: string;
5 export let description = "";
6 export let open = false;
7
8 let popup = null;
9 let wrapper = null;
10
11 const dispatch = createEventDispatcher();
12
13 function handleClick(e)
14 {
15 if (e.target === wrapper) {
16 open = false;
17 }
18 }
19 </script>
20
21 {#if open}
22 <!-- svelte-ignore a11y-click-events-have-key-events -->
23 <div class="popup-wrapper" bind:this={wrapper} on:click={handleClick}>
24 <div class="popup-container" bind:this={popup}>
25 <div class="popup-header">
26 <span class="title">{title}</span>
27 </div>
28 <div class="popup-content">
29 <p class="description">{description}</p>
30 <div class="content">
31 <slot></slot>
32 </div>
33 <div class="button-group">
34 <slot name="buttons"></slot>
35 </div>
36 </div>
37 </div>
38 </div>
39 {/if}
40
41 <style lang="scss">
42 .popup-wrapper {
43 position: fixed;
44 top: 0;
45 left: 0;
46 display: flex;
47 justify-content: center;
48 align-items: center;
49 width: 100vw;
50 height: 100vh;
51 z-index: 3;
52 }
53 .popup-container {
54 position: static;
55 min-height: 25%;
56 min-width: 45%;
57 border-radius: 2px;
58 }
59 @media(min-width: 42rem) {
60 .popup-container {
61 position: static;
62 width: 84%;
63 height: auto;
64 max-height: 90%
65 }
66 }
67 @media(min-width: 66rem) {
68 .popup-container {
69 width: 60%;
70 max-height: 84%
71 }
72 }
73 @media(min-width: 82rem) {
74 .popup-container {
75 width: 48%
76 }
77 }
78 .popup-header {
79 display: flex;
80 align-items: center;
81 padding: 1.5rem 3rem 0.5rem 1rem;
82 font-size: 1.25rem;
83 }
84 .popup-content {
85 display: flex;
86 padding: 1rem 3rem 0.5rem 1rem;
87 flex-direction: column;
88 justify-content: center;
89 .description {
90 margin-top: -5px;
91 font-size: 0.9rem;
92 }
93 .content {
94 width: 100%;
95 }
96 .button-group {
97 width: 100%;
98 display: flex;
99 align-items: center;
100 justify-content: center;
101 margin-top: 40px;
102 margin-bottom: 30px;
103 :global(button) {
104 min-width: 90px;
105 height: 35px;
106 border-radius: 2px;
107 margin: 0 10px;
108 display: flex;
109 justify-content: center;
110 align-items: center;
111 cursor: pointer;
112 padding: 0 10px;
113 font-size: 15px;
114 }
115 }
116 }
117 </style>