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

Commit 0441699

Browse files
committed
Material - Labels & Border Bottom animation
1 parent a30f11b commit 0441699

File tree

4 files changed

+72
-23
lines changed

4 files changed

+72
-23
lines changed

dev/styles/_vendors.scss

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

src/components/dynamic-input/DynamicInput.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,22 @@
3333
:formControl="formControl"
3434
@change="valueChange"
3535
/>
36-
<label
37-
class="form-label"
38-
:for="formControl.name"
39-
v-if="formControl.type !== 'checkbox'"
40-
>
41-
{{ formControl.label }}
42-
</label>
4336
<slot
37+
v-if="formControl.type === 'custom-field'"
4438
:name="'custom-field'"
4539
:control="formControl"
4640
:valueChange="valueChange"
4741
:onFocus="onFocus"
4842
:onBlur="onBlur"
4943
/>
44+
<label
45+
class="form-label"
46+
:for="formControl.name"
47+
v-if="formControl.type !== 'checkbox'"
48+
>
49+
{{ formControl.label }}
50+
</label>
51+
<span class="form-bar"></span>
5052
<div v-if="hasErrors">
5153
<p
5254
v-for="(errorText, $index) in errorMessages"

src/styles/themes/default.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@ $input-error-color: #dc3545;
2525
.form-label {
2626
display: inline-block;
2727
margin-bottom: 0.5rem;
28+
order: 1;
2829
}
2930

3031
.form-group {
32+
display: flex;
33+
flex-direction: column;
3134
width: 100%;
3235
margin-bottom: 1rem;
3336

37+
& > div {
38+
order: 2;
39+
}
40+
3441
&--error {
3542
.form-label {
3643
color: $input-error-color;
@@ -60,6 +67,7 @@ $input-error-color: #dc3545;
6067
);
6168
border: $input-border-width solid $input-border-color;
6269
border-radius: $input-border-radius;
70+
order: 2;
6371

6472
// Placeholder
6573
&::placeholder {

src/styles/themes/material.scss

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,31 @@ $input-error-color: #dc3545;
2626

2727
.form-label {
2828
position: absolute;
29-
left: 0;
29+
left: 15px;
3030
top: 7px;
3131
font-size: 16px;
3232
pointer-events: none;
3333
color: $base-color;
3434
transition: 0.2s ease all;
3535
}
36+
37+
.form-bar {
38+
display: block;
39+
width: 100%;
40+
height: $input-border-width;
41+
background-color: $input-border-color;
42+
}
3643
}
3744

3845
.form-control {
46+
position: relative;
3947
width: 100%;
40-
padding: $input-padding-y $input-padding-x;
4148
font-family: $font-family;
4249
font-size: $font-size;
4350
height: calc(
4451
#{$line-height * 1em} + #{$input-padding-y * 2} + #{$input-border-width * 2}
4552
);
4653
border: 0;
47-
border-bottom: $input-border-width solid $input-border-color;
4854
border-radius: $input-border-radius;
4955

5056
// Placeholder
@@ -55,30 +61,67 @@ $input-error-color: #dc3545;
5561

5662
&:focus {
5763
outline: none;
58-
border-bottom: $input-border-width * 2 solid $input-border-color;
5964
}
6065
}
6166

6267
/* active state */
68+
.form-group > div ~ .form-label,
6369
.form-control:focus ~ .form-label,
6470
.form-control--value ~ .form-label,
65-
.custom-select ~ .form-label,
71+
select.form-control ~ .form-label,
72+
.custom-field ~ .form-label,
6673
.checkbox-group ~ .form-label,
67-
.radio-group ~ .form-label,
68-
.datalist-input--searching ~ .form-label {
74+
.input-radio ~ .form-label {
6975
color: $theme-color;
7076
top: -18px;
7177
font-size: 12px;
7278
}
7379

80+
.form-control ~ .form-bar {
81+
position: relative;
82+
83+
&::before {
84+
left: 50%;
85+
}
86+
&::after {
87+
right: 50%;
88+
}
89+
90+
&::before,
91+
&::after {
92+
content: '';
93+
height: 2px;
94+
width: 0;
95+
bottom: 1px;
96+
position: absolute;
97+
background: $theme-color;
98+
transition: 0.2s ease all;
99+
}
100+
}
101+
102+
.form-group > div ~ .form-bar,
103+
.form-control--value ~ .form-bar,
104+
.form-control:focus ~ .form-bar,
105+
.custom-field ~ .form-bar {
106+
&::before,
107+
&::after {
108+
width: 50%;
109+
}
110+
}
111+
112+
.form-check ~ .form-bar,
113+
.input-radio ~ .form-bar {
114+
display: none;
115+
}
116+
74117
.checkbox-group,
75-
.radio-group {
118+
.input-radio {
76119
padding-top: 12px;
77120
}
78121

79-
.form-control:focus {
122+
/* .form-control:focus {
80123
border-bottom: 1px solid $theme-color;
81-
}
124+
} */
82125

83126
.custom-select {
84127
border-radius: 0;
@@ -90,10 +133,6 @@ $input-error-color: #dc3545;
90133
}
91134
}
92135

93-
.datalist-input {
94-
border-bottom: 1px solid $theme-color;
95-
}
96-
97136
.custom-checkbox .custom-control-label {
98137
padding-left: 1rem;
99138
}

0 commit comments

Comments
 (0)