Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
a367d364df
|
|||
|
27fee3ac34
|
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "tools-app",
|
"name": "tools-app",
|
||||||
"version": "0.6.21",
|
"version": "0.6.22",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "tools-app",
|
"name": "tools-app",
|
||||||
"version": "0.6.21",
|
"version": "0.6.22",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@gkucmierz/utils": "^1.28.7",
|
"@gkucmierz/utils": "^1.28.7",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "tools-app",
|
"name": "tools-app",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.6.21",
|
"version": "0.6.22",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import Footer from './components/Footer.vue'
|
|||||||
import Sidebar from './components/Sidebar.vue'
|
import Sidebar from './components/Sidebar.vue'
|
||||||
import InstallPrompt from './components/InstallPrompt.vue'
|
import InstallPrompt from './components/InstallPrompt.vue'
|
||||||
import ReloadPrompt from './components/ReloadPrompt.vue'
|
import ReloadPrompt from './components/ReloadPrompt.vue'
|
||||||
|
import GlobalTooltip from './components/common/GlobalTooltip.vue'
|
||||||
import { UI_CONFIG } from './config/ui'
|
import { UI_CONFIG } from './config/ui'
|
||||||
|
|
||||||
const isSidebarOpen = ref(window.innerWidth >= 768)
|
const isSidebarOpen = ref(window.innerWidth >= 768)
|
||||||
@@ -61,6 +62,7 @@ onUnmounted(() => {
|
|||||||
<Footer />
|
<Footer />
|
||||||
<InstallPrompt />
|
<InstallPrompt />
|
||||||
<ReloadPrompt />
|
<ReloadPrompt />
|
||||||
|
<GlobalTooltip />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ onMounted(() => {
|
|||||||
class="menu-btn"
|
class="menu-btn"
|
||||||
@click="$emit('toggleSidebar')"
|
@click="$emit('toggleSidebar')"
|
||||||
aria-label="Toggle Menu"
|
aria-label="Toggle Menu"
|
||||||
title="Toggle Menu"
|
v-tooltip="'Toggle Menu'"
|
||||||
v-ripple
|
v-ripple
|
||||||
>
|
>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
@@ -50,7 +50,7 @@ onMounted(() => {
|
|||||||
<button
|
<button
|
||||||
class="btn-neon nav-btn icon-only"
|
class="btn-neon nav-btn icon-only"
|
||||||
@click="toggleTheme"
|
@click="toggleTheme"
|
||||||
:title="isDark ? 'Switch to light mode' : 'Switch to dark mode'"
|
v-tooltip="isDark ? 'Switch to light mode' : 'Switch to dark mode'"
|
||||||
v-ripple
|
v-ripple
|
||||||
>
|
>
|
||||||
<Sun v-if="isDark" :size="20" />
|
<Sun v-if="isDark" :size="20" />
|
||||||
|
|||||||
138
src/components/common/GlobalTooltip.vue
Normal file
138
src/components/common/GlobalTooltip.vue
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
<script setup>
|
||||||
|
import { tooltipState } from '../../composables/useTooltip'
|
||||||
|
import { ref, watch, nextTick } from 'vue'
|
||||||
|
|
||||||
|
const tooltipRef = ref(null)
|
||||||
|
const x = ref(0)
|
||||||
|
const y = ref(0)
|
||||||
|
const arrowX = ref(0)
|
||||||
|
const isBottom = ref(false)
|
||||||
|
|
||||||
|
watch(() => tooltipState.isVisible, async (visible) => {
|
||||||
|
if (visible) {
|
||||||
|
// Wait for DOM update to ensure the text content affects height before measuring
|
||||||
|
await nextTick()
|
||||||
|
if (!tooltipRef.value || !tooltipState.targetRect) return
|
||||||
|
|
||||||
|
const rect = tooltipState.targetRect
|
||||||
|
const tooltipRect = tooltipRef.value.getBoundingClientRect()
|
||||||
|
|
||||||
|
let top = rect.top - tooltipRect.height - 8
|
||||||
|
let idealCenter = rect.left + (rect.width / 2)
|
||||||
|
let left = idealCenter - (tooltipRect.width / 2)
|
||||||
|
|
||||||
|
isBottom.value = false
|
||||||
|
if (top < 8) {
|
||||||
|
top = rect.bottom + 8
|
||||||
|
isBottom.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bounds checking for the tooltip box
|
||||||
|
let actualLeft = left
|
||||||
|
if (actualLeft < 8) {
|
||||||
|
actualLeft = 8
|
||||||
|
} else if (actualLeft + tooltipRect.width > window.innerWidth - 8) {
|
||||||
|
actualLeft = window.innerWidth - tooltipRect.width - 8
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the difference between where the box is forced to be,
|
||||||
|
// and where it naturally wanted to be. We move the arrow by the opposite amount.
|
||||||
|
arrowX.value = idealCenter - (actualLeft + (tooltipRect.width / 2))
|
||||||
|
|
||||||
|
x.value = actualLeft
|
||||||
|
y.value = top
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
ref="tooltipRef"
|
||||||
|
class="global-tooltip"
|
||||||
|
:class="{ 'visible': tooltipState.isVisible, 'tooltip-bottom': isBottom }"
|
||||||
|
:style="{
|
||||||
|
transform: `translate(${x}px, ${y}px)`,
|
||||||
|
'--arrow-offset': `${arrowX}px`
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ tooltipState.text }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.global-tooltip {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 99999;
|
||||||
|
background: rgba(15, 23, 42, 0.95);
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
-webkit-backdrop-filter: blur(8px);
|
||||||
|
color: #f8fafc;
|
||||||
|
padding: 6px 12px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: 500;
|
||||||
|
white-space: nowrap;
|
||||||
|
pointer-events: none;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
transform: translateY(4px) scale(0.95);
|
||||||
|
transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
||||||
|
opacity: 0;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.global-tooltip::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: calc(50% + var(--arrow-offset, 0px));
|
||||||
|
bottom: -5px;
|
||||||
|
margin-left: -5px;
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
background: rgba(15, 23, 42, 0.95);
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
-webkit-backdrop-filter: blur(8px);
|
||||||
|
border-right: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
transform: rotate(45deg);
|
||||||
|
border-radius: 0 0 2px 0;
|
||||||
|
clip-path: polygon(100% 0, 100% 100%, 0 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.global-tooltip.tooltip-bottom::after {
|
||||||
|
bottom: auto;
|
||||||
|
top: -5px;
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: none;
|
||||||
|
border-left: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
border-radius: 2px 0 0 0;
|
||||||
|
clip-path: polygon(0 0, 100% 0, 0 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.global-tooltip.visible {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
/* Transform returns to natural pos defined by inline styles when visible */
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-theme="light"] .global-tooltip {
|
||||||
|
background: rgba(255, 255, 255, 0.95);
|
||||||
|
color: #0f172a;
|
||||||
|
border-color: rgba(15, 23, 42, 0.1);
|
||||||
|
box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-theme="light"] .global-tooltip::after {
|
||||||
|
background: rgba(255, 255, 255, 0.95);
|
||||||
|
border-right-color: rgba(15, 23, 42, 0.1);
|
||||||
|
border-bottom-color: rgba(15, 23, 42, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-theme="light"] .global-tooltip.tooltip-bottom::after {
|
||||||
|
border-left-color: rgba(15, 23, 42, 0.1);
|
||||||
|
border-top-color: rgba(15, 23, 42, 0.1);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -62,7 +62,7 @@ const clearText = () => {
|
|||||||
class="btn-neon"
|
class="btn-neon"
|
||||||
@click="startListening"
|
@click="startListening"
|
||||||
:disabled="!isExtensionReady"
|
:disabled="!isExtensionReady"
|
||||||
:title="!isExtensionReady ? 'Extension required' : 'Start capturing clipboard'"
|
v-tooltip="!isExtensionReady ? 'Extension required' : 'Start capturing clipboard'"
|
||||||
v-ripple
|
v-ripple
|
||||||
>
|
>
|
||||||
Start Sniffing
|
Start Sniffing
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ const triggerDownload = (blob, filename) => {
|
|||||||
class="icon-btn edit-toggle-btn"
|
class="icon-btn edit-toggle-btn"
|
||||||
:class="{ 'active': showHandles }"
|
:class="{ 'active': showHandles }"
|
||||||
@click="showHandles = !showHandles"
|
@click="showHandles = !showHandles"
|
||||||
title="Toggle edit handles"
|
v-tooltip="'Toggle edit handles'"
|
||||||
>
|
>
|
||||||
<Eye v-if="showHandles" size="20" />
|
<Eye v-if="showHandles" size="20" />
|
||||||
<EyeOff v-else size="20" />
|
<EyeOff v-else size="20" />
|
||||||
@@ -370,11 +370,11 @@ const triggerDownload = (blob, filename) => {
|
|||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label>Size (px)</label>
|
<label>Size (px)</label>
|
||||||
<div class="number-control size-control">
|
<div class="number-control size-control">
|
||||||
<button class="control-btn" @click="size = Math.max(10, size - 100)" title="-100" v-ripple>-100</button>
|
<button class="control-btn" @click="size = Math.max(10, size - 100)" v-tooltip="'-100'" v-ripple>-100</button>
|
||||||
<button class="control-btn" @click="size = Math.max(10, size - 10)" title="-10" v-ripple>-10</button>
|
<button class="control-btn" @click="size = Math.max(10, size - 10)" v-tooltip="'-10'" v-ripple>-10</button>
|
||||||
<input type="number" v-model.number="size" class="number-input" />
|
<input type="number" v-model.number="size" class="number-input" />
|
||||||
<button class="control-btn" @click="size += 10" title="+10" v-ripple>+10</button>
|
<button class="control-btn" @click="size += 10" v-tooltip="'+10'" v-ripple>+10</button>
|
||||||
<button class="control-btn" @click="size += 100" title="+100" v-ripple>+100</button>
|
<button class="control-btn" @click="size += 100" v-tooltip="'+100'" v-ripple>+100</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ const isUrl = (string) => {
|
|||||||
v-if="hasMultipleCameras"
|
v-if="hasMultipleCameras"
|
||||||
class="switch-camera-btn"
|
class="switch-camera-btn"
|
||||||
@click.stop="switchCamera"
|
@click.stop="switchCamera"
|
||||||
title="Switch Camera"
|
v-tooltip="'Switch Camera'"
|
||||||
v-ripple
|
v-ripple
|
||||||
>
|
>
|
||||||
<SwitchCamera size="24" />
|
<SwitchCamera size="24" />
|
||||||
@@ -333,13 +333,13 @@ const isUrl = (string) => {
|
|||||||
<div class="results-header">
|
<div class="results-header">
|
||||||
<h3>Scanned Codes ({{ scannedCodes.length }})</h3>
|
<h3>Scanned Codes ({{ scannedCodes.length }})</h3>
|
||||||
<div v-if="scannedCodes.length > 0" class="header-actions">
|
<div v-if="scannedCodes.length > 0" class="header-actions">
|
||||||
<button class="icon-btn" @click="copyAll" title="Copy All" v-ripple>
|
<button class="icon-btn" @click="copyAll" v-tooltip="'Copy All'" v-ripple>
|
||||||
<Copy size="18" />
|
<Copy size="18" />
|
||||||
</button>
|
</button>
|
||||||
<button class="icon-btn" @click="downloadJson" title="Download JSON" v-ripple>
|
<button class="icon-btn" @click="downloadJson" v-tooltip="'Download JSON'" v-ripple>
|
||||||
<Download size="18" />
|
<Download size="18" />
|
||||||
</button>
|
</button>
|
||||||
<button class="icon-btn delete-btn" @click="clearHistory" title="Clear All" v-ripple>
|
<button class="icon-btn delete-btn" @click="clearHistory" v-tooltip="'Clear All'" v-ripple>
|
||||||
<Trash2 size="18" />
|
<Trash2 size="18" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -358,13 +358,13 @@ const isUrl = (string) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="item-actions">
|
<div class="item-actions">
|
||||||
<button class="icon-btn" @click="copyToClipboard(code.value)" title="Copy" v-ripple>
|
<button class="icon-btn" @click="copyToClipboard(code.value)" v-tooltip="'Copy'" v-ripple>
|
||||||
<Copy size="18" />
|
<Copy size="18" />
|
||||||
</button>
|
</button>
|
||||||
<button class="icon-btn" @click="navigateToGenerateQr(code.value)" title="Generate QR Code" v-ripple>
|
<button class="icon-btn" @click="navigateToGenerateQr(code.value)" v-tooltip="'Generate QR Code'" v-ripple>
|
||||||
<QrCode size="18" />
|
<QrCode size="18" />
|
||||||
</button>
|
</button>
|
||||||
<button class="icon-btn delete-btn" @click="removeCode(code.id)" title="Remove" v-ripple>
|
<button class="icon-btn delete-btn" @click="removeCode(code.id)" v-tooltip="'Remove'" v-ripple>
|
||||||
<Trash2 size="18" />
|
<Trash2 size="18" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ onUnmounted(() => {
|
|||||||
<div class="panel-header">
|
<div class="panel-header">
|
||||||
<h2 class="tool-title">URL Cleaner</h2>
|
<h2 class="tool-title">URL Cleaner</h2>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<button class="icon-btn settings-btn" @click="showExceptionsModal = true" title="Cleaning Exceptions" v-ripple>
|
<button class="icon-btn settings-btn" @click="showExceptionsModal = true" v-tooltip="'Cleaning Exceptions'" v-ripple>
|
||||||
<Settings size="20" />
|
<Settings size="20" />
|
||||||
</button>
|
</button>
|
||||||
<ExtensionStatus :isReady="isExtensionReady" />
|
<ExtensionStatus :isReady="isExtensionReady" />
|
||||||
@@ -137,7 +137,7 @@ onUnmounted(() => {
|
|||||||
:class="{ 'active': isWatchEnabled && isExtensionReady }"
|
:class="{ 'active': isWatchEnabled && isExtensionReady }"
|
||||||
@click="toggleWatch"
|
@click="toggleWatch"
|
||||||
:disabled="!isExtensionReady"
|
:disabled="!isExtensionReady"
|
||||||
:title="!isExtensionReady ? 'Extension required for auto-watch' : 'Automatically clean URLs from clipboard'"
|
v-tooltip="!isExtensionReady ? 'Extension required for auto-watch' : 'Automatically clean URLs from clipboard'"
|
||||||
v-ripple
|
v-ripple
|
||||||
>
|
>
|
||||||
<Power size="18" />
|
<Power size="18" />
|
||||||
@@ -151,13 +151,13 @@ onUnmounted(() => {
|
|||||||
<div class="history-header">
|
<div class="history-header">
|
||||||
<h3>Cleaned URLs ({{ cleanedHistory.length }})</h3>
|
<h3>Cleaned URLs ({{ cleanedHistory.length }})</h3>
|
||||||
<div class="history-actions">
|
<div class="history-actions">
|
||||||
<button class="icon-btn" @click="copyAllUrls" title="Copy all URLs" v-ripple>
|
<button class="icon-btn" @click="copyAllUrls" v-tooltip="'Copy all URLs'" v-ripple>
|
||||||
<Copy size="18" />
|
<Copy size="18" />
|
||||||
</button>
|
</button>
|
||||||
<button class="icon-btn" @click="downloadJson" title="Download JSON" v-ripple>
|
<button class="icon-btn" @click="downloadJson" v-tooltip="'Download JSON'" v-ripple>
|
||||||
<Download size="18" />
|
<Download size="18" />
|
||||||
</button>
|
</button>
|
||||||
<button class="icon-btn delete-btn" @click="clearHistory" title="Clear History" v-ripple>
|
<button class="icon-btn delete-btn" @click="clearHistory" v-tooltip="'Clear History'" v-ripple>
|
||||||
<Trash2 size="18" />
|
<Trash2 size="18" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -176,13 +176,13 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="item-actions">
|
<div class="item-actions">
|
||||||
<button class="icon-btn" @click="copyToClipboard(item.cleaned)" title="Copy" v-ripple>
|
<button class="icon-btn" @click="copyToClipboard(item.cleaned)" v-tooltip="'Copy'" v-ripple>
|
||||||
<Copy size="18" />
|
<Copy size="16" />
|
||||||
</button>
|
</button>
|
||||||
<a :href="item.cleaned" target="_blank" class="icon-btn" title="Open">
|
<a :href="item.cleaned" target="_blank" class="icon-btn" v-tooltip="'Open'" v-ripple>
|
||||||
<ExternalLink size="18" />
|
<ExternalLink size="16" />
|
||||||
</a>
|
</a>
|
||||||
<button class="icon-btn delete-btn" @click="removeEntry(item.id)" title="Remove" v-ripple>
|
<button class="icon-btn delete-btn" @click="removeEntry(item.id)" v-tooltip="'Remove'" v-ripple>
|
||||||
<X size="18" />
|
<X size="18" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -268,13 +268,13 @@ const resetToDefault = (ruleId) => {
|
|||||||
|
|
||||||
<div v-for="rule in localExceptions" :key="rule.id" class="rule-item" :class="{ disabled: !rule.isEnabled }">
|
<div v-for="rule in localExceptions" :key="rule.id" class="rule-item" :class="{ disabled: !rule.isEnabled }">
|
||||||
<div class="rule-info">
|
<div class="rule-info">
|
||||||
<div class="rule-domain" @click="editRule(rule)" title="Click to edit">{{ rule.domainPattern }}</div>
|
<div class="rule-domain" @click="editRule(rule)" v-tooltip="'Click to edit'">{{ rule.domainPattern }}</div>
|
||||||
<div class="rule-details">
|
<div class="rule-details">
|
||||||
<div class="params-list">
|
<div class="params-list">
|
||||||
<template v-if="rule.keepAllParams">
|
<template v-if="rule.keepAllParams">
|
||||||
<span class="detail-tag">
|
<span class="detail-tag">
|
||||||
Keep all params
|
Keep all params
|
||||||
<button class="remove-param-btn" @click.stop="toggleKeepAllParams(rule.id)" title="Disable keep all params">
|
<button class="remove-param-btn" @click.stop="toggleKeepAllParams(rule.id)" v-tooltip="'Disable keep all params'">
|
||||||
<X size="12" />
|
<X size="12" />
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
@@ -282,14 +282,14 @@ const resetToDefault = (ruleId) => {
|
|||||||
<template v-else>
|
<template v-else>
|
||||||
<span v-for="param in rule.keepParams" :key="param" class="detail-tag">
|
<span v-for="param in rule.keepParams" :key="param" class="detail-tag">
|
||||||
{{ param }}
|
{{ param }}
|
||||||
<button class="remove-param-btn" @click.stop="removeParam(rule.id, param)" title="Remove parameter">
|
<button class="remove-param-btn" @click.stop="removeParam(rule.id, param)" v-tooltip="'Remove parameter'">
|
||||||
<X size="12" />
|
<X size="12" />
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<span v-if="rule.keepHash" class="detail-tag hash-tag">
|
<span v-if="rule.keepHash" class="detail-tag hash-tag">
|
||||||
Keep #
|
Keep #
|
||||||
<button class="remove-param-btn" @click.stop="toggleKeepHash(rule.id)" title="Remove hash exception">
|
<button class="remove-param-btn" @click.stop="toggleKeepHash(rule.id)" v-tooltip="'Remove hash exception'">
|
||||||
<X size="12" />
|
<X size="12" />
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
@@ -302,7 +302,7 @@ const resetToDefault = (ruleId) => {
|
|||||||
<button
|
<button
|
||||||
class="icon-btn"
|
class="icon-btn"
|
||||||
@click="toggleRule(rule.id)"
|
@click="toggleRule(rule.id)"
|
||||||
:title="rule.isEnabled ? 'Disable rule' : 'Enable rule'"
|
v-tooltip="rule.isEnabled ? 'Disable rule' : 'Enable rule'"
|
||||||
v-ripple
|
v-ripple
|
||||||
>
|
>
|
||||||
<div class="toggle-switch" :class="{ active: rule.isEnabled }"></div>
|
<div class="toggle-switch" :class="{ active: rule.isEnabled }"></div>
|
||||||
@@ -312,12 +312,12 @@ const resetToDefault = (ruleId) => {
|
|||||||
v-if="!rule.isDefault"
|
v-if="!rule.isDefault"
|
||||||
class="icon-btn delete-btn"
|
class="icon-btn delete-btn"
|
||||||
@click="removeRule(rule.id)"
|
@click="removeRule(rule.id)"
|
||||||
title="Remove rule"
|
v-tooltip="'Remove rule'"
|
||||||
v-ripple
|
v-ripple
|
||||||
>
|
>
|
||||||
<Trash2 size="18" />
|
<Trash2 size="18" />
|
||||||
</button>
|
</button>
|
||||||
<button v-else class="btn-neon small default-reset" @click="resetToDefault(rule.id)" title="Restore default rule" v-ripple>
|
<button v-else class="btn-neon small default-reset" @click="resetToDefault(rule.id)" v-tooltip="'Restore default rule'" v-ripple>
|
||||||
<RotateCcw size="16" /> Default
|
<RotateCcw size="16" /> Default
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ onUnmounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="extension-status" v-bind="$attrs" :class="{ 'is-ready': isReady }" @click="showModal = true" :title="isReady ? 'Extension Connected' : 'Extension Not Connected'">
|
<div class="extension-status" v-bind="$attrs" :class="{ 'is-ready': isReady }" @click="showModal = true" v-tooltip="isReady ? 'Extension Connected' : 'Extension Not Connected'">
|
||||||
<Plug v-if="isReady" size="18" />
|
<Plug v-if="isReady" size="18" />
|
||||||
<Plus v-else size="18" />
|
<Plus v-else size="18" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
34
src/composables/useTooltip.js
Normal file
34
src/composables/useTooltip.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { reactive } from 'vue'
|
||||||
|
|
||||||
|
export const tooltipState = reactive({
|
||||||
|
isVisible: false,
|
||||||
|
text: '',
|
||||||
|
targetRect: null
|
||||||
|
})
|
||||||
|
|
||||||
|
export function showTooltip(el, text) {
|
||||||
|
if (!text) return;
|
||||||
|
|
||||||
|
if (!el.hasAttribute('aria-label')) {
|
||||||
|
el.setAttribute('aria-label', text);
|
||||||
|
}
|
||||||
|
|
||||||
|
const rect = el.getBoundingClientRect();
|
||||||
|
tooltipState.targetRect = {
|
||||||
|
top: rect.top,
|
||||||
|
left: rect.left,
|
||||||
|
width: rect.width,
|
||||||
|
bottom: rect.bottom
|
||||||
|
};
|
||||||
|
tooltipState.text = text;
|
||||||
|
tooltipState.isVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide tooltip on any scroll event to avoid floating detached tooltips
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
window.addEventListener('scroll', hideTooltip, { passive: true, capture: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hideTooltip() {
|
||||||
|
tooltipState.isVisible = false;
|
||||||
|
}
|
||||||
28
src/directives/tooltip.js
Normal file
28
src/directives/tooltip.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { showTooltip, hideTooltip, tooltipState } from '../composables/useTooltip'
|
||||||
|
|
||||||
|
export const tooltipDirective = {
|
||||||
|
mounted(el, binding) {
|
||||||
|
el._tooltipText = binding.value;
|
||||||
|
|
||||||
|
el.addEventListener('mouseenter', () => showTooltip(el, el._tooltipText));
|
||||||
|
el.addEventListener('mouseleave', hideTooltip);
|
||||||
|
el.addEventListener('focus', () => showTooltip(el, el._tooltipText));
|
||||||
|
el.addEventListener('blur', hideTooltip);
|
||||||
|
},
|
||||||
|
updated(el, binding) {
|
||||||
|
el._tooltipText = binding.value;
|
||||||
|
|
||||||
|
if (tooltipState.isVisible && tooltipState.text !== binding.value) {
|
||||||
|
if (el.matches(':hover') || document.activeElement === el) {
|
||||||
|
showTooltip(el, binding.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unmounted(el) {
|
||||||
|
el.removeEventListener('mouseenter', () => showTooltip(el, el._tooltipText));
|
||||||
|
el.removeEventListener('mouseleave', hideTooltip);
|
||||||
|
el.removeEventListener('focus', () => showTooltip(el, el._tooltipText));
|
||||||
|
el.removeEventListener('blur', hideTooltip);
|
||||||
|
hideTooltip();
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -3,6 +3,7 @@ import './style.css'
|
|||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
import Ripple from './directives/ripple'
|
import Ripple from './directives/ripple'
|
||||||
|
import { tooltipDirective } from './directives/tooltip'
|
||||||
import { BarcodeDetector, prepareZXingModule } from 'barcode-detector/ponyfill'
|
import { BarcodeDetector, prepareZXingModule } from 'barcode-detector/ponyfill'
|
||||||
|
|
||||||
// Configure BarcodeDetector polyfill to use local WASM file
|
// Configure BarcodeDetector polyfill to use local WASM file
|
||||||
@@ -28,5 +29,6 @@ try {
|
|||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
app.directive('ripple', Ripple)
|
app.directive('ripple', Ripple)
|
||||||
|
app.directive('tooltip', tooltipDirective)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
Reference in New Issue
Block a user