Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 4ffd8c0

Browse files
authored
Merge pull request #180 from asigloo/feature/custom-styles-attr
feat(forms): added CustomStyles attrs to form and inputs
2 parents 1f57661 + a3fd0ed commit 4ffd8c0

File tree

7 files changed

+822
-2174
lines changed

7 files changed

+822
-2174
lines changed

dev/vue/App.vue

+9
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,15 @@ const data = () => ({
197197
customClass: 'col-6',
198198
options: ['Arduino', 'Pinguino'],
199199
}),
200+
new FormField({
201+
type: 'text',
202+
label: 'Custom Style',
203+
name: 'custom-style',
204+
customStyles: {
205+
boxShadow: '0 0 22px -1px rgba(0,0,0,0.2)',
206+
},
207+
customClass: 'col-12',
208+
}),
200209
],
201210
options: {
202211
autoValidate: true,

package-lock.json

+790-2,174
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/dynamic-form/DynamicForm.js

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ const methods = {
7777
};
7878

7979
const computed = {
80+
getClasses() {
81+
return this.options.customClass;
82+
},
83+
getStyles() {
84+
return this.options.customStyles;
85+
},
8086
isValid() {
8187
const control = this.controls.find(control => !control.valid);
8288
return control ? control.valid : true;

src/components/dynamic-form/DynamicForm.vue

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
v-if="fields.length > 0 && !showFeedback"
55
:id="id"
66
:name="id"
7+
:class="getClasses"
8+
:style="getStyles"
79
v-bind="formattedOptions"
810
novalidate
911
@submit.prevent="handleSubmit()"

src/components/dynamic-input/DynamicInput.js

+3
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ const computed = {
9292
(this.submited || this.autoValidate)
9393
);
9494
},
95+
getStyles() {
96+
return this.formControl.customStyles;
97+
},
9598
errorMessages() {
9699
const errors = Object.entries(this.formControl.errors);
97100
if (errors.length > 0) {

src/components/dynamic-input/DynamicInput.vue

+6
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,31 @@
1010
"
1111
:formControl="formControl"
1212
@change="valueChange"
13+
:style="getStyles"
1314
/>
1415
<input-textarea
1516
v-if="formControl.type === 'textarea'"
1617
:formControl="formControl"
1718
@change="valueChange"
19+
:style="getStyles"
1820
/>
1921
<input-select
2022
v-if="formControl.type === 'select'"
2123
:formControl="formControl"
2224
@change="valueChange"
25+
:style="getStyles"
2326
/>
2427
<input-checkbox
2528
v-if="formControl.type === 'checkbox'"
2629
:formControl="formControl"
2730
@change="valueChange"
31+
:style="getStyles"
2832
/>
2933
<input-radio
3034
v-if="formControl.type === 'radio'"
3135
:formControl="formControl"
3236
@change="valueChange"
37+
:style="getStyles"
3338
/>
3439
<slot
3540
v-if="formControl.type === 'custom-field'"
@@ -38,6 +43,7 @@
3843
:valueChange="valueChange"
3944
:onFocus="onFocus"
4045
:onBlur="onBlur"
46+
:style="getStyles"
4147
/>
4248
<label
4349
class="form-label"

src/core/utils/form-control.model.js

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export function FormControl({
77
form,
88
name = null,
99
customClass = null,
10+
customStyles = null,
1011
options = [],
1112
placeholder = null,
1213
rows = null,
@@ -26,6 +27,7 @@ export function FormControl({
2627
this.label = label;
2728
this.name = name;
2829
this.customClass = customClass;
30+
this.customStyles = customStyles;
2931
this.options = options;
3032
this.placeholder = placeholder;
3133
this.disabled = disabled;
@@ -46,6 +48,7 @@ export function FormField({
4648
label = null,
4749
name = null,
4850
customClass = null,
51+
customStyles = null,
4952
disabled = false,
5053
options = [],
5154
placeholder = null,
@@ -61,6 +64,7 @@ export function FormField({
6164
this.label = label;
6265
this.name = name;
6366
this.customClass = customClass;
67+
this.customStyles = customStyles;
6468
this.disabled = disabled;
6569
this.options = options;
6670
this.placeholder = placeholder;
@@ -80,12 +84,14 @@ export function FormValidation(
8084

8185
export function FormOptions({
8286
customClass = '',
87+
customStyles = '',
8388
method = 'POST',
8489
autoValidate = false,
8590
netlify = false,
8691
netlifyHoneypot = null,
8792
}) {
8893
this.customClass = customClass;
94+
this.customStyles = customStyles;
8995
this.method = method;
9096
this.autoValidate = autoValidate;
9197
this.netlify = netlify;

0 commit comments

Comments
 (0)