Create A Widget
Start from a small view tree, then add data, panels, timelines, and intents only when needed.
Steps
- Create or open an Await widget project.
- Keep
package.jsonandtsconfig.jsonat the package root, with each Await widget in its own subdirectory. This makes it easier to manage multiple Await widget subprojects in one package:
text
MyAwaitWidgets/
package.json
tsconfig.json
YourWidget/
index.tsx- Ensure
package.jsonincludes@await-widget/runtimeandtypescript. - Ensure
tsconfig.jsonuses:
json
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "await",
"types": ["@await-widget/runtime"]
}
}- Import components from
await. - Implement
widget. - Register it with
Await.define. - Run
npm test. - Run
npx await-widgetfrom the widget folder and connect the matching Await detail page when you want live preview.
Starter Template
tsx
import {Text, VStack} from 'await';
// @panel {type:'color'}
const accent = 'blue';
function widget() {
return (
<VStack spacing={8} maxSides padding={16} background='background'>
<Text value='Await' fontSize={18} fontWeight='semibold'/>
<Text value='Small things, close at hand' foreground={accent} minimumScaleFactor={0.7}/>
</VStack>
);
}
Await.define({
widget,
});