-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30803c8
commit 1114462
Showing
2 changed files
with
111 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<template> | ||
<label class="relative"> | ||
<input | ||
v-model.number="value" | ||
class="absolute input-reset w3 pa0 bn bg-transparent mono f4 fw5 lh-copy white tr" | ||
type="number" | ||
:class="shouldDisplayInput ? '' : 'is-hidden'" | ||
:min="min" | ||
:max="max" | ||
:step="step" | ||
@blur="onBlur" | ||
@change="onChange" | ||
@focus="onFocus" | ||
/> | ||
<span | ||
class="dib w3 pa0 mono f4 fw5 lh-copy white tr" | ||
:class="shouldDisplayInput ? 'o-40' : ''" | ||
>{{ value | zeropad }}</span | ||
> | ||
</label> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
filters: { | ||
zeropad: function(value) { | ||
return value ? value.toString().padStart(3, '0') : '' | ||
}, | ||
}, | ||
props: { | ||
max: { | ||
type: Number, | ||
default: Infinity, | ||
}, | ||
min: { | ||
type: Number, | ||
default: -Infinity, | ||
}, | ||
value: { | ||
type: Number, | ||
required: true, | ||
}, | ||
step: { | ||
type: Number, | ||
default: 1, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
shouldDisplayInput: false, | ||
} | ||
}, | ||
methods: { | ||
onBlur() { | ||
this.shouldDisplayInput = false | ||
}, | ||
onFocus() { | ||
this.shouldDisplayInput = true | ||
}, | ||
onChange($event) { | ||
this.$emit('update', $event.target.value) | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style scoped lang="postcss"> | ||
input { | ||
right: 0; | ||
appearance: textfield; | ||
&.is-hidden { | ||
width: 1px; | ||
height: 1px; | ||
padding: 0; | ||
margin: -1px; | ||
overflow: hidden; | ||
clip: rect(0, 0, 0, 0); | ||
border: 0; | ||
} | ||
&::-webkit-inner-spin-button, | ||
&::-webkit-outer-spin-button { | ||
appearance: none; | ||
margin: 0; | ||
} | ||
} | ||
span { | ||
cursor: text; | ||
} | ||
</style> |
1114462
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully aliased the URL https://gibsonipsum-o1r3uwlrc.now.sh to the following aliases: