Add headless-demo plugin and its usage example

Summary:
Next steps:
1. Refactor it TS for consistency
2. Remove it in favor of tic-tac-toe integration

Reviewed By: mweststrate

Differential Revision: D36102002

fbshipit-source-id: 7dc930f67bed636159a2ec433d7405ab6ee09f97
This commit is contained in:
Andrey Goncharov
2022-05-10 05:13:24 -07:00
committed by Facebook GitHub Bot
parent b4498f070f
commit 7b31a1c6b6
6 changed files with 221 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import React from 'react';
import {createState, Layout, FlipperPluginInstance} from 'flipper-plugin';
export function API(
pluginInstance: FlipperPluginInstance<typeof devicePlugin>,
) {
return {
increment: pluginInstance.increment,
};
}
export function devicePlugin() {
const data = createState(0);
const increment = (step: number = 1) => {
const newVal = data.get() + step;
data.set(newVal);
return newVal;
};
return {increment};
}
export function Component() {
return (
<Layout.ScrollContainer>
I am a new shiny headless plugin
</Layout.ScrollContainer>
);
}

View File

@@ -0,0 +1,30 @@
{
"$schema": "https://fbflipper.com/schemas/plugin-package/v2.json",
"name": "flipper-plugin-headless-demo",
"id": "headless-demo",
"pluginType": "device",
"version": "0.0.0",
"flipperBundlerEntry": "index.tsx",
"headless": true,
"main": "dist/bundle.js",
"license": "MIT",
"title": "Headless-demo",
"icon": "apps",
"keywords": [
"flipper-plugin"
],
"bugs": {
"url": "https://github.com/facebook/flipper/issues"
},
"peerDependencies": {
"flipper-plugin": "*",
"antd": "*",
"react": "*",
"react-dom": "*",
"@emotion/styled": "*",
"@ant-design/icons": "*",
"@types/react": "*",
"@types/react-dom": "*",
"@types/node": "*"
}
}