fix: drag works from first attempt + size in window header
- ui.tsx: pass min/max opts to useWindowResize (fixes first-drag bug)
- ui.tsx: move live size to top toolbar (left of expand button)
- main.ts: set figma window title with startup size via showUI({title})
This commit is contained in:
1 parent
3bff4241d6
commit
26d391f90a
2 files changed
+11
-7
No files matched your search
+1
-1
@@ -10,5 +10,5 @@ export default function () {
|
||||
figma.ui.resize(width, height)
|
||||
})
|
||||
|
||||
showUI({ width: 320, height: 200, themeColors: true })
|
||||
showUI({ width: 320, height: 200, themeColors: true, title: 'AI assistant (MVP) — 320×200' })
|
||||
}
|
||||
+10
-6
@@ -19,10 +19,17 @@ const MAX_WINDOW_SIZE = { width: 800, height: 800 }
|
||||
function Plugin () {
|
||||
const [currentWindowSize, setCurrentWindowSize] = useState(MIN_WINDOW_SIZE)
|
||||
|
||||
// Нативный drag-ресайз окна Figma (тянуть за правый нижний угол)
|
||||
// Нативный drag-ресайз окна Figma (тянуть за правый нижний угол).
|
||||
// Опции min/max обязательны: без них хук берёт базу из window.innerWidth на момент
|
||||
// маунта (окно ещё не приняло размер от showUI) → первый drag не работает.
|
||||
useWindowResize(function (windowSize: { width: number; height: number }) {
|
||||
setCurrentWindowSize(windowSize)
|
||||
emit('RESIZE_WINDOW', windowSize)
|
||||
}, {
|
||||
minWidth: 320,
|
||||
minHeight: 200,
|
||||
maxWidth: 800,
|
||||
maxHeight: 800
|
||||
})
|
||||
|
||||
function toggleWindowSize () {
|
||||
@@ -41,7 +48,8 @@ function Plugin () {
|
||||
return (
|
||||
<Fragment>
|
||||
<Container space="medium" style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<Muted>{currentWindowSize.width} × {currentWindowSize.height}</Muted>
|
||||
<IconButton
|
||||
title={isMaximized ? 'Свернуть окно' : 'Развернуть окно'}
|
||||
onClick={toggleWindowSize}
|
||||
@@ -61,10 +69,6 @@ function Plugin () {
|
||||
<Text style={{ fontSize: '13px', fontWeight: 600 }}>Hello, Figma ✦</Text>
|
||||
<VerticalSpace space="small" />
|
||||
<Muted>AI assistant (MVP) — bootstrap</Muted>
|
||||
<VerticalSpace space="small" />
|
||||
<Muted>
|
||||
{currentWindowSize.width} × {currentWindowSize.height}
|
||||
</Muted>
|
||||
</div>
|
||||
</Container>
|
||||
{/* Декоративная иконка drag-хендла в правом нижнем углу (как в старом плагине).
|
||||
|
||||
Reference in new issue
Block a user