Git Product home page Git Product logo

form-editor's Introduction

Form Builder With Svelte & Tailwindcss

NoCode Customizable Form Editor

Demo

Demo Form Builder

Screenshots

Form Builder Fouita

Form builder Fouita

Form builder Fouita

Features

  • Customize text and inputs (WYSIWYG)
  • Multi Steps Forms
  • Customize colors
  • RTL support
  • Add images and videos by inserting a link inside the text
  • Form Schema is exported so you can manipulate the data yourself
  • Form data is dispatched when user click on the Submit of the last step

Install

npm i @fouita/form-editor

How to use

Inside your svelte app

<script>
  import FormEditor from "@fouita/form-editor"

  // you can create a button to toggle the editable variable
  let editable = true

  // initial form schema needed
  let form =  {
    "name": "My Form",
    "version": "1",
    "steps": [{
        "index": 0,
        "props": {
            "previousBtn": "Back",
            "nextBtn": "Next"
        },
        "inputs": [
            
        ]
    }]
  }

  const settings = {
	  textColor: "250 250 250",
	  bgColor: "0 0 0",
	  outlineColor: "165 180 252",
	  buttonBgColor: "79 70 229",
	  buttonTextColor: "255 255 255",
	  borderColor: "200 200 200",
	  form: form,
	  rounded: "rounded-none",
	  size: "full",
	  rtl: false,
	  transparent: false,
	  btnsPosition: "start", // start, end, center
  }

  // get updated data
  $: if(form) {
    // form is updated
  }

  function handleSubmit(evt) {
    // send data to your server
  }
</script>

<FormEditor bind:form {editable} {...settings} on:submit={handleSubmit} />

Generate CSS

To be able to see the styled Editor, you can either use form-editor.css in your index.html or you can build the CSS using tailwind

  1. Copy the file tailwind.config.js
  2. Generate a seperate CSS for the Form Editor using the following command in your project
npx tailwindcss -i ./src/global.css -o ./public/form-editor.css --minify

( change global.css to your css file that includes @tailwind)

gloabl.css

@tailwind base;
@tailwind components;
@tailwind utilities;

Include the file in your HTML index file

<link rel="stylesheet" href="/form-editor.css" />

Use it as widget

You can use the form-editor in your project as an external widget, with backend data collection at Fouita for Free

form-editor's People

Contributors

haynajjar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

form-editor's Issues

Unknown file extension ".svelte" error

I keep getting this error:

error

All I did was use the example code on a test sveltekit route:

<script>
  import FormEditor from "@fouita/form-editor"
  // you can create a button to toggle the editable variable
  let editable = true
  // initial form schema needed
  let form =  {
    "name": "My Form",
    "version": "1",
    "steps": [{
        "index": 0,
        "props": {
            "previousBtn": "Back",
            "nextBtn": "Next"
        },
        "inputs": [    
        ]
    }]
  }
  const settings = {
	  textColor: "250 250 250",
	  bgColor: "0 0 0",
	  outlineColor: "165 180 252",
	  buttonBgColor: "79 70 229",
	  buttonTextColor: "255 255 255",
	  borderColor: "200 200 200",
	  form: form,
	  rounded: "rounded-none",
	  size: "full",
	  rtl: false,
	  transparent: false,
	  btnsPosition: "start", // start, end, center
  }
  // get updated data
  $: if(form) {
    // form is updated
  }
  function handleSubmit(evt) {
    // send data to your server
  }
</script>
<FormEditor bind:form {editable} {...settings} on:submit={handleSubmit} />

Help will be greatly appreciated.

Full error:

|- TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for C:\Users\user\Documents\Github\SvelteKit\Goremote Africa\main\node_modules\@fouita\form-editor\src\App.svelte
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:143:22)
    at async ModuleLoader.load (node:internal/modules/esm/loader:403:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:45)
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for C:\Users\user\Documents\Github\SvelteKit\Goremote Africa\main\node_modules\@fouita\form-editor\src\App.svelte
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:143:22)
    at async ModuleLoader.load (node:internal/modules/esm/loader:403:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:45)

local install fails

I tried both with plain svelte and your template:

[plugin:vite:import-analysis] Failed to resolve import "../ui/InputTypes/CheckBox.svelte" from "node_modules/@fouita/form-editor/src/lib/utils/cmpsRegistry.js". Does the file exist?

/home/pm/Documents/github/svelte_fouita/node_modules/@fouita/form-editor/src/lib/utils/cmpsRegistry.js:7:23

5  |  import Textarea from "../ui/InputTypes/Textarea.svelte";
6  |  import Submit from "../ui/InputTypes/Submit.svelte";
7  |  import Checkbox from "../ui/InputTypes/CheckBox.svelte";
   |                        ^
8  |  import Password from "../ui/InputTypes/Password.svelte";
9  |  import Date from "../ui/InputTypes/Date.svelte";

    at formatError (/home/pm/Documents/github/svelte_fouita/node_modules/vite/dist/node/chunks/dep-689425f3.js:39080:46)
    at TransformContext.error (/home/pm/Documents/github/svelte_fouita/node_modules/vite/dist/node/chunks/dep-689425f3.js:39076:19)
    at normalizeUrl (/home/pm/Documents/github/svelte_fouita/node_modules/vite/dist/node/chunks/dep-689425f3.js:58360:26)
    at async TransformContext.transform (/home/pm/Documents/github/svelte_fouita/node_modules/vite/dist/node/chunks/dep-689425f3.js:58509:57)
    at async Object.transform (/home/pm/Documents/github/svelte_fouita/node_modules/vite/dist/node/chunks/dep-689425f3.js:39317:30)
    at async doTransform (/home/pm/Documents/github/svelte_fouita/node_modules/vite/dist/node/chunks/dep-689425f3.js:50043:29

Indeed, it should be Checkbox.svelte, not CheckBox

But then, I get a weird result on both Chromium and FF:
image

Bonne journée

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.