Newer
Older
import Toggle from '../components/Toggle.vue';
import { API } from '../util/API';
export default {
data: () => {
return {
image: "profile/default_avatar.png",
profile: {
profileImageUrl: "",
name: "",
isRestricted: false
}
this.profile.isRestricted = this.$refs.toggle.state;
API.addProfile(this.profile);
updateImg() {
let file = document.getElementById("avatar").files[0];
document.getElementById("avatar_preview").src = ev.target.result;
}
</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>
</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;
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
}
#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%;
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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>