diff --git a/Gruntfile.js b/Gruntfile.js index 5d5d6ae4c..813a472b6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,5 +1,9 @@ 'use strict'; -module.exports = function(grunt) { +module.exports = function( grunt) { + const tailwindFileMap = { + 'admin/form-builder/views/form-builder.php': 'admin/form-builder.css', + } + var formBuilderAssets = require('./admin/form-builder/assets/js/form-builder-assets.js'); var pkg = grunt.file.readJSON('package.json'); @@ -112,7 +116,15 @@ module.exports = function(grunt) { tasks: [ 'shell:npm_build' ] - } + }, + + tailwind: { + files: ['src/css/**/*.css', 'admin/form-builder/views/*.php', 'includes/Admin/views/*.php'], + tasks: ['shell:tailwind'], + options: { + spawn: false + } + }, }, // Clean up build directory @@ -221,6 +233,11 @@ module.exports = function(grunt) { shell: { npm_build: { command: 'npm run build', + }, + tailwind: { + command: function ( input, output ) { + return `npx tailwindcss -i ${input} -o ${output}`; + } } } }); @@ -238,6 +255,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks( 'grunt-notify' ); grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' ); grunt.loadNpmTasks( 'grunt-shell' ); + grunt.loadNpmTasks( 'grunt-postcss' ); grunt.registerTask( 'default', [ 'less', 'concat', 'uglify', 'i18n' ] ); @@ -248,4 +266,28 @@ module.exports = function(grunt) { // build stuff grunt.registerTask( 'release', [ 'less', 'concat', 'uglify', 'i18n', 'readme' ] ); grunt.registerTask( 'zip', [ 'clean', 'copy', 'compress' ] ); + + grunt.event.on('watch', function(action, filepath, target) { + if (target === 'tailwind') { + grunt.task.run('tailwind'); + } + }); + + grunt.registerTask('tailwind', function() { + const done = this.async(); + + // Process each file mapping + Object.entries(tailwindFileMap).forEach(([phpFile, cssFile]) => { + const inputFile = `src/css/${cssFile}`; + const outputFile = `assets/css/${cssFile}`; + + // Ensure the input file exists + if (grunt.file.exists(inputFile)) { + // Run the tailwind command + grunt.task.run(`shell:tailwind:${inputFile}:${outputFile}`); + } + }); + + done(); + }); }; diff --git a/admin/form-builder/assets/js/components/form-checkbox_field/template.php b/admin/form-builder/assets/js/components/form-checkbox_field/template.php index 0111026b0..e59ce0d70 100644 --- a/admin/form-builder/assets/js/components/form-checkbox_field/template.php +++ b/admin/form-builder/assets/js/components/form-checkbox_field/template.php @@ -1,16 +1,44 @@