layout shifts
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user