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

Commit 9ac52df

Browse files
committed
First Attempt of Material Theme
1 parent a0c3ad7 commit 9ac52df

File tree

8 files changed

+135
-14
lines changed

8 files changed

+135
-14
lines changed

dev/App.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@ const data = () => ({
8080
type: 'select',
8181
label: 'Category',
8282
name: 'category',
83+
value: 'arduino',
8384
options: [
8485
{ value: null, text: 'Please select an option' },
85-
{ value: 'arduino', text: 'Arduino' },
86-
{ value: 'transistors', text: 'Transistors' },
86+
{ value: 'actionfield', text: 'Action field' },
87+
{ value: 'advancedselect', text: 'Advanced select' },
88+
{ value: 'autocomplete', text: 'Autocomplete' },
89+
{ value: 'buttongroup', text: 'Button group' },
8790
],
8891
}),
8992
new FormField({

dev/styles/_vendors.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
//@import 'bootstrap/scss/bootstrap.scss';
22
@import 'bootstrap/scss/bootstrap-grid.scss';
33
@import '../../src/styles/themes/default.scss';
4+
// @import '../../src/styles/themes/material.scss';

src/components/dynamic-input/DynamicInput.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ const watch = {
6565
};
6666

6767
const computed = {
68-
hasValue() {
69-
const { value } = this.formControl;
70-
return value !== null && value !== undefined;
71-
},
7268
hasErrors() {
7369
return (
7470
this.formControl.errors &&

src/components/dynamic-input/DynamicInput.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
class="dynamic-input form-group"
44
:class="{ 'form-group--error': hasErrors }"
55
>
6-
<label
7-
class="form-label"
8-
:for="formControl.name"
9-
v-if="formControl.type !== 'checkbox'"
10-
>
11-
{{ formControl.label }}
12-
</label>
136
<input-text
147
v-if="
158
formControl.type === 'text' ||
@@ -40,6 +33,13 @@
4033
:formControl="formControl"
4134
@change="valueChange"
4235
/>
36+
<label
37+
class="form-label"
38+
:for="formControl.name"
39+
v-if="formControl.type !== 'checkbox'"
40+
>
41+
{{ formControl.label }}
42+
</label>
4343
<div v-if="hasErrors">
4444
<p
4545
v-for="(errorText, $index) in errorMessages"

src/components/input-select/InputSelect.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
:name="formControl.name"
66
class="form-control"
77
>
8-
<option v-for="opt in formControl.options" :key="opt.value">
8+
<option
9+
v-for="opt in formControl.options"
10+
:key="opt.value"
11+
:value="opt.value"
12+
>
913
{{ opt.text }}
1014
</option>
1115
</select>

src/components/input-text/InputText.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ const props = {
77
},
88
};
99

10+
const computed = {
11+
hasValue() {
12+
const { value } = this.formControl;
13+
return value !== null && value !== undefined;
14+
},
15+
};
16+
1017
const methods = {
1118
valueChange() {
1219
this.$emit('change', this.formControl.value);
@@ -24,6 +31,7 @@ const InputText = {
2431
name: 'asInputText',
2532
props,
2633
methods,
34+
computed,
2735
};
2836

2937
export default InputText;

src/components/input-text/InputText.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
v-model="formControl.value"
55
:name="formControl.name"
66
class="form-control"
7+
:data-text="hasValue"
8+
:class="{ 'form-control--value': hasValue }"
79
:type="formControl.type"
810
:placeholder="formControl.placeholder"
911
:disabled="formControl.disabled"

src/styles/themes/material.scss

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
$theme-color: #6200ee;
2+
$base-color: #ced4da;
3+
$font-size: 1rem !default;
4+
5+
$font-family-sans-serif: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
6+
'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji',
7+
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji' !default;
8+
$font-family: $font-family-sans-serif !default;
9+
10+
$line-height: 1.5;
11+
12+
$input-padding-y: 0.375rem;
13+
$input-padding-x: 0.75rem;
14+
$input-border-width: 1px;
15+
$input-border-color: $base-color;
16+
$input-border-radius: 0;
17+
$input-transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
18+
$input-placeholder-color: #6c757d;
19+
20+
$input-error-color: #dc3545;
21+
22+
.form-group {
23+
position: relative;
24+
margin-top: 35px;
25+
margin-bottom: 20px;
26+
27+
.form-label {
28+
position: absolute;
29+
left: 0;
30+
top: 7px;
31+
font-size: 16px;
32+
pointer-events: none;
33+
color: $base-color;
34+
transition: 0.2s ease all;
35+
}
36+
}
37+
38+
.form-control {
39+
width: 100%;
40+
padding: $input-padding-y $input-padding-x;
41+
font-family: $font-family;
42+
font-size: $font-size;
43+
height: calc(
44+
#{$line-height * 1em} + #{$input-padding-y * 2} + #{$input-border-width * 2}
45+
);
46+
border: 0;
47+
border-bottom: $input-border-width solid $input-border-color;
48+
border-radius: $input-border-radius;
49+
50+
// Placeholder
51+
&::placeholder {
52+
color: $input-border-color;
53+
opacity: 1;
54+
}
55+
56+
&:focus {
57+
outline: none;
58+
border-bottom: $input-border-width * 2 solid $input-border-color;
59+
}
60+
}
61+
62+
/* active state */
63+
.form-control:focus ~ .form-label,
64+
.form-control--value ~ .form-label,
65+
.custom-select ~ .form-label,
66+
.checkbox-group ~ .form-label,
67+
.radio-group ~ .form-label,
68+
.datalist-input--searching ~ .form-label {
69+
color: $theme-color;
70+
top: -18px;
71+
font-size: 12px;
72+
}
73+
74+
.checkbox-group,
75+
.radio-group {
76+
padding-top: 12px;
77+
}
78+
79+
.form-control:focus {
80+
border-bottom: 1px solid $theme-color;
81+
}
82+
83+
.custom-select {
84+
border-radius: 0;
85+
background-image: unset;
86+
border-bottom: 1px solid $theme-color;
87+
88+
&:focus {
89+
box-shadow: unset;
90+
}
91+
}
92+
93+
.datalist-input {
94+
border-bottom: 1px solid $theme-color;
95+
}
96+
97+
.custom-checkbox .custom-control-label {
98+
padding-left: 1rem;
99+
}
100+
101+
.custom-control-input:focus:not(:checked) ~ .custom-control-label::before {
102+
border-color: $theme-color;
103+
}
104+
105+
.custom-control-input:not(:checked) ~ .custom-control-label::before {
106+
border-color: $theme-color;
107+
}

0 commit comments

Comments
 (0)