Skip to content

Commit

Permalink
feat(components): improve a11y on backToTop button
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Nov 20, 2023
1 parent 46f930d commit dcfbe3f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
36 changes: 22 additions & 14 deletions packages/components/src/client/components/BackToTop.ts
Expand Up @@ -56,7 +56,7 @@ export default defineComponent({
);

const progress = computed(
() => y.value / (bodyHeight.value - windowHeight.value),
() => (y.value / (bodyHeight.value - windowHeight.value)) * 100,
);

onMounted(() => {
Expand All @@ -83,19 +83,27 @@ export default defineComponent({
props.noProgress
? null
: h(
"svg",
{ class: "vp-scroll-progress" },
h("circle", {
cx: "50%",
cy: "50%",
style: {
"stroke-dasharray": `calc(${
Math.PI * progress.value * 100
}% - ${4 * Math.PI}px) calc(${Math.PI * 100}% - ${
4 * Math.PI
}px)`,
},
}),
"span",
{
class: "vp-scroll-progress",
role: "progressbar",
"aria-labelledby": "loadinglabel",
"aria-valuenow": progress.value,
},
h(
"svg",
h("circle", {
cx: "50%",
cy: "50%",
style: {
"stroke-dasharray": `calc(${
Math.PI * progress.value
}% - ${4 * Math.PI}px) calc(${Math.PI * 100}% - ${
4 * Math.PI
}px)`,
},
}),
),
),
h(BackToTopIcon),
],
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/client/styles/back-to-top.scss
Expand Up @@ -56,6 +56,11 @@
height: 40px;
}

svg {
width: 100%;
height: 100%;
}

circle {
opacity: 0.9;
fill: none;
Expand Down

1 comment on commit dcfbe3f

@thanesh
Copy link

@thanesh thanesh commented on dcfbe3f Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be broken in production. You no longer see the progress that was visible in v2.0.0-rc.0

Please sign in to comment.