fix(ui): wrap control bar when content is too long (#815)

This commit is contained in:
Mees Frensel
2026-09-18 20:05:03 -04:00
committed by GitHub
parent 46b1c36d0c
commit ddef39fefa
3 changed files with 37 additions and 6 deletions
@@ -1,9 +1,24 @@
<script lang="ts"> <script lang="ts">
import { ControlBar, ControlBarHeader, ControlBarTitle, Stack, toastManager } from '@immich/ui'; import {
Button,
ControlBar,
ControlBarDescription,
ControlBarHeader,
ControlBarOverflow,
ControlBarTitle,
Heading,
IconButton,
Stack,
toastManager,
} from '@immich/ui';
import { mdiArrowLeft, mdiUndo } from '@mdi/js';
const onClose = () => { const onClose = () => {
toastManager.primary('onClose'); toastManager.primary('onClose');
}; };
const onDone = () => {
toastManager.primary('onDone');
};
</script> </script>
<Stack> <Stack>
@@ -12,4 +27,18 @@
<ControlBarTitle>2 Selected</ControlBarTitle> <ControlBarTitle>2 Selected</ControlBarTitle>
</ControlBarHeader> </ControlBarHeader>
</ControlBar> </ControlBar>
<Heading size="tiny" class="mb-2">Narrow screen</Heading>
<div class="max-w-80">
<ControlBar {onClose} closeIcon={mdiArrowLeft} translations={{ close: 'Back' }}>
<ControlBarHeader>
<ControlBarTitle>Very long person or workflow name</ControlBarTitle>
<ControlBarDescription>Pictures of Mich</ControlBarDescription>
</ControlBarHeader>
<ControlBarOverflow>
<IconButton aria-label="Undo" icon={mdiUndo} variant="ghost" shape="round" color="secondary" />
<Button variant="filled" color="primary" onclick={onDone}>Done</Button>
</ControlBarOverflow>
</ControlBar>
</div>
</Stack> </Stack>
@@ -25,7 +25,7 @@
}: ControlBarProps = $props(); }: ControlBarProps = $props();
const styles = tv({ const styles = tv({
base: `h-control-bar flex w-full items-center gap-2 px-2`, base: `min-h-control-bar flex flex-wrap w-full items-center gap-2 p-2`,
variants: { variants: {
variant: { variant: {
filled: 'bg-light-100', filled: 'bg-light-100',
@@ -60,7 +60,7 @@
class={cleanClass(styles({ shape, variant }), className)} class={cleanClass(styles({ shape, variant }), className)}
{...restProps} {...restProps}
> >
<div class={cleanClass('flex shrink-0 items-center gap-2')}> <div class={cleanClass('flex max-w-full items-center gap-2')}>
{#if typeof closeIcon === 'function'} {#if typeof closeIcon === 'function'}
{@render closeIcon?.()} {@render closeIcon?.()}
{:else if onClose} {:else if onClose}
@@ -70,13 +70,14 @@
shape="round" shape="round"
variant="ghost" variant="ghost"
color="secondary" color="secondary"
class="shrink-0"
aria-label={t('close', translations)} aria-label={t('close', translations)}
onclick={() => onClose()} onclick={() => onClose()}
/> />
{/if} {/if}
{#if headerChild} {#if headerChild}
<div class={cleanClass('flex shrink-0 flex-col', headerChild.class)}> <div class={cleanClass('flex flex-col truncate', headerChild.class)}>
{@render headerChild.children?.()} {@render headerChild.children?.()}
</div> </div>
{/if} {/if}
@@ -87,7 +88,7 @@
</div> </div>
{#if overflowChild} {#if overflowChild}
<div class={cleanClass('flex shrink-0 items-center gap-2', overflowChild.class)}> <div class={cleanClass('flex shrink-0 ms-auto items-center gap-2', overflowChild.class)}>
{@render overflowChild.children?.()} {@render overflowChild.children?.()}
</div> </div>
{/if} {/if}
@@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import Heading from '$lib/components/Heading/Heading.svelte'; import Heading from '$lib/components/Heading/Heading.svelte';
import type { Color, FontWeight, HeadingSize, HeadingTag } from '$lib/types.js'; import type { Color, FontWeight, HeadingSize, HeadingTag } from '$lib/types.js';
import { cleanClass } from '$lib/utilities/internal.js';
import type { Snippet } from 'svelte'; import type { Snippet } from 'svelte';
type Props = { type Props = {
@@ -18,6 +19,6 @@
const { size = 'small', fontWeight = 'medium', color, tag, class: className, children }: Props = $props(); const { size = 'small', fontWeight = 'medium', color, tag, class: className, children }: Props = $props();
</script> </script>
<Heading {tag} {size} {color} {fontWeight} class={className}> <Heading {tag} {size} {color} {fontWeight} class={cleanClass('truncate', className)}>
{@render children?.()} {@render children?.()}
</Heading> </Heading>