-
Notifications
You must be signed in to change notification settings - Fork 38
/
AuthenticateInput.vue
72 lines (68 loc) · 1.4 KB
/
AuthenticateInput.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<template>
<div>
<label :for="id" :class="$style.title" :style="styles.title">{{
label
}}</label>
<input
:class="$style.input"
:id="id"
:style="styles.input"
:value="text"
:type="type"
@input="onInput"
/>
</div>
</template>
<script lang="ts">
import {
defineComponent,
SetupContext,
reactive,
PropType
} from '@vue/composition-api'
import useInput from '@/use/input'
import { makeStyles } from '@/lib/styles'
import { randomString } from '@/lib/util/randomString'
const useStyles = () =>
reactive({
title: makeStyles(theme => ({
color: theme.ui.secondary
})),
input: makeStyles(theme => ({
background: theme.background.secondary,
color: theme.text.primary
}))
})
export default defineComponent({
name: 'AuthenticateInput',
props: {
text: { type: String, default: '' },
label: { type: String, default: '' },
type: {
type: String as PropType<'text' | 'password'>,
default: 'text' as const
}
},
setup(props, context: SetupContext) {
const { onInput } = useInput(context)
const styles = useStyles()
const id = randomString()
return { styles, onInput, id }
}
})
</script>
<style lang="scss" module>
.title {
margin-bottom: 16px;
font: {
size: 1rem;
weight: bold;
}
}
.input {
height: 2rem;
padding: 0.5rem;
border-radius: 4px;
width: 100%;
}
</style>