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

Commit 084cefd

Browse files
authored
Merge pull request #43 from alvarosaburido/feature/material-theme
Feature/material theme
2 parents e64f14d + 5c81c2a commit 084cefd

File tree

17 files changed

+491
-26
lines changed

17 files changed

+491
-26
lines changed

dev/nuxt/nuxt.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default {
5252
*/
5353
modules: [['@asigloo/vue-dynamic-forms/nuxt']],
5454
dynamicForms: {
55-
theme: 'default',
55+
theme: 'material',
5656
},
5757
/*
5858
** Build configuration

dev/nuxt/package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/vue/App.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ const data = () => ({
137137
inline: false,
138138
customClass: 'col-12',
139139
}),
140+
new FormField({
141+
type: 'checkbox',
142+
label: 'Disabled',
143+
name: 'disabled',
144+
value: true,
145+
disabled: true,
146+
customClass: 'col-12',
147+
}),
140148
new FormField({
141149
type: 'radio',
142150
label: 'Prefered Animal',

dev/vue/styles/_vendors.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
// Customize default theme
55
/* $input-bg: #e9ecef;
66
$input-border-radius: 50px; */
7+
// @import '../../src/styles/themes/default.scss';
78

8-
@import '../../src/styles/themes/default.scss';
9+
@import '../../src/styles/themes/material.scss';

docs/guide/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ You can select directly the theme trough `dynamicForms` options like this
6868
module.exports = {
6969
modules: ['@asigloo/vue-dynamic-forms/nuxt'],
7070
dynamicForms: {
71-
theme: 'materialize',
71+
theme: 'default',
7272
},
7373
};
7474
```

docs/guide/theming.md

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ The components are unstyled by default, so you can customize them with your own
44
@import '~@asigloo/vue-dynamic-forms/src/styles/themes/theme.scss';
55
```
66

7-
For now, only default theme (similar to bootstrap) is available. More themes are in progress.
8-
7+
More themes are in progress.
98

109
## Defaul Theme
1110

@@ -14,7 +13,18 @@ Similar to default bootstrap theme for forms.
1413
### Import to your app
1514

1615
```scss
17-
@import '~@asigloo/vue-dynamic-forms/src/styles/themes/theme.scss';
16+
@import '~@asigloo/vue-dynamic-forms/src/styles/themes/default.scss';
17+
```
18+
19+
or with Nuxt Module options in `nuxt.config.js`:
20+
21+
```javascript [nuxt.config.js]
22+
module.exports = {
23+
modules: ['@asigloo/vue-dynamic-forms/nuxt'],
24+
dynamicForms: {
25+
theme: 'default',
26+
},
27+
};
1828
```
1929

2030
### Customize your variables
@@ -23,7 +33,7 @@ Similar to default bootstrap theme for forms.
2333
$input-bg: #e2eb5d52;
2434
$input-border-color: #aec64c;
2535

26-
@import '~@asigloo/vue-dynamic-forms/src/styles/themes/theme.scss';
36+
@import '~@asigloo/vue-dynamic-forms/src/styles/themes/default.scss';
2737
```
2838

2939
### Variables available
@@ -54,8 +64,8 @@ $input-transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out
5464
$input-placeholder-color: #6c757d !default;
5565
$input-box-shadow: inset 0 1px 1px rgba(#000, 0.075) !default;
5666
$input-height: calc(
57-
#{$input-line-height * 1em} + #{$input-padding-y * 2} + #{$input-border-width *
58-
2}
67+
#{$input-line-height * 1em} + #{$input-padding-y * 2} +
68+
#{$input-border-width * 2}
5969
);
6070

6171
$input-focus-bg: $input-bg !default;
@@ -71,4 +81,64 @@ $input-error-color: #dc3545 !default;
7181

7282
## Material Theme
7383

74-
Work in progress [[#3](https://github.com/alvarosaburido/vue-dynamic-forms/issues/3)]
84+
### Import to your app
85+
86+
```scss
87+
@import '~@asigloo/vue-dynamic-forms/src/styles/themes/material.scss';
88+
```
89+
90+
or with Nuxt Module options in `nuxt.config.js`:
91+
92+
```javascript [nuxt.config.js]
93+
module.exports = {
94+
modules: ['@asigloo/vue-dynamic-forms/nuxt'],
95+
dynamicForms: {
96+
theme: 'material',
97+
},
98+
};
99+
```
100+
101+
### Variables available
102+
103+
You have all this variables to customize your form inputs.
104+
105+
Consider that this variables will affect **All** your inputs, for more selective styling please use `customClass` available on the [models](./models.md).
106+
107+
```scss
108+
$theme-color: #6200ee;
109+
$base-color: #ced4da;
110+
$text-color: #202020;
111+
$light: #fefefe;
112+
113+
$font-size: 1rem !default;
114+
115+
$font-family-sans-serif: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
116+
'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji',
117+
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji' !default;
118+
$font-family: $font-family-sans-serif !default;
119+
120+
$line-height: 1.5;
121+
122+
$input-padding-y: 0.375rem;
123+
$input-padding-x: 0.75rem;
124+
$input-border-width: 1px;
125+
$input-border-color: $base-color;
126+
$input-border-radius: 0;
127+
$input-transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
128+
$input-placeholder-color: #6c757d;
129+
130+
$input-error-color: #dc3545;
131+
```
132+
133+
### Customize your variables
134+
135+
```scss
136+
$theme-color: #6200ee;
137+
$base-color: #ced4da;
138+
139+
@import '~@asigloo/vue-dynamic-forms/src/styles/themes/material.scss';
140+
```
141+
142+
## Submit you own theme
143+
144+
If you have a great custom theme and you want it to be on the library submit a propose via PR [here](https://github.com/alvarosaburido/vue-dynamic-forms/pulls). 👩‍🎤👨‍🎤

nuxt/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path');
22

3-
const THEMES = ['default'];
3+
const THEMES = ['default', 'material'];
44

55
module.exports = function nuxtDynamicForms(moduleOptions) {
66
const options = Object.assign({}, this.options.dynamicForms, moduleOptions);

src/components/dynamic-input/DynamicInput.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<template>
22
<div :class="getClasses">
3-
<label
4-
class="form-label"
5-
:for="formControl.name"
6-
v-if="formControl.type !== 'checkbox'"
7-
>
8-
{{ formControl.label }}
9-
</label>
103
<input-text
114
v-if="
125
formControl.type === 'text' ||
@@ -39,12 +32,21 @@
3932
@change="valueChange"
4033
/>
4134
<slot
35+
v-if="formControl.type === 'custom-field'"
4236
:name="'custom-field'"
4337
:control="formControl"
4438
:valueChange="valueChange"
4539
:onFocus="onFocus"
4640
:onBlur="onBlur"
4741
/>
42+
<label
43+
class="form-label"
44+
:for="formControl.name"
45+
v-if="formControl.type !== 'checkbox'"
46+
>
47+
{{ formControl.label }}
48+
</label>
49+
<span class="form-bar"></span>
4850
<p class="form-hint" v-if="formControl.helper">
4951
{{ formControl.helper }}
5052
</p>

src/components/input-checkbox/InputCheckbox.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<template>
2-
<div class="form-check">
2+
<div class="input-checkbox">
33
<input
4-
class="form-check-input"
4+
class="input-checkbox__input"
55
type="checkbox"
66
:id="formControl.name"
77
v-model="formControl.value"
88
:disabled="formControl.disabled"
99
/>
10-
<label class="form-check-label" :for="formControl.name">
10+
<label class="input-checkbox__label" :for="formControl.name">
1111
{{ formControl.label }}
1212
</label>
1313
</div>

src/components/input-radio/InputRadio.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<template>
2-
<div class="input-radio">
2+
<div
3+
class="input-radio"
4+
:class="{ 'input-radio--inline': formControl.inline }"
5+
>
36
<div
4-
class="form-check"
5-
:class="{ 'form-check-inline': formControl.inline }"
7+
class="input-radio__base"
68
v-for="opt in formControl.options"
79
:key="opt.name"
810
>
911
<input
10-
class="form-check-input"
12+
class="input-radio__input"
1113
type="radio"
1214
:id="opt.value"
1315
v-model="formControl.value"
1416
:value="opt.value"
1517
:disabled="opt.disabled"
1618
/>
17-
<label class="form-check-label" :for="opt.value">
19+
<label class="input-radio__label" :for="opt.value">
1820
{{ opt.text }}
1921
</label>
2022
</div>

0 commit comments

Comments
 (0)