Skip to content

Commit

Permalink
refactor: ui icon buttons (#15531)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 authored Jan 22, 2025
1 parent 1f19a65 commit 78464a4
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 146 deletions.
8 changes: 4 additions & 4 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"dependencies": {
"@formatjs/icu-messageformat-parser": "^2.9.8",
"@immich/sdk": "file:../open-api/typescript-sdk",
"@immich/ui": "^0.14.1",
"@immich/ui": "^0.15.0",
"@mapbox/mapbox-gl-rtl-text": "0.2.3",
"@mdi/js": "^7.4.47",
"@photo-sphere-viewer/core": "^5.11.5",
Expand Down
36 changes: 26 additions & 10 deletions web/src/lib/components/album-page/albums-controls.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import Dropdown from '$lib/components/elements/dropdown.svelte';
import GroupTab from '$lib/components/elements/group-tab.svelte';
import Icon from '$lib/components/elements/icon.svelte';
import SearchBar from '$lib/components/elements/search-bar.svelte';
import {
AlbumFilter,
Expand Down Expand Up @@ -129,8 +128,13 @@
</div>

<!-- Create Album -->
<Button onclick={() => createAlbumAndRedirect()} size="small" variant="ghost" color="secondary">
<Icon path={mdiPlusBoxOutline} />
<Button
leadingIcon={mdiPlusBoxOutline}
onclick={() => createAlbumAndRedirect()}
size="small"
variant="ghost"
color="secondary"
>
<p class="hidden md:block">{$t('create_album')}</p>
</Button>

Expand Down Expand Up @@ -190,12 +194,24 @@
{/if}

<!-- Cover/List Display Toggle -->
<Button onclick={() => handleChangeListMode()} size="small" variant="ghost" color="secondary">
{#if $albumViewSettings.view === AlbumViewMode.List}
<Icon path={mdiViewGridOutline} />
{#if $albumViewSettings.view === AlbumViewMode.List}
<Button
leadingIcon={mdiViewGridOutline}
onclick={() => handleChangeListMode()}
size="small"
variant="ghost"
color="secondary"
>
<Text class="hidden md:block">{$t('covers')}</Text>
{:else}
<Icon path={mdiFormatListBulletedSquare} size="18" />
</Button>
{:else}
<Button
leadingIcon={mdiFormatListBulletedSquare}
onclick={() => handleChangeListMode()}
size="small"
variant="ghost"
color="secondary"
>
<Text class="hidden md:block">{$t('list')}</Text>
{/if}
</Button>
</Button>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { clickOutside } from '$lib/actions/click-outside';
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
import SkipLink from '$lib/components/elements/buttons/skip-link.svelte';
import Icon from '$lib/components/elements/icon.svelte';
import HelpAndFeedbackModal from '$lib/components/shared-components/help-and-feedback-modal.svelte';
import ImmichLogo from '$lib/components/shared-components/immich-logo.svelte';
import SearchBar from '$lib/components/shared-components/search-bar/search-bar.svelte';
Expand Down Expand Up @@ -99,11 +98,13 @@
</div>

{#if !page.url.pathname.includes('/admin') && showUploadButton}
<Button onclick={onUploadClick} class="hidden lg:block" variant="ghost" color="secondary">
<div class="flex gap-2">
<Icon path={mdiTrayArrowUp} size="1.5em" />
<span>{$t('upload')}</span>
</div>
<Button
leadingIcon={mdiTrayArrowUp}
onclick={onUploadClick}
class="hidden lg:flex"
variant="ghost"
color="secondary"
>{$t('upload')}
</Button>
<CircleIconButton
onclick={onUploadClick}
Expand Down
13 changes: 8 additions & 5 deletions web/src/routes/(user)/people/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
updatePerson,
type PersonResponseDto,
} from '@immich/sdk';
import { Button, Text } from '@immich/ui';
import { Button } from '@immich/ui';
import { mdiAccountOff, mdiEyeOutline } from '@mdi/js';
import { onMount } from 'svelte';
import { t } from 'svelte-i18n';
Expand Down Expand Up @@ -392,10 +392,13 @@
/>
</div>
</div>
<Button onclick={() => (selectHidden = !selectHidden)} size="small" variant="ghost" color="secondary">
<Icon path={mdiEyeOutline} />
<Text>{$t('show_and_hide_people')}</Text>
</Button>
<Button
leadingIcon={mdiEyeOutline}
onclick={() => (selectHidden = !selectHidden)}
size="small"
variant="ghost"
color="secondary">{$t('show_and_hide_people')}</Button
>
</div>
{/if}
{/snippet}
Expand Down
20 changes: 11 additions & 9 deletions web/src/routes/(user)/sharing/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import empty2Url from '$lib/assets/empty-2.svg';
import Albums from '$lib/components/album-page/albums-list.svelte';
import Icon from '$lib/components/elements/icon.svelte';
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
import EmptyPlaceholder from '$lib/components/shared-components/empty-placeholder.svelte';
import UserAvatar from '$lib/components/shared-components/user-avatar.svelte';
Expand All @@ -15,7 +14,7 @@
type AlbumViewSettings,
} from '$lib/stores/preferences.store';
import { createAlbumAndRedirect } from '$lib/utils/album-utils';
import { Button, HStack } from '@immich/ui';
import { Button, HStack, Text } from '@immich/ui';
import { mdiLink, mdiPlusBoxOutline } from '@mdi/js';
import { t } from 'svelte-i18n';
import type { PageData } from './$types';
Expand All @@ -40,14 +39,17 @@
<UserPageLayout title={data.meta.title}>
{#snippet buttons()}
<HStack gap={0}>
<Button onclick={() => createAlbumAndRedirect()} size="small" variant="ghost" color="secondary">
<Icon path={mdiPlusBoxOutline} class="shrink-0" />
<span class="leading-none max-sm:text-xs">{$t('create_album')}</span>
<Button
leadingIcon={mdiPlusBoxOutline}
onclick={() => createAlbumAndRedirect()}
size="small"
variant="ghost"
color="secondary"
>
<Text class="hidden md:block">{$t('create_album')}</Text>
</Button>

<Button href={AppRoute.SHARED_LINKS} size="small" variant="ghost" color="secondary">
<Icon path={mdiLink} class="shrink-0" />
<span class="leading-none max-sm:text-xs">{$t('shared_links')}</span>
<Button leadingIcon={mdiLink} href={AppRoute.SHARED_LINKS} size="small" variant="ghost" color="secondary">
<Text class="hidden md:block">{$t('shared_links')}</Text>
</Button>
</HStack>
{/snippet}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import SkipLink from '$lib/components/elements/buttons/skip-link.svelte';
import Icon from '$lib/components/elements/icon.svelte';
import UserPageLayout, { headerId } from '$lib/components/layouts/user-page-layout.svelte';
import AssetGrid from '$lib/components/photos-page/asset-grid.svelte';
import { dialogController } from '$lib/components/shared-components/dialog/dialog';
Expand Down Expand Up @@ -169,18 +168,15 @@

{#snippet buttons()}
<HStack>
<Button onclick={handleCreate} size="small" variant="ghost" color="secondary">
<Icon path={mdiPlus} />
<p class="hidden md:block">{$t('create_tag')}</p>
<Button leadingIcon={mdiPlus} onclick={handleCreate} size="small" variant="ghost" color="secondary">
<Text class="hidden md:block">{$t('create_tag')}</Text>
</Button>

{#if pathSegments.length > 0 && tag}
<Button onclick={handleEdit} size="small" variant="ghost" color="secondary">
<Icon path={mdiPencil} size="18" />
<Button leadingIcon={mdiPencil} onclick={handleEdit} size="small" variant="ghost" color="secondary">
<Text class="hidden md:block">{$t('edit_tag')}</Text>
</Button>
<Button onclick={handleDelete} size="small" variant="ghost" color="secondary">
<Icon path={mdiTrashCanOutline} />
<Button leadingIcon={mdiTrashCanOutline} onclick={handleDelete} size="small" variant="ghost" color="secondary">
<Text class="hidden md:block">{$t('delete_tag')}</Text>
</Button>
{/if}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import { goto } from '$app/navigation';
import empty3Url from '$lib/assets/empty-3.svg';
import Icon from '$lib/components/elements/icon.svelte';
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
import DeleteAssets from '$lib/components/photos-page/actions/delete-assets.svelte';
import RestoreAssets from '$lib/components/photos-page/actions/restore-assets.svelte';
Expand All @@ -21,7 +20,7 @@
import { handlePromiseError } from '$lib/utils';
import { handleError } from '$lib/utils/handle-error';
import { emptyTrash, restoreTrash } from '@immich/sdk';
import { Button, HStack } from '@immich/ui';
import { Button, HStack, Text } from '@immich/ui';
import { mdiDeleteForeverOutline, mdiHistory } from '@mdi/js';
import { onDestroy } from 'svelte';
import { t } from 'svelte-i18n';
Expand Down Expand Up @@ -115,24 +114,24 @@
{#snippet buttons()}
<HStack gap={0}>
<Button
leadingIcon={mdiHistory}
onclick={handleRestoreTrash}
disabled={assetInteraction.selectionActive}
variant="ghost"
color="secondary"
size="small"
>
<Icon path={mdiHistory} />
{$t('restore_all')}
<Text class="hidden md:block">{$t('restore_all')}</Text>
</Button>
<Button
leadingIcon={mdiDeleteForeverOutline}
onclick={() => handleEmptyTrash()}
disabled={assetInteraction.selectionActive}
variant="ghost"
color="secondary"
size="small"
>
<Icon path={mdiDeleteForeverOutline} />
{$t('empty_trash')}
<Text class="hidden md:block">{$t('empty_trash')}</Text>
</Button>
</HStack>
{/snippet}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
import Icon from '$lib/components/elements/icon.svelte';
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
import { dialogController } from '$lib/components/shared-components/dialog/dialog';
import DuplicatesModal from '$lib/components/shared-components/duplicates-modal.svelte';
Expand All @@ -17,7 +16,7 @@
import { handleError } from '$lib/utils/handle-error';
import type { AssetResponseDto } from '@immich/sdk';
import { deleteAssets, updateAssets } from '@immich/sdk';
import { Button, HStack, IconButton } from '@immich/ui';
import { Button, HStack, IconButton, Text } from '@immich/ui';
import { mdiCheckOutline, mdiInformationOutline, mdiKeyboard, mdiTrashCanOutline } from '@mdi/js';
import { t } from 'svelte-i18n';
import type { PageData } from './$types';
Expand Down Expand Up @@ -164,18 +163,24 @@
{#snippet buttons()}
<HStack gap={0}>
<Button
leadingIcon={mdiTrashCanOutline}
onclick={() => handleDeduplicateAll()}
disabled={!hasDuplicates}
size="small"
variant="ghost"
color="secondary"
>
<Icon path={mdiTrashCanOutline} />
{$t('deduplicate_all')}
<Text class="hidden md:block">{$t('deduplicate_all')}</Text>
</Button>
<Button onclick={() => handleKeepAll()} disabled={!hasDuplicates} size="small" variant="ghost" color="secondary">
<Icon path={mdiCheckOutline} />
{$t('keep_all')}
<Button
leadingIcon={mdiCheckOutline}
onclick={() => handleKeepAll()}
disabled={!hasDuplicates}
size="small"
variant="ghost"
color="secondary"
>
<Text class="hidden md:block">{$t('keep_all')}</Text>
</Button>
<IconButton
shape="round"
Expand Down
19 changes: 11 additions & 8 deletions web/src/routes/admin/jobs-status/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import JobsPanel from '$lib/components/admin-page/jobs/jobs-panel.svelte';
import Icon from '$lib/components/elements/icon.svelte';
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
import Combobox, { type ComboBoxOption } from '$lib/components/shared-components/combobox.svelte';
import ConfirmDialog from '$lib/components/shared-components/dialog/confirm-dialog.svelte';
Expand All @@ -12,7 +11,7 @@
import { asyncTimeout } from '$lib/utils';
import { handleError } from '$lib/utils/handle-error';
import { createJob, getAllJobsStatus, ManualJobName, type AllJobStatusResponseDto } from '@immich/sdk';
import { Button, HStack } from '@immich/ui';
import { Button, HStack, Text } from '@immich/ui';
import { mdiCog, mdiPlus } from '@mdi/js';
import { onDestroy, onMount } from 'svelte';
import { t } from 'svelte-i18n';
Expand Down Expand Up @@ -72,13 +71,17 @@
<UserPageLayout title={data.meta.title} admin>
{#snippet buttons()}
<HStack gap={0}>
<Button onclick={() => (isOpen = true)} size="small" variant="ghost" color="secondary">
<Icon path={mdiPlus} size="18" />
{$t('admin.create_job')}
<Button leadingIcon={mdiPlus} onclick={() => (isOpen = true)} size="small" variant="ghost" color="secondary">
<Text class="hidden md:block">{$t('admin.create_job')}</Text>
</Button>
<Button href="{AppRoute.ADMIN_SETTINGS}?isOpen=job" size="small" variant="ghost" color="secondary">
<Icon path={mdiCog} size="18" />
{$t('admin.manage_concurrency')}
<Button
leadingIcon={mdiCog}
href="{AppRoute.ADMIN_SETTINGS}?isOpen=job"
size="small"
variant="ghost"
color="secondary"
>
<Text class="hidden md:block">{$t('admin.manage_concurrency')}</Text>
</Button>
</HStack>
{/snippet}
Expand Down
22 changes: 11 additions & 11 deletions web/src/routes/admin/library-management/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
type LibraryStatsResponseDto,
type UserResponseDto,
} from '@immich/sdk';
import { Button } from '@immich/ui';
import { Button, Text } from '@immich/ui';
import { mdiDatabase, mdiDotsVertical, mdiPlusBoxOutline, mdiSync } from '@mdi/js';
import { onMount } from 'svelte';
import { t } from 'svelte-i18n';
Expand Down Expand Up @@ -220,18 +220,18 @@
{#snippet buttons()}
<div class="flex justify-end gap-2">
{#if libraries.length > 0}
<Button onclick={handleScanAll} size="small" variant="ghost" color="secondary">
<div class="flex gap-1 text-sm">
<Icon path={mdiSync} size="18" />
<span>{$t('scan_all_libraries')}</span>
</div>
<Button leadingIcon={mdiSync} onclick={handleScanAll} size="small" variant="ghost" color="secondary">
<Text class="hidden md:block">{$t('scan_all_libraries')}</Text>
</Button>
{/if}
<Button onclick={() => (toCreateLibrary = true)} size="small" variant="ghost" color="secondary">
<div class="flex gap-1 text-sm">
<Icon path={mdiPlusBoxOutline} size="18" />
<span>{$t('create_library')}</span>
</div>
<Button
leadingIcon={mdiPlusBoxOutline}
onclick={() => (toCreateLibrary = true)}
size="small"
variant="ghost"
color="secondary"
>
<Text class="hidden md:block">{$t('create_library')}</Text>
</Button>
</div>
{/snippet}
Expand Down
Loading

0 comments on commit 78464a4

Please sign in to comment.