2023-03-03 08:58:47 +00:00
|
|
|
import type { Ref, InjectionKey } from 'vue';
|
|
|
|
import { inject, provide, ref } from 'vue';
|
2023-03-02 02:59:44 +00:00
|
|
|
|
|
|
|
import type { FloatButtonShape } from './interface';
|
|
|
|
|
2023-03-03 08:58:47 +00:00
|
|
|
interface FloatButtonGroupContext {
|
|
|
|
shape: Ref<FloatButtonShape>;
|
2023-03-02 02:59:44 +00:00
|
|
|
}
|
2023-03-03 08:58:47 +00:00
|
|
|
const contextKey: InjectionKey<FloatButtonGroupContext> = Symbol('floatButtonGroupContext');
|
|
|
|
|
|
|
|
export const useProvideFloatButtonGroupContext = (props: FloatButtonGroupContext) => {
|
|
|
|
provide(contextKey, props);
|
2023-03-02 02:59:44 +00:00
|
|
|
|
2023-03-03 08:58:47 +00:00
|
|
|
return props;
|
|
|
|
};
|
2023-03-02 02:59:44 +00:00
|
|
|
|
2023-03-03 08:58:47 +00:00
|
|
|
export const useInjectFloatButtonGroupContext = () => {
|
|
|
|
return inject(contextKey, { shape: ref() } as FloatButtonGroupContext);
|
|
|
|
};
|