Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Add an override property to the sticky root margin composition #1480

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }
}
Loading