Skip to content
This repository was archived by the owner on Apr 25, 2020. It is now read-only.

Commit f1ab3fd

Browse files
committed
Rename always to fixed, add test and docs
1 parent b48ba69 commit f1ab3fd

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@ export default {
203203
</script>
204204
```
205205

206+
Set `:fixed` to `true` to make label permanently active:
207+
208+
```vue
209+
<template>
210+
<float-label fixed>
211+
<input type="text" placeholder="Fixed">
212+
</float-label>
213+
</template>
214+
```
215+
206216
Set `:dispatch` to `false` to disable triggering `input` event
207217
once the component is mounted:
208218

components/FloatLabel.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
type: Boolean,
1616
default: true
1717
},
18-
always: {
18+
fixed: {
1919
type: Boolean,
2020
default: false
2121
},
@@ -84,7 +84,7 @@ export default {
8484
},
8585
classObject () {
8686
return {
87-
'vfl-label-on-input': this.on && (this.isActive || this.always),
87+
'vfl-label-on-input': this.on && (this.isActive || this.fixed),
8888
'vfl-label-on-focus': this.isFocused
8989
}
9090
},

demo/Demo.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
</select>
4040
</float-label>
4141

42+
<float-label fixed>
43+
<input type="text" placeholder="Fixed">
44+
</float-label>
45+
4246
<div class="example">
4347
<float-label>
4448
<input type="text" placeholder="Website">

test/components/FloatLabel.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,9 @@ test(':label', () => {
8585
expect(ctorInput({ label: 'Foobar' }).floatLabel).toEqual('Foobar')
8686
})
8787

88+
test(':fixed', () => {
89+
expect(ctorInput({ fixed: true }).classObject).toMatchObject({ 'vfl-label-on-input': true })
90+
})
91+
8892
xtest(':on')
8993
xtest(':dispatch')

0 commit comments

Comments
 (0)