import React from 'react';
import {
Button,
FramerPlugin,
SegmentedControls,
TextControls,
useStore,
Spinner,
} from '@triozer/framer-toolbox';
type Resizable = 'both' | 'width' | 'height' | 'none';
export function App() {
const { store, setStoreValue, isStoreLoaded } = useStore<{
autoResize: boolean;
resizable: Resizable;
text: string;
}>('my-plugin-store', {
autoResize: false,
resizable: 'both',
text: 'Framer Toolbox',
});
const { autoResize, resizable, text } = store;
if (!isStoreLoaded) return <Spinner />;
return (
<FramerPlugin
autoResize={autoResize}
uiOptions={{
resizable: resizable === 'both' ? true : resizable === 'none' ? false : resizable,
}}
>
<SegmentedControls
title="Auto Resize"
value={autoResize}
items={[
{ label: 'Enabled', value: true },
{ label: 'Disabled', value: false },
]}
onChange={(value) => setStoreValue('autoResize', value)}
/>
<SegmentedControls
title="Resizable"
value={resizable}
items={[
{ label: 'Both', value: 'both' },
{ label: 'Width', value: 'width' },
{ label: 'Height', value: 'height' },
{ label: 'None', value: 'none' },
]}
onChange={(value) => setStoreValue('resizable', value as Resizable)}
/>
<TextControls
title="Text Controls"
placeholder="Type something..."
value={text}
onChange={(value) => setStoreValue('text', value)}
/>
<Button variant="primary">Click Me</Button>
</FramerPlugin>
);
}