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

fix(anchor-overscrolls): update css to fix anchor overscroll in main content #3889

Merged
merged 10 commits into from
Oct 31, 2023
9 changes: 2 additions & 7 deletions packages/docs/composables/useDocsScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ export const useDocsScroll = () => {
const pageContent = document.querySelector('.docs-layout__main-content')

if (pageContent) {
pageContent.scrollTop = 0
pageContent.scrollIntoView(true);
}
}

const scrollToElement = () => {
if (route.hash) {
if (typeof document === 'undefined') { return }
const el = document.querySelector(route.hash)

el?.scrollIntoView({ behavior: 'smooth', block: 'start', inline: 'nearest' })
} else {
if (!route.hash) {
scrollTop()
}
}
Expand Down
2 changes: 0 additions & 2 deletions packages/docs/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ html {
display: flex;
justify-content: center;
background: var(--va-background-primary);

// @include va-scroll(var(--va-primary));
}

&__page-content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export default defineComponent({
opacity: 0;
font-size: 95%;
transition: opacity 0.1s ease-in-out;

&:focus {
opacity: 1;
}

&--force-show {
opacity: 1;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/docs/page-config/ui-elements/avatar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export default definePageConfig({
block.subtitle("Examples"),

block.example("Default", {
title: 'By default `va-avatar` is displayed as a circle container.'
title: 'Default',
description: 'By default `va-avatar` is displayed as a circle container.'
}),

block.example("WithImage", {
Expand Down
11 changes: 10 additions & 1 deletion packages/ui/src/components/va-layout/VaLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default defineComponent({
components: { VaLayoutArea },

setup (props, { slots }) {
useLayout(props)
const { paddings } = useLayout(props)

const doDisableScroll = computed(() => {
return !props.allowBodyScrollOnOverlay && areaNames.some((area) => props[area]?.overlay)
Expand Down Expand Up @@ -94,6 +94,7 @@ export default defineComponent({
.filter(Boolean)
.join(' ')
}),
paddings,
}
},
})
Expand Down Expand Up @@ -123,6 +124,14 @@ export default defineComponent({
// Make it possible for content to be smaller than the layout
min-width: 0;
min-height: 0;

// When scroll anchor is present in content, there might be overflow, so we add scroll margins
[id] {
scroll-margin-top: calc(v-bind("paddings.top + 'px'") + var(--va-layout-scroll-padding));
scroll-margin-bottom: calc(v-bind("paddings.bottom + 'px'") + var(--va-layout-scroll-padding));
scroll-margin-left: calc(v-bind("paddings.left + 'px'") + var(--va-layout-scroll-padding));
scroll-margin-right: calc(v-bind("paddings.right + 'px'") + var(--va-layout-scroll-padding));
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/va-layout/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
:root,
:host {
--va-layout-overlay-color: rgba(0, 0, 0, 0.5);
--va-layout-scroll-padding: 1rem;
}
6 changes: 6 additions & 0 deletions packages/ui/src/components/va-layout/hooks/useLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ export const useLayout = (props: ExtractPropTypes<typeof useLayoutProps>) => {
paddings,
orders,
})

return {
paddings,
orders,
items,
}
}

export const useFixedLayoutChild = (area: AreaName, sizes: Ref<DOMRectReadOnly | null>) => {
Expand Down
Loading