change support btn
This commit is contained in:
@@ -98,15 +98,22 @@ function restorePosition() {
|
||||
placed.value = clampAnchor(saved, el)
|
||||
}
|
||||
|
||||
function equalizePills() {
|
||||
function lockPillWidth() {
|
||||
const root = rootRef.value
|
||||
if (!root) return
|
||||
const pills = [...root.querySelectorAll<HTMLElement>('.support-widget__link, .support-widget__fab')]
|
||||
if (!pills.length) return
|
||||
for (const pill of pills) pill.style.width = 'max-content'
|
||||
const width = Math.ceil(Math.max(...pills.map((pill) => pill.getBoundingClientRect().width)))
|
||||
for (const pill of pills) pill.style.width = ''
|
||||
root.style.setProperty('--support-pill-width', `${width}px`)
|
||||
const probe = document.createElement('div')
|
||||
probe.style.cssText = 'position:fixed;left:-9999px;top:0;visibility:hidden;pointer-events:none;width:max-content;'
|
||||
for (const pill of pills) {
|
||||
const clone = pill.cloneNode(true) as HTMLElement
|
||||
clone.style.width = 'max-content'
|
||||
probe.appendChild(clone)
|
||||
}
|
||||
document.body.appendChild(probe)
|
||||
const width = Math.ceil(probe.getBoundingClientRect().width)
|
||||
probe.remove()
|
||||
if (width > 0) root.style.setProperty('--support-pill-width', `${width}px`)
|
||||
}
|
||||
|
||||
function fitPanel() {
|
||||
@@ -119,7 +126,6 @@ function fitPanel() {
|
||||
panel.style.maxHeight = ''
|
||||
panel.style.overflowY = ''
|
||||
}
|
||||
equalizePills()
|
||||
|
||||
const rect = root.getBoundingClientRect()
|
||||
const overflowLeft = EDGE - rect.left
|
||||
@@ -268,17 +274,19 @@ watch(hasSupportLinks, (ok) => {
|
||||
|
||||
watch(showWidget, (show) => {
|
||||
if (!show) return
|
||||
void nextTick(() => requestAnimationFrame(() => restorePosition()))
|
||||
void nextTick(() => {
|
||||
lockPillWidth()
|
||||
requestAnimationFrame(() => restorePosition())
|
||||
})
|
||||
})
|
||||
|
||||
watch(supportLinks, () => {
|
||||
if (!showWidget.value) return
|
||||
void nextTick(() => lockPillWidth())
|
||||
})
|
||||
|
||||
watch(open, (isOpen) => {
|
||||
if (!isOpen) {
|
||||
if (rootRef.value) {
|
||||
rootRef.value.style.transform = ''
|
||||
rootRef.value.style.removeProperty('--support-pill-width')
|
||||
}
|
||||
return
|
||||
}
|
||||
if (!isOpen) return
|
||||
void nextTick(() => fitPanel())
|
||||
})
|
||||
|
||||
@@ -303,15 +311,15 @@ watch(dragging, (isDragging) => {
|
||||
:class="{ 'support-widget--above-nav': props.aboveBottomNav }"
|
||||
:style="widgetStyle"
|
||||
>
|
||||
<Transition name="support-pop" @after-enter="fitPanel">
|
||||
<div
|
||||
v-if="open"
|
||||
ref="panelRef"
|
||||
class="support-widget__panel"
|
||||
role="dialog"
|
||||
aria-label="پشتیبانی"
|
||||
aria-modal="false"
|
||||
>
|
||||
<div
|
||||
ref="panelRef"
|
||||
class="support-widget__panel"
|
||||
:class="{ 'support-widget__panel--open': open }"
|
||||
role="dialog"
|
||||
aria-label="پشتیبانی"
|
||||
:aria-hidden="!open"
|
||||
:inert="!open ? true : undefined"
|
||||
>
|
||||
<ul class="support-widget__list">
|
||||
<li v-for="link in supportLinks" :key="link.kind">
|
||||
<a
|
||||
@@ -371,8 +379,7 @@ watch(dragging, (isDragging) => {
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
@@ -415,8 +422,8 @@ watch(dragging, (isDragging) => {
|
||||
display: grid;
|
||||
grid-auto-flow: row;
|
||||
justify-items: stretch;
|
||||
row-gap: 8px;
|
||||
width: max-content;
|
||||
row-gap: 0;
|
||||
width: min(var(--support-pill-width, max-content), calc(100vw - 20px));
|
||||
max-width: calc(100vw - 20px);
|
||||
pointer-events: none;
|
||||
}
|
||||
@@ -441,8 +448,9 @@ watch(dragging, (isDragging) => {
|
||||
}
|
||||
|
||||
.support-widget__fab {
|
||||
width: min(var(--support-pill-width, max-content), calc(100vw - 20px));
|
||||
width: 100%;
|
||||
height: 38px;
|
||||
flex-shrink: 0;
|
||||
padding-inline: 14px 11px;
|
||||
border: 1px solid rgba(21, 32, 51, 0.06);
|
||||
border-radius: 999px;
|
||||
@@ -517,14 +525,30 @@ watch(dragging, (isDragging) => {
|
||||
background: #eef1f4;
|
||||
}
|
||||
|
||||
.support-widget__panel {
|
||||
width: 100%;
|
||||
.support-widget > .support-widget__panel {
|
||||
position: absolute;
|
||||
inset-inline: 0;
|
||||
bottom: calc(100% + 8px);
|
||||
width: auto;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
overflow: visible;
|
||||
transform-origin: bottom center;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
transition:
|
||||
opacity 0.16s ease,
|
||||
visibility 0s linear 0.16s;
|
||||
}
|
||||
|
||||
.support-widget > .support-widget__panel.support-widget__panel--open {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
pointer-events: auto;
|
||||
transition:
|
||||
opacity 0.16s ease,
|
||||
visibility 0s;
|
||||
}
|
||||
|
||||
.support-widget__list {
|
||||
@@ -541,8 +565,9 @@ watch(dragging, (isDragging) => {
|
||||
}
|
||||
|
||||
.support-widget__link {
|
||||
width: min(var(--support-pill-width, max-content), calc(100vw - 20px));
|
||||
width: 100%;
|
||||
height: 38px;
|
||||
flex-shrink: 0;
|
||||
padding-inline: 14px 11px;
|
||||
border: 1px solid rgba(21, 32, 51, 0.06);
|
||||
border-radius: 999px;
|
||||
@@ -612,17 +637,4 @@ watch(dragging, (isDragging) => {
|
||||
:global(html.dark) .support-widget__link:active {
|
||||
background: #eef1f4;
|
||||
}
|
||||
|
||||
.support-pop-enter-active,
|
||||
.support-pop-leave-active {
|
||||
transition:
|
||||
opacity 0.16s ease,
|
||||
transform 0.16s ease;
|
||||
}
|
||||
|
||||
.support-pop-enter-from,
|
||||
.support-pop-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(8px) scale(0.97);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user