2.3.0 • Published 2 months ago

@tsed/tailwind-formio v2.3.0

Weekly downloads
-
License
-
Repository
github
Last release
2 months ago

Build & Release semantic-release code style: prettier backers

This repository will change the rendering of forms in formio.js so that it uses html and classes compatible with the Semantic UI framework.

Install

npm install @tsed/tailwind-formio --save
npm install --save-dev postcss-nested@4

Tailwind and create-react-app

If you use create-react-app, you'll need to follow the official tailwind guide installation here: https://tailwindcss.com/docs/guides/create-react-app

Configure postcss

Edit the craco.config.js (or postcss.config.js) and add the postcss-nested to the postcss plugins list:

module.exports = {
  style: {
    postcss: {
      plugins: [
        require('tailwindcss'),
+       require('postcss-nested')
        require('autoprefixer')
      ]
    }
  }
}

Or:

export default {
  plugins: {
    'tailwindcss/nesting': {},
    tailwindcss: {},
    autoprefixer: {},
  },
}

Configure tailwind

Generate the initial tailwind.config.js with the following command:

npx tailwindcss-cli@latest init

Edit the tailwind.config.js and copy the following content:

const primary = "hsla(208, 100%, 43%, 1)";
const secondary = "hsla(190, 81%, 42%, 1)";

module.exports = {
  purge: [],
  darkMode: false, // or 'media' or 'class'
  theme: {
    extend: {
      colors: {
        primary: {
          DEFAULT: primary,
          50: "hsla(208, 100%, 91%, 1)",
          100: "hsla(208, 100%, 83%, 1)",
          200: "hsla(208, 100%, 75%, 1)",
          300: "hsla(208, 100%, 67%, 1)",
          400: "hsla(208, 100%, 59%, 1)",
          500: "hsla(208, 100%, 51%, 1)",
          600: primary,
          700: "hsla(208, 100%, 35%, 1)",
          800: "hsla(208, 100%, 27%, 1)",
          900: "hsla(208, 100%, 19%, 1)"
        },
        secondary: {
          DEFAULT: secondary,
          50: "hsla(190, 81%, 90%, 1)",
          100: "hsla(190, 81%, 82%, 1)",
          200: "hsla(190, 81%, 74%, 1)",
          300: "hsla(190, 81%, 66%, 1)",
          400: "hsla(190, 81%, 58%, 1)",
          500: "hsla(190, 81%, 50%, 1)",
          600: secondary,
          700: "hsla(190, 81%, 34%, 1)",
          800: "hsla(190, 81%, 28%, 1)",
          900: "hsla(190, 81%, 20%, 1)"
        },
        "gray-darker": "#504747"
      },
      spacing: {
        7.5: "1.875rem", // 30px
        15: "3.75rem", // 60px
        22: "5.5rem", // 88px
        25: "6.25rem", // 100px
        26: "6.5rem", // 104px
        30: "8.5rem", // 136px
        32: "9rem", // 144px
        68: "17rem" // 272px
      },
      padding: {
        px: "1px"
      },
      margin: {
        px: "1px",
        "-px": "-1px",
        "-2px": "-2px",
        auto: "auto"
      },
      fontSize: {
        micro: ".5rem", // 8px
        xxs: ".625rem", // 10px
        md: "1.125rem" // 18px
      },
      fontWeight: {
        hairline: 100
      },
      fontFamily: {
        brand: ["Source Sans Pro", "sans-serif"],
        sans: ["Source Sans Pro", "sans-serif"],
        serif: ["Source Sans Pro", "sans-serif"],
        inconsolata: ["Inconsolata"],
        source: ["source-code-pro", "Menlo", "Monaco", "Consolas", "Courier New", "monospace"]
      },
      minWidth: {
        site: "18.75rem",
        "input-mini": "17.5rem",
        "input-small": "31.25rem",
        "input-medium": "36.3125rem",
        "input-large": "61.45rem",
        "button-mini": "5.5rem",
        "button-small": "7rem",
        "button-medium": "9.875rem",
        "button-large": "10rem"
      },
      width: {
        arrow: ".8rem",
        "3/10": "30%",
        "7/10": "70%",
        "9/10": "90%",
        "12/25": "48%"
      },
      maxWidth: {
        sm: "30rem",
        md: "40rem",
        lg: "50rem",
        xl: "60rem",
        "2xl": "70rem",
        "3xl": "80rem",
        "4xl": "90rem",
        "5xl": "100rem",
        "1/4": "25%",
        "1/2": "50%",
        "3/5": "60%",
        "4/5": "80%",
        "9/10": "90%",
        "site-mini": "17.5rem",
        "site-small": "31.25rem",
        "site-medium": "43.75rem",
        "site-large": "56.25rem",
        site: "73.75rem",
        screen: "100vw"
      },
      height: {
        arrow: ".4rem",
        px: "1px",
        4: "1rem",
        5: "1.25rem",
        8: "1.8rem",
        9: "2.25rem",
        10: "2.5rem",
        11: "2.75rem",
        12: "3rem",
        16: "4rem",
        24: "6rem",
        32: "8rem"
      },
      borderWidth: {
        1: "1px",
        5: "5px"
      },
      borderRadius: {
        half: "50%",
        full: "100%"
      },
      zIndex: {
        1: 1,
        2: 2,
        3: 3,
        4: 4,
        5: 5,
        6: 6
      },
      fill: {
        transparent: "transparent"
      },
      flex: {
        2: "2 2 0%",
        3: "3 3 0%"
      }
    },
    outline: {
      none: ["2px solid transparent", "2px"],
      white: ["2px dotted white", "2px"],
      black: ["2px dotted black", "2px"]
    }
  },
  variants: {
    extend: {}
  },
  corePlugins: {
    borderCollapse: true
  },
  plugins: []
};

Then create a tailwind.css in styles directory and add the following lines:

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

Import the tailwind.css in the index.css created by create-react-app:

@import "~formiojs/dist/formio.full.css";
@import "./tailwind.css";
@import "~@tsed/tailwind-formio/styles/index.css";

Optionally, you can import fonts and icons:

@import "~formiojs/dist/formio.full.css";
@import "./tailwind.css";
+@import "./fonts/source-sans-pro/index.css";
+@import "./fonts/inconsolata/index.css";
+@import "./fonts/bxicons/index.css";
@import "~@tsed/tailwind-formio/styles/index.css";

Now, we can configure formio to use the tailwind template in our React application. So edit the index.js (or index.ts):

import React from 'react';
import ReactDOM from 'react-dom';
+import { Formio, Templates } from "@tsed/react-formio";
+import tailwind from "@tsed/tailwind-formio";
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

+Formio.use(tailwind);
+Templates.framework = "tailwind";

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

Finally, start the application!

Contributors

Please read contributing guidelines here.

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

License

The MIT License (MIT)

Copyright (c) 2016 - 2021 Romain Lenzotti

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

2.3.0

2 months ago

2.2.1

8 months ago

2.2.0

8 months ago

2.2.3

8 months ago

2.2.2

8 months ago

2.0.3

1 year ago

2.1.2

12 months ago

2.1.1

1 year ago

2.1.4

12 months ago

2.1.0

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.15.0

1 year ago

1.14.1

1 year ago

1.14.0

1 year ago

1.13.7-rc.1

2 years ago

1.12.0

2 years ago

1.13.2

2 years ago

1.13.1

2 years ago

1.13.0

2 years ago

1.13.6

2 years ago

1.13.5

2 years ago

1.13.4

2 years ago

1.13.3

2 years ago

1.11.2

2 years ago

1.11.1

2 years ago

1.11.0

2 years ago

1.10.13

2 years ago

1.10.14

2 years ago

1.10.5

3 years ago

1.10.4

3 years ago

1.10.3

3 years ago

1.10.2

3 years ago

1.10.9

2 years ago

1.10.8

2 years ago

1.10.7

3 years ago

1.10.6

3 years ago

1.9.9

3 years ago

1.10.11

2 years ago

1.10.12

2 years ago

1.10.10

2 years ago

1.10.1

3 years ago

1.10.0

3 years ago

1.9.8

3 years ago

1.9.7

3 years ago

1.9.6

3 years ago

1.9.5

3 years ago

1.9.4

3 years ago

1.9.3

3 years ago

1.9.1

3 years ago

1.9.0

3 years ago

1.9.2

3 years ago

1.8.13

3 years ago

1.8.14

3 years ago

1.8.15

3 years ago

1.8.16

3 years ago

1.8.11

3 years ago

1.8.12

3 years ago

1.8.9

3 years ago

1.8.10

3 years ago

1.8.8

3 years ago

1.8.7

3 years ago

1.8.6

3 years ago

1.8.5

3 years ago

1.8.4

3 years ago

1.8.3

3 years ago

1.8.2

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.0

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago