Skip to content

Commit

Permalink
fix: update button based on screen size
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomaz committed May 1, 2024
1 parent 1b69b77 commit 31e4e2b
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions frontend/pages/organizations/[id]/about.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,30 +124,31 @@ const expandReduceText = () => {
textExpanded.value = !textExpanded.value;
};
const currentWidth = ref(window.innerWidth);
let resizeTimeout: ReturnType<typeof setTimeout> | null = null;
const windowWidth = ref(window.innerWidth);
const shareButtonLabel = ref("");
function updateShareBtnLabel() {
if (currentWidth.value < Breakpoint.SMALL) {
windowWidth.value = window.innerWidth;
if (windowWidth.value < Breakpoint.SMALL) {
shareButtonLabel.value = "components.btn-action.share";
} else {
shareButtonLabel.value = "components._global.share-organization";
}
}
const handleResize = () => {
if (resizeTimeout) {
clearTimeout(resizeTimeout);
}
resizeTimeout = setTimeout(updateShareBtnLabel, 100);
};
onMounted(() => {
window.addEventListener("resize", handleResize);
window.addEventListener("resize", updateShareBtnLabel);
updateShareBtnLabel();
});
onUpdated(() => {
updateShareBtnLabel();
});
onUnmounted(() => {
window.removeEventListener("resize", updateShareBtnLabel);
});
// TODO: for testing purpose, should be removed.
// const upVotes = ref(123);
// const downVotes = ref(123);
Expand Down

0 comments on commit 31e4e2b

Please sign in to comment.