This repository has been archived on 2026-08-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
drizzli/src/routes/weather/hero.svelte.ts
T
2026-08-01 13:37:04 +02:00

21 lines
588 B
TypeScript

import { getContext } from 'svelte';
import type { Snippet } from 'svelte';
interface HeroContext {
setActions: (snippet: Snippet | null) => void;
}
/**
* Renders a page's own controls into the shared location row that lives in
* `weather/+layout.svelte`. The row itself stays mounted across navigation;
* only the controls swap, and they are cleared when the page unmounts.
*/
export function useHeroActions(actions: Snippet): void {
const hero = getContext<HeroContext>('weather-hero');
$effect(() => {
hero.setActions(actions);
return () => hero.setActions(null);
});
}