anim: remove hero signal

* BottomSheet: remove hero support
* use StackedRouter's hero support instead
This commit is contained in:
thislight 2024-11-19 17:49:49 +08:00
parent 8588a17bd0
commit 15974af792
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E
3 changed files with 3 additions and 144 deletions

View file

@ -1,58 +1,3 @@
import {
createContext,
createRenderEffect,
createSignal,
untrack,
useContext,
type Accessor,
type Signal,
} from "solid-js";
export type HeroSource = {
[key: string | symbol | number]: HTMLElement | undefined;
};
const HeroSourceContext = createContext<Signal<HeroSource>>(
/* __@PURE__ */ undefined,
);
export const HeroSourceProvider = HeroSourceContext.Provider;
export function useHeroSource() {
return useContext(HeroSourceContext);
}
/**
* Use hero value for the {@link key}.
*
* Note: the setter here won't set the value of the hero source.
* To set hero source, use {@link useHeroSource} and set the corresponding key.
*/
export function useHeroSignal(
key: string | symbol | number,
): Signal<HTMLElement | undefined> {
const source = useHeroSource();
if (source) {
const [get, set] = createSignal<HTMLElement>();
createRenderEffect(() => {
const value = source[0]();
if (value[key]) {
set(value[key]);
source[1]((x) => {
const cpy = Object.assign({}, x);
delete cpy[key];
return cpy;
});
}
});
return [get, set];
} else {
console.debug("no hero source");
return [() => undefined, () => undefined];
}
}
export function animateRollOutFromTop(
root: HTMLElement,