mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-04 03:27:09 -05:00 
			
		
		
		
	refactor(web): added types and some small changes (#1722)
This commit is contained in:
		
							parent
							
								
									c90dcde7cc
								
							
						
					
					
						commit
						bd71e087d4
					
				@ -1,8 +1,8 @@
 | 
				
			|||||||
<script lang="ts">
 | 
					<script lang="ts">
 | 
				
			||||||
 | 
						import type Icon from 'svelte-material-icons/AbTesting.svelte';
 | 
				
			||||||
	import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
 | 
						import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// eslint-disable-next-line @typescript-eslint/no-explicit-any
 | 
						export let logo: typeof Icon;
 | 
				
			||||||
	export let logo: any;
 | 
					 | 
				
			||||||
	export let title: string;
 | 
						export let title: string;
 | 
				
			||||||
	export let value: string;
 | 
						export let value: string;
 | 
				
			||||||
	export let unit: string | undefined = undefined;
 | 
						export let unit: string | undefined = undefined;
 | 
				
			||||||
@ -13,13 +13,10 @@
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const maxLength = 13;
 | 
							const maxLength = 13;
 | 
				
			||||||
		let result = '';
 | 
					 | 
				
			||||||
		const valueLength = parseInt(value).toString().length;
 | 
							const valueLength = parseInt(value).toString().length;
 | 
				
			||||||
		const zeroLength = maxLength - valueLength;
 | 
							const zeroLength = maxLength - valueLength;
 | 
				
			||||||
		for (let i = 0; i < zeroLength; i++) {
 | 
					
 | 
				
			||||||
			result += '0';
 | 
							return '0'.repeat(zeroLength);
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return result;
 | 
					 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -330,12 +330,8 @@
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const showAlbumOptionsMenu = (event: CustomEvent) => {
 | 
						const showAlbumOptionsMenu = ({ x, y }: MouseEvent) => {
 | 
				
			||||||
		contextMenuPosition = {
 | 
							contextMenuPosition = { x, y };
 | 
				
			||||||
			x: event.detail.mouseEvent.x,
 | 
					 | 
				
			||||||
			y: event.detail.mouseEvent.y
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		isShowAlbumOptions = !isShowAlbumOptions;
 | 
							isShowAlbumOptions = !isShowAlbumOptions;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -467,7 +463,7 @@
 | 
				
			|||||||
					{#if !isPublicShared}
 | 
										{#if !isPublicShared}
 | 
				
			||||||
						<CircleIconButton
 | 
											<CircleIconButton
 | 
				
			||||||
							title="Album options"
 | 
												title="Album options"
 | 
				
			||||||
							on:click={(event) => showAlbumOptionsMenu(event)}
 | 
												on:click={showAlbumOptionsMenu}
 | 
				
			||||||
							logo={DotsVertical}
 | 
												logo={DotsVertical}
 | 
				
			||||||
						/>
 | 
											/>
 | 
				
			||||||
					{/if}
 | 
										{/if}
 | 
				
			||||||
 | 
				
			|||||||
@ -31,12 +31,8 @@
 | 
				
			|||||||
	let contextMenuPosition = { x: 0, y: 0 };
 | 
						let contextMenuPosition = { x: 0, y: 0 };
 | 
				
			||||||
	let isShowAssetOptions = false;
 | 
						let isShowAssetOptions = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const showOptionsMenu = (event: CustomEvent) => {
 | 
						const showOptionsMenu = ({ x, y }: MouseEvent) => {
 | 
				
			||||||
		contextMenuPosition = {
 | 
							contextMenuPosition = { x, y };
 | 
				
			||||||
			x: event.detail.mouseEvent.x,
 | 
					 | 
				
			||||||
			y: event.detail.mouseEvent.y
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		isShowAssetOptions = !isShowAssetOptions;
 | 
							isShowAssetOptions = !isShowAssetOptions;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -101,11 +97,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		{#if isOwner}
 | 
							{#if isOwner}
 | 
				
			||||||
			<CircleIconButton logo={DeleteOutline} on:click={() => dispatch('delete')} title="Delete" />
 | 
								<CircleIconButton logo={DeleteOutline} on:click={() => dispatch('delete')} title="Delete" />
 | 
				
			||||||
			<CircleIconButton
 | 
								<CircleIconButton logo={DotsVertical} on:click={showOptionsMenu} title="More" />
 | 
				
			||||||
				logo={DotsVertical}
 | 
					 | 
				
			||||||
				on:click={(event) => showOptionsMenu(event)}
 | 
					 | 
				
			||||||
				title="More"
 | 
					 | 
				
			||||||
			/>
 | 
					 | 
				
			||||||
		{/if}
 | 
							{/if}
 | 
				
			||||||
	</div>
 | 
						</div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
				
			|||||||
@ -2,31 +2,21 @@
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * This is the circle icon component.
 | 
						 * This is the circle icon component.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	import { createEventDispatcher } from 'svelte';
 | 
						import type Icon from 'svelte-material-icons/AbTesting.svelte';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO: why any here?
 | 
						export let logo: typeof Icon;
 | 
				
			||||||
	// eslint-disable-next-line @typescript-eslint/no-explicit-any
 | 
					 | 
				
			||||||
	export let logo: any;
 | 
					 | 
				
			||||||
	export let backgroundColor = 'transparent';
 | 
						export let backgroundColor = 'transparent';
 | 
				
			||||||
	export let hoverColor = '#e2e7e9';
 | 
						export let hoverColor = '#e2e7e9';
 | 
				
			||||||
	export let size = '24';
 | 
						export let size = '24';
 | 
				
			||||||
	export let title = '';
 | 
						export let title = '';
 | 
				
			||||||
	let iconButton: HTMLButtonElement;
 | 
					 | 
				
			||||||
	const dispatch = createEventDispatcher();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	$: {
 | 
					 | 
				
			||||||
		if (iconButton) {
 | 
					 | 
				
			||||||
			iconButton.style.backgroundColor = backgroundColor;
 | 
					 | 
				
			||||||
			iconButton.style.setProperty('--immich-icon-button-hover-color', hoverColor);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<button
 | 
					<button
 | 
				
			||||||
	{title}
 | 
						{title}
 | 
				
			||||||
	bind:this={iconButton}
 | 
						style:backgroundColor
 | 
				
			||||||
 | 
						style:--immich-icon-button-hover-color={hoverColor}
 | 
				
			||||||
	class={`immich-circle-icon-button dark:text-immich-dark-fg hover:dark:text-immich-dark-gray rounded-full p-3 flex place-items-center place-content-center transition-all`}
 | 
						class={`immich-circle-icon-button dark:text-immich-dark-fg hover:dark:text-immich-dark-gray rounded-full p-3 flex place-items-center place-content-center transition-all`}
 | 
				
			||||||
	on:click={(mouseEvent) => dispatch('click', { mouseEvent })}
 | 
						on:click
 | 
				
			||||||
>
 | 
					>
 | 
				
			||||||
	<svelte:component this={logo} {size} />
 | 
						<svelte:component this={logo} {size} />
 | 
				
			||||||
</button>
 | 
					</button>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,8 +1,8 @@
 | 
				
			|||||||
<script lang="ts">
 | 
					<script lang="ts">
 | 
				
			||||||
 | 
						import type Icon from 'svelte-material-icons/AbTesting.svelte';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	export let title: string;
 | 
						export let title: string;
 | 
				
			||||||
	// TODO: why `any` here? There should be a expected type for this
 | 
						export let logo: typeof Icon;
 | 
				
			||||||
	// eslint-disable-next-line @typescript-eslint/no-explicit-any
 | 
					 | 
				
			||||||
	export let logo: any;
 | 
					 | 
				
			||||||
	export let isSelected: boolean;
 | 
						export let isSelected: boolean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	import { createEventDispatcher } from 'svelte';
 | 
						import { createEventDispatcher } from 'svelte';
 | 
				
			||||||
 | 
				
			|||||||
@ -64,12 +64,8 @@
 | 
				
			|||||||
	let isShowAlbumPicker = false;
 | 
						let isShowAlbumPicker = false;
 | 
				
			||||||
	let addToSharedAlbum = false;
 | 
						let addToSharedAlbum = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const handleShowMenu = (event: CustomEvent) => {
 | 
						const handleShowMenu = ({ x, y }: MouseEvent) => {
 | 
				
			||||||
		contextMenuPosition = {
 | 
							contextMenuPosition = { x, y };
 | 
				
			||||||
			x: event.detail.mouseEvent.x,
 | 
					 | 
				
			||||||
			y: event.detail.mouseEvent.y
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		isShowAddMenu = !isShowAddMenu;
 | 
							isShowAddMenu = !isShowAddMenu;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user