Newer
Older
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<script>
export default {
data: () => {
return {
image: "profile/default_avatar.png",
profile: {
profileImageUrl: "",
name: "",
isRestricted: false
}
}
},
methods: {
submit() {
console.log(this.profile)
},
updateImg(e) {
let file = document.getElementById('avatar').files[0];
let reader = new FileReader();
reader.onload = function(ev) {
document.getElementById("avatar_preview").src = ev.target.result;
}
reader.readAsDataURL(file);
}
}
}
</script>
<template>
<main>
<h1>Ny profil</h1>
<form action="todo" method="post">
<label for="avatar" id="avatar_label">
<div class="img_hover">
<img :src="image" alt="fjes" id="avatar_preview">
<p class="hover_text">
Klikk for å endre
</p>
</div>
</label>
<input type="file" name="avatar" id="avatar" @change="updateImg">
<label for="name">Navn</label>
<input name="name" type="text" v-model="profile.name">
<div class="check_container">
<label for="child">Begrenset:</label>
<input name="child" type="checkbox" v-model="profile.isRestricted">
</div>
</form>
<button @click="submit">Opprett</button>
</main>
</template>
<style scoped lang="scss">
@import '../style.scss';
$img-size: 150px;
input[type="file"] {
display: none;
}
main {
display: flex;
flex-direction: column;
padding-top: 15%;
flex-wrap: wrap;
justify-content: center;
align-items: center;
gap: 1em;
}
#avatar_label {
display: flex;
justify-content: center;
width: 100%;
}
.check_container {
display: flex;
gap: .5em;
}
.img_hover {
display: flex;
justify-content: center;
align-items: center;
&:hover .hover_text {
visibility: visible;
opacity: 1;
}
&:hover img {
filter: brightness(70%);
border-radius: 25%;
}
img {
height: $img-size;
width: $img-size;
border-radius: 50%;
transition: all 300ms ease;
}
}
.hover_text {
position: absolute;
font-weight: bold;
color: #fff;
visibility: hidden;
opacity: 0;
transition: all 350ms eases;
}
form {
display: flex;
flex-direction: column;
max-width: 20em;
}
button {
padding: .5rem 1rem;
border: 2px $green solid;
border-radius: .5rem;
background-color: $light-green;
color: white;
font-weight: bold;
}
</style>