2024-05-13 03:08:26 -05:00
|
|
|
import { useEffect } from 'react';
|
|
|
|
import useResizeObserver from 'use-resize-observer';
|
|
|
|
|
2024-05-09 05:56:45 -05:00
|
|
|
import Penpot from '@ui/assets/penpot.svg?react';
|
2024-05-03 06:43:07 -05:00
|
|
|
import { PenpotExporter } from '@ui/components/PenpotExporter';
|
2024-05-09 05:56:45 -05:00
|
|
|
import { Stack } from '@ui/components/Stack';
|
2024-05-13 03:12:58 -05:00
|
|
|
import { Wrapper } from '@ui/components/Wrapper';
|
2024-05-03 06:43:07 -05:00
|
|
|
|
2024-05-13 03:08:26 -05:00
|
|
|
// Safe default value to avoid overflowing from the screen
|
|
|
|
const MAX_HEIGHT = 800;
|
|
|
|
|
|
|
|
export const App = () => {
|
|
|
|
const { ref, height } = useResizeObserver<HTMLDivElement>({ box: 'border-box' });
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (height === undefined) return;
|
|
|
|
|
|
|
|
const capHeight = Math.min(height, MAX_HEIGHT);
|
|
|
|
|
|
|
|
parent.postMessage({ pluginMessage: { type: 'resize', height: capHeight } }, '*');
|
|
|
|
}, [height]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Wrapper ref={ref} overflowing={(height ?? 0) > MAX_HEIGHT}>
|
2024-05-31 04:25:32 -05:00
|
|
|
<Stack>
|
2024-05-13 03:08:26 -05:00
|
|
|
<Penpot
|
|
|
|
style={{
|
|
|
|
alignSelf: 'center',
|
|
|
|
height: 'auto',
|
|
|
|
width: '8.125rem',
|
|
|
|
fill: 'var(--figma-color-icon)'
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<PenpotExporter />
|
|
|
|
</Stack>
|
|
|
|
</Wrapper>
|
|
|
|
);
|
|
|
|
};
|