-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhance: header for form builder UI redesign #1488
base: develop
Are you sure you want to change the base?
Changes from 8 commits
63151b3
787c082
a7c5fe7
d008e8a
c96afbf
065b1fa
6607241
ab3ce2c
3eba5a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}`; | ||
} | ||
} | ||
Comment on lines
+237
to
241
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential issue with dynamic parameters in the The Consider modifying the task to accept arguments differently or restructure the tailwind: {
command: 'npx tailwindcss -i <%= inputFile %> -o <%= outputFile %>'
} And set |
||
} | ||
}); | ||
|
@@ -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' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You have loaded |
||
|
||
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(); | ||
}); | ||
Comment on lines
+276
to
+292
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Asynchronous In the Consider restructuring the grunt.registerTask('tailwind', function() {
// 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)) {
// Set the input and output files
grunt.config.set('inputFile', inputFile);
grunt.config.set('outputFile', outputFile);
// Run the tailwind shell command
grunt.task.run('shell:tailwind');
}
});
}); And modify the tailwind: {
command: 'npx tailwindcss -i <%= inputFile %> -o <%= outputFile %>'
} Would you like assistance in implementing this refactoring to ensure the Tailwind CSS compilation runs smoothly? |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,44 @@ | ||
<div class="wpuf-fields"> | ||
<ul :class="['wpuf-fields-list', ('yes' === field.inline) ? 'wpuf-list-inline' : '']"> | ||
<li v-if="has_options" v-for="(label, val) in field.options"> | ||
<label> | ||
<div | ||
v-if="field.inline !== 'yes'" | ||
class="wpuf-space-y-5"> | ||
<div | ||
v-if="has_options" v-for="(label, val) in field.options" | ||
class="wpuf-relative wpuf-flex wpuf-items-start"> | ||
<div class="wpuf-items-center"> | ||
<input | ||
type="checkbox" | ||
:value="val" | ||
:checked="is_selected(val)" | ||
:class="class_names('checkbox_btns')" | ||
> {{ label }} | ||
</label> | ||
</li> | ||
</ul> | ||
class="wpuf-h-4 wpuf-w-4 wpuf-rounded wpuf-border-gray-300 wpuf-text-indigo-600 focus:wpuf-ring-indigo-600"> | ||
</div> | ||
<div class="wpuf-ml-1 wpuf-text-sm"> | ||
<label class="wpuf-font-medium wpuf-text-gray-900">{{ label }}</label> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<span v-if="field.help" class="wpuf-help" v-html="field.help" /> | ||
<div | ||
v-if="field.inline === 'yes'" | ||
class="wpuf-flex" | ||
> | ||
<div | ||
v-if="has_options" v-for="(label, val) in field.options" | ||
class="wpuf-relative wpuf-flex wpuf-items-start wpuf-mr-4"> | ||
<div class="wpuf-items-center"> | ||
<input | ||
type="checkbox" | ||
:value="val" | ||
:checked="is_selected(val)" | ||
:class="class_names('checkbox_btns')" | ||
class="wpuf-h-4 wpuf-w-4 wpuf-rounded wpuf-border-gray-300 wpuf-text-indigo-600 focus:wpuf-ring-indigo-600"> | ||
</div> | ||
<div class="wpuf-ml-1 wpuf-text-sm"> | ||
<label class="wpuf-font-medium wpuf-text-gray-900">{{ label }}</label> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<p v-if="field.help" class="wpuf-mt-2 wpuf-text-sm wpuf-text-gray-500" v-html="field.help"></p> | ||
Comment on lines
+2
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider refactoring to reduce code duplication. The template effectively supports both inline and vertical layouts with consistent use of Tailwind CSS classes. However, there's an opportunity to reduce code duplication between the two layout options. Consider extracting the common checkbox rendering logic into a separate component or method. This could be achieved by creating a new Vue component for the checkbox item or using a method to render the checkbox. Here's a conceptual example: <template>
<div :class="containerClass">
<checkbox-item
v-for="(label, val) in field.options"
:key="val"
:value="val"
:label="label"
:checked="is_selected(val)"
:class="checkboxClass"
/>
</div>
<p v-if="field.help" class="wpuf-mt-2 wpuf-text-sm wpuf-text-gray-500" v-html="field.help"></p>
</template>
<script>
export default {
// ... other component logic ...
computed: {
containerClass() {
return this.field.inline === 'yes'
? 'wpuf-flex'
: 'wpuf-space-y-5';
},
checkboxClass() {
return this.field.inline === 'yes'
? 'wpuf-mr-4'
: '';
}
}
}
</script> This approach would centralize the checkbox rendering logic, making it easier to maintain and update in the future. |
||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
<div class="wpuf-fields"> | ||
<select | ||
disabled | ||
:class="class_names('select_lbl')" | ||
> | ||
class="wpuf-block wpuf-w-full !wpuf-max-w-full wpuf-rounded-md wpuf-border-0 wpuf-text-gray-900 wpuf-ring-1 wpuf-ring-inset wpuf-ring-gray-300 focus:wpuf-ring-2 focus:wpuf-ring-indigo-600 sm:wpuf-text-sm sm:wpuf-leading-6"> | ||
<option v-if="field.first" value="">{{ field.first }}</option> | ||
|
||
<option | ||
v-if="has_options" | ||
v-for="(label, val) in field.options" | ||
:value="label" | ||
:selected="is_selected(label)" | ||
>{{ label }}</option> | ||
</select> | ||
|
||
<span v-if="field.help" class="wpuf-help" v-html="field.help"> </span> | ||
<p v-if="field.help" class="wpuf-mt-2 wpuf-text-sm wpuf-text-gray-500" v-html="field.help"></p> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
<div class="wpuf-fields"> | ||
<input | ||
disabled | ||
type="text" | ||
:class="class_names('textfield')" | ||
:placeholder="field.placeholder" | ||
:value="field.default" | ||
:size="field.size" | ||
:class="class_names('textfield')" | ||
class="wpuf-block wpuf-w-full wpuf-rounded-md wpuf-border-0 wpuf-py-1.5 wpuf-text-gray-900 wpuf-shadow-sm wpuf-ring-1 wpuf-ring-inset wpuf-ring-gray-300 placeholder:wpuf-text-gray-400 focus:wpuf-ring-2 focus:wpuf-ring-inset focus:wpuf-ring-indigo-600 sm:wpuf-text-sm sm:wpuf-leading-6" | ||
> | ||
<span v-if="field.help" class="wpuf-help" v-html="field.help" /> | ||
<p v-if="field.help" class="wpuf-mt-2 wpuf-text-sm wpuf-text-gray-500" v-html="field.help"></p> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
<div class="wpuf-fields"> | ||
<ul :class="['wpuf-fields-list', ('yes' === field.inline) ? 'wpuf-list-inline' : '']"> | ||
<li v-if="has_options" v-for="(label, val) in field.options"> | ||
<label> | ||
<input | ||
type="radio" | ||
:value="val" | ||
:checked="is_selected(val)" | ||
:class="class_names('radio_btns')" | ||
> {{ label }} | ||
</label> | ||
</li> | ||
</ul> | ||
<div | ||
v-if="field.inline !== 'yes'" | ||
class="wpuf-space-y-6"> | ||
<div | ||
v-if="has_options" v-for="(label, val) in field.options" | ||
class="wpuf-flex wpuf-items-center"> | ||
<input | ||
type="radio" | ||
class="wpuf-h-4 wpuf-w-4 wpuf-border-gray-300 wpuf-text-indigo-600 focus:wpuf-ring-indigo-600"> | ||
<label | ||
disabled | ||
:value="val" | ||
:checked="is_selected(val)" | ||
:class="class_names('radio_btns')" | ||
class="wpuf-ml-3 wpuf-block wpuf-text-sm wpuf-font-medium wpuf-leading-6 wpuf-text-gray-900">{{ label }}</label> | ||
sapayth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
</div> | ||
|
||
<span v-if="field.help" class="wpuf-help" v-html="field.help"/> | ||
<p v-if="field.help" class="wpuf-mt-2 wpuf-text-sm wpuf-text-gray-500" v-html="field.help"></p> | ||
Comment on lines
1
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Country Dropdown Not Addressed in This PR The changes in To fully meet the PR objectives:
These additions are necessary to enhance the billing address section's usability and align with user feedback. 🔗 Analysis chainSummary of changes and alignment with PR objectives The changes to this file align well with the PR objective of enhancing the form builder UI. The integration of Tailwind CSS classes improves the styling and layout of the radio button fields, contributing to a more visually appealing and consistent design. However, the changes don't directly address the specific user request mentioned in issue #638 regarding the country dropdown in the billing address section. This file focuses on the radio button component, which is a separate concern. To fully meet the PR objectives:
These additional changes would more directly address the user feedback and improve the usability of the billing address section. To verify if the country dropdown has been addressed in other files, you can run the following script: This will help identify if and where the country dropdown functionality has been modified to meet the user's request. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for files that might contain country dropdown logic
rg -i -t php -t js "country.*dropdown" --glob '!vendor/*'
Length of output: 59 Script: #!/bin/bash
# Broad search for 'country' related terms in PHP and JS files
rg -i -t php -t js "country" --glob '!vendor/*'
Length of output: 23363 |
||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
<div class="wpuf-fields"> | ||
<input | ||
disabled | ||
sapayth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type="text" | ||
:class="class_names('textfield')" | ||
:placeholder="field.placeholder" | ||
:value="field.default" | ||
:size="field.size" | ||
:class="class_names('textfield')" | ||
class="wpuf-block wpuf-w-full wpuf-rounded-md wpuf-border-0 wpuf-py-1.5 wpuf-text-gray-900 wpuf-shadow-sm wpuf-ring-1 wpuf-ring-inset wpuf-ring-gray-300 placeholder:wpuf-text-gray-400 focus:wpuf-ring-2 focus:wpuf-ring-inset focus:wpuf-ring-indigo-600 sm:wpuf-text-sm sm:wpuf-leading-6" | ||
> | ||
<span v-if="field.help" class="wpuf-help" v-html="field.help" /> | ||
<p v-if="field.help" class="wpuf-mt-2 wpuf-text-sm wpuf-text-gray-500" v-html="field.help"></p> | ||
sapayth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
<div class="wpuf-fields"> | ||
<textarea | ||
v-if="'no' === field.rich" | ||
:class="class_names('textareafield')" | ||
:placeholder="field.placeholder" | ||
:deault="field.default" | ||
:default="field.default" | ||
:rows="field.rows" | ||
:cols="field.cols" | ||
>{{ field.default }}</textarea> | ||
:class="class_names('textareafield')" | ||
class="wpuf-block wpuf-w-full wpuf-rounded-md wpuf-border-0 wpuf-py-1.5 wpuf-text-gray-900 wpuf-shadow-sm wpuf-ring-1 wpuf-ring-inset wpuf-ring-gray-300 placeholder:wpuf-text-gray-400 focus:wpuf-ring-2 focus:wpuf-ring-inset focus:wpuf-ring-indigo-600 sm:wpuf-text-sm sm:wpuf-leading-6">{{ field.default }}</textarea> | ||
|
||
sapayth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<text-editor v-if="'no' !== field.rich" :default_text="field.default" :rich="field.rich"></text-editor> | ||
<text-editor | ||
v-if="'no' !== field.rich" | ||
:default_text="field.default" | ||
:rich="field.rich"></text-editor> | ||
|
||
<span v-if="field.help" class="wpuf-help" v-html="field.help" /> | ||
<p v-if="field.help" class="wpuf-mt-2 wpuf-text-sm wpuf-text-gray-500" v-html="field.help"></p> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Inconsistent use of
const
instead ofvar
The codebase primarily uses
var
for variable declarations, but the new code introducesconst
fortailwindFileMap
. For consistency, consider usingvar
, or update the entire file to use ES6 declarations (let
andconst
) where appropriate.