Create injectable, configurable and extendable forms.
Demo on: https://tuur29.github.io/surveytool/
Load the production script file inside your own website and create an empty div.
Next, either initialize the tool in said div with new SurveyTool(cssSelector, {...}) with the same config object at a later date to initialize the tool:
<script src="[...]/surveytool-1.0.0.min.js"></script>
<div id="surveyTool"></div>
<script>
const config = {...};
const tool = new SurveyTool("#surveyTool", config);
// or async (for example on button click):
document.querySelector("#button").addEventListener("click", () => {
tool.resetAnswers();
tool.updateConfig(config);
});
</script>- Check out the Storybook
- The example configuration used in the demo can be found here: mockConfig.ts
- Install packages (
yarn installornpm install) - Start project (
yarn start/npm run start) - Open http://localhost:3000 to view it in the browser.
Tip: to circumvent TS compile errors during development you can add this to a .env file in the root folder:
TSC_COMPILE_ON_ERROR=trueyarn run test:typingwill run a typescript check across the codeyarn run test:unitwill run unit tests with jestyarn run test:lintwill run a linting check across the code
You can also view a hosted version of the storybook: https://tuur29.github.io/surveytool/docs
yarn run docs:startwill start a locally running storybookyarn run docs:buildwill build a static version of the storybook
yarn buildbuilds the app for production to thebuildfolder.- Bundle the output with
./scripts/bundle_build.sh, this will give you a singlebuild/dist/surveytool.min.jsyou can upload and use.
Demo:
- To update the demo page run
./scripts/deploy_demo.sh.
This tool was created with: