ChangelogModal.svelte 3.02 KB
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
<script lang="ts">
2
	import { onMount } from 'svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
3
	import { Confetti } from 'svelte-confetti';
4
5
6

	import { config } from '$lib/stores';

Timothy J. Baek's avatar
Timothy J. Baek committed
7
8
9
	import { WEBUI_NAME, WEB_UI_VERSION } from '$lib/constants';
	import { getChangelog } from '$lib/apis';

10
11
	import Modal from './common/Modal.svelte';

Timothy J. Baek's avatar
Timothy J. Baek committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
	export let show = false;

	let changelog = null;

	onMount(async () => {
		const res = await getChangelog();
		changelog = res;
	});
</script>

<Modal bind:show>
	<div class="px-5 py-4 dark:text-gray-300">
		<div class="flex justify-between items-start">
			<div class="text-xl font-bold">
Timothy J. Baek's avatar
Timothy J. Baek committed
26
				What’s New in {WEBUI_NAME}
Timothy J. Baek's avatar
Timothy J. Baek committed
27
				<Confetti x={[-1, -0.25]} y={[0, 0.5]} />
Timothy J. Baek's avatar
Timothy J. Baek committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
			</div>
			<button
				class="self-center"
				on:click={() => {
					show = false;
				}}
			>
				<svg
					xmlns="http://www.w3.org/2000/svg"
					viewBox="0 0 20 20"
					fill="currentColor"
					class="w-5 h-5"
				>
					<path
						d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
					/>
				</svg>
			</button>
		</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
47
		<div class="flex items-center mt-1">
Timothy J. Baek's avatar
Timothy J. Baek committed
48
49
50
51
52
53
			<div class="text-sm dark:text-gray-200">Release Notes</div>
			<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-200 dark:bg-gray-700" />
			<div class="text-sm dark:text-gray-200">
				v{WEB_UI_VERSION}
			</div>
		</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
54
55
56
57
58
	</div>

	<hr class=" dark:border-gray-800" />

	<div class=" w-full p-4 px-5">
Timothy J. Baek's avatar
Timothy J. Baek committed
59
		<div class=" overflow-y-scroll max-h-80">
Timothy J. Baek's avatar
Timothy J. Baek committed
60
			<div class="mb-3">
Timothy J. Baek's avatar
Timothy J. Baek committed
61
62
63
64
65
66
				{#if changelog}
					{#each Object.keys(changelog) as version}
						<div class="font-bold text-xl mb-1">
							v{version} - {changelog[version].date}
						</div>

Timothy J. Baek's avatar
Timothy J. Baek committed
67
68
						<hr class=" dark:border-gray-800 my-2" />

Timothy J. Baek's avatar
Timothy J. Baek committed
69
						{#each Object.keys(changelog[version]).filter((section) => section !== 'date') as section}
Timothy J. Baek's avatar
Timothy J. Baek committed
70
71
72
							<div class="">
								<div
									class="font-bold capitalize text-xs {section === 'added'
Timothy J. Baek's avatar
Timothy J. Baek committed
73
										? 'text-white bg-blue-600'
Timothy J. Baek's avatar
Timothy J. Baek committed
74
										: section === 'fixed'
Timothy J. Baek's avatar
Timothy J. Baek committed
75
										? 'text-white bg-green-600'
Timothy J. Baek's avatar
Timothy J. Baek committed
76
										: section === 'changed'
Timothy J. Baek's avatar
Timothy J. Baek committed
77
										? 'text-white bg-yellow-600'
Timothy J. Baek's avatar
Timothy J. Baek committed
78
										: section === 'removed'
Timothy J. Baek's avatar
Timothy J. Baek committed
79
										? 'text-white bg-red-600'
Timothy J. Baek's avatar
Timothy J. Baek committed
80
81
82
83
										: ''}  w-fit px-3 rounded-full my-3"
								>
									{section}
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
84

Timothy J. Baek's avatar
Timothy J. Baek committed
85
								<div class="my-1.5 px-1.5">
Timothy J. Baek's avatar
Timothy J. Baek committed
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
									{#each Object.keys(changelog[version][section]) as item}
										<div class="text-sm mb-2">
											<div class="font-semibold">
												{changelog[version][section][item].title}
											</div>
											<div class="my-1.5">{changelog[version][section][item].content}</div>
										</div>
									{/each}
								</div>
							</div>
						{/each}
					{/each}
				{/if}
			</div>
		</div>
		<div class="flex justify-end pt-3 text-sm font-medium">
			<button
				on:click={() => {
104
					localStorage.version = $config.version;
Timothy J. Baek's avatar
Timothy J. Baek committed
105
106
107
108
					show = false;
				}}
				class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
			>
109
				<span class="relative">Okay, Let's Go!</span>
Timothy J. Baek's avatar
Timothy J. Baek committed
110
111
112
113
			</button>
		</div>
	</div>
</Modal>