Skip to content

Commit 352f82d

Browse files
committed
feat: enhance panel visual hint logic
1 parent 926fd18 commit 352f82d

File tree

3 files changed

+70
-8
lines changed

3 files changed

+70
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.14.5
4+
5+
- Only show the panel visual hint when the panel significantly overlaps with Figma's own panels.
6+
37
## 0.14.4
48

59
- Improved MCP tool output.

packages/extension/entrypoints/ui/App.vue

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,49 @@ const mcpBadgeActiveClass = computed(() =>
8585
isMcpConnected.value ? (selfActive.value ? 'tp-mcp-badge-active' : 'tp-mcp-badge-inactive') : null
8686
)
8787
88-
const showHint = ref(true)
88+
const lowVisibility = ref(false)
8989
const initialLock = ref(true)
9090
const { idle } = useIdle(HINT_IDLE_MS, {
9191
initialState: true
9292
})
9393
94-
watch(idle, (isIdle) => {
95-
showHint.value = isIdle || initialLock.value
96-
})
94+
function getOverlapWidth(a: DOMRect, b: DOMRect) {
95+
return Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left))
96+
}
97+
98+
function updateHintOverlap() {
99+
if (!layoutReady.value) {
100+
lowVisibility.value = false
101+
return
102+
}
103+
104+
const canvas = getCanvas()
105+
const panel = document.querySelector('.tp-panel.tp-main') as HTMLElement | null
106+
if (!canvas || !panel) {
107+
lowVisibility.value = false
108+
return
109+
}
110+
111+
const panelRect = panel.getBoundingClientRect()
112+
const canvasRect = canvas.getBoundingClientRect()
113+
const overlapWidth = getOverlapWidth(panelRect, canvasRect)
114+
115+
if (panelRect.width <= 0) {
116+
lowVisibility.value = false
117+
return
118+
}
119+
120+
lowVisibility.value = overlapWidth < panelRect.width / 3
121+
}
122+
123+
useIntervalFn(updateHintOverlap, LAYOUT_CHECK_INTERVAL, { immediate: true })
97124
98125
useTimeoutFn(() => {
99126
initialLock.value = false
100-
showHint.value = idle.value
101127
}, 3000)
102128
129+
const showHint = computed(() => (idle.value || initialLock.value) && lowVisibility.value)
130+
103131
watch(layoutReady, (ready) => {
104132
if (ready) {
105133
syncSelection()
@@ -176,7 +204,7 @@ function activateMcp() {
176204
}
177205
178206
.tp-main-hint {
179-
animation: tp-main-hint-pulse 2s cubic-bezier(0.87, 0, 0.13, 1) infinite;
207+
animation: tp-main-hint-pulse 10s cubic-bezier(0.87, 0, 0.13, 1) infinite;
180208
}
181209
182210
.tp-main.tp-panel-dragging,
@@ -220,8 +248,38 @@ function activateMcp() {
220248
}
221249
222250
@keyframes tp-main-hint-pulse {
251+
0%,
252+
20%,
253+
40%,
254+
60%,
255+
80%,
256+
100% {
257+
box-shadow: var(--elevation-100);
258+
}
259+
10% {
260+
box-shadow:
261+
var(--elevation-100),
262+
0 0 0 2px #f24e1e;
263+
}
264+
30% {
265+
box-shadow:
266+
var(--elevation-100),
267+
0 0 0 2px #ff7262;
268+
}
223269
50% {
224-
box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-text) 40%, var(--color-bg) 20%);
270+
box-shadow:
271+
var(--elevation-100),
272+
0 0 0 2px #a259ff;
273+
}
274+
70% {
275+
box-shadow:
276+
var(--elevation-100),
277+
0 0 0 2px #1abcfe;
278+
}
279+
90% {
280+
box-shadow:
281+
var(--elevation-100),
282+
0 0 0 2px #0acf83;
225283
}
226284
}
227285

packages/extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tempad-dev/extension",
3-
"version": "0.14.4",
3+
"version": "0.14.5",
44
"private": true,
55
"description": "TemPad Dev browser extension.",
66
"type": "module",

0 commit comments

Comments
 (0)