Skip to content

Commit

Permalink
Add an override property
Browse files Browse the repository at this point in the history
  • Loading branch information
znicholasbrown committed Oct 23, 2024
1 parent 860ecc2 commit b1e67ba
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/compositions/useOffsetStickyRootMargin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Ref, computed } from 'vue'
import { Ref, computed, ref } from 'vue'
import { media } from '@/utilities'

type UseOffsetStickyRootMargin = {
margin: Ref<string>,
}

export const overrideMargins = ref<string>()

/**
* The useOffsetStickyRootMargin composition is used to provide a rootMargin
* value for sticky headers that are intended to align with the top of the page,
Expand All @@ -13,7 +15,13 @@ type UseOffsetStickyRootMargin = {
* @returns UseOffsetStickyRootMargin
*/
export function useOffsetStickyRootMargin(): UseOffsetStickyRootMargin {
const margin = computed(() => media.lg ? '-1px 0px 0px 0px' : '-65px 0px 0px 0px')
const margin = computed(() => {
if (overrideMargins.value) {
return overrideMargins.value
}

return media.lg ? '-1px 0px 0px 0px' : '-65px 0px 0px 0px'
})

return { margin }
}

0 comments on commit b1e67ba

Please sign in to comment.