feat(responsiveManager): add a manager to monitor responsive state and give access to responsive state flags
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<!--
|
||||
Component: ResponsiveProvider
|
||||
Provides a responsive manager to all children
|
||||
-->
|
||||
<script lang="ts">
|
||||
import {
|
||||
type ResponsiveManager,
|
||||
createResponsiveManager,
|
||||
} from '$shared/lib/helpers';
|
||||
import { setContext } from 'svelte';
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
interface Props {
|
||||
children: Snippet;
|
||||
}
|
||||
|
||||
let { children }: Props = $props();
|
||||
|
||||
const responsive = createResponsiveManager();
|
||||
|
||||
// Initialize and cleanup
|
||||
$effect(() => {
|
||||
return responsive.init();
|
||||
});
|
||||
|
||||
// Provide to all children
|
||||
setContext('responsive', responsive);
|
||||
</script>
|
||||
|
||||
{@render children()}
|
||||
1
src/shared/lib/providers/index.ts
Normal file
1
src/shared/lib/providers/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as ResponsiveProvider } from './ResponsiveProvider/ResponsiveProvider.svelte';
|
||||
Reference in New Issue
Block a user