mirror of https://github.com/Budibase/budibase.git
committed by
GitHub
7 changed files with 107 additions and 36 deletions
@ -0,0 +1,31 @@ |
|||
<script> |
|||
import Provider from "./Provider.svelte" |
|||
import { onMount } from "svelte" |
|||
|
|||
let width = window.innerWidth |
|||
const tabletBreakpoint = 768 |
|||
const desktopBreakpoint = 1280 |
|||
const resizeObserver = new ResizeObserver(entries => { |
|||
if (entries?.[0]) { |
|||
width = entries[0].contentRect?.width |
|||
} |
|||
}) |
|||
|
|||
$: data = { |
|||
mobile: width && width < tabletBreakpoint, |
|||
tablet: width && width >= tabletBreakpoint && width < desktopBreakpoint, |
|||
} |
|||
|
|||
onMount(() => { |
|||
const doc = document.documentElement |
|||
resizeObserver.observe(doc) |
|||
|
|||
return () => { |
|||
resizeObserver.unobserve(doc) |
|||
} |
|||
}) |
|||
</script> |
|||
|
|||
<Provider key="device" {data}> |
|||
<slot /> |
|||
</Provider> |
|||
@ -0,0 +1,19 @@ |
|||
<script> |
|||
import Provider from "./Provider.svelte" |
|||
import { authStore } from "../store" |
|||
import { ActionTypes, TableNames } from "../constants" |
|||
|
|||
// Register this as a refreshable datasource so that user changes cause |
|||
// the user object to be refreshed |
|||
$: actions = [ |
|||
{ |
|||
type: ActionTypes.RefreshDatasource, |
|||
callback: () => authStore.actions.fetchUser(), |
|||
metadata: { dataSource: { type: "table", tableId: TableNames.USERS } }, |
|||
}, |
|||
] |
|||
</script> |
|||
|
|||
<Provider key="user" data={$authStore} {actions}> |
|||
<slot /> |
|||
</Provider> |
|||
Loading…
Reference in new issue