Skip to content

Commit

Permalink
feat: add dropdown to profile and log out
Browse files Browse the repository at this point in the history
  • Loading branch information
vertocode committed Oct 12, 2023
1 parent 7121a3e commit 9fb21e1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/components/Modal/BaseModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const socials = [
.base-modal-footer {
padding: 1rem;
background-color: #f8f8f8;
color: black;
display: flex;
justify-content: center;
align-items: center;
Expand Down
3 changes: 2 additions & 1 deletion src/components/Modal/EditProfileModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<base-button
v-if="!saveChangesDisabled"
class="m-auto mt-3"
:loading="true"
:loading="state.isLoading"
:disabled="saveChangesDisabled"
action="Save Changes"
@click="saveChanges"
Expand Down Expand Up @@ -127,6 +127,7 @@ const saveChanges = async () => {
<style lang="scss">
.edit-profile-modal {
position: absolute;
main {
display: flex;
justify-content: center;
Expand Down
5 changes: 1 addition & 4 deletions src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
<img src="../assets/login-icon.webp" alt="">
</div>
</div>
<edit-profile-modal
v-if="state.showEditProfileModal"
@close="state.showEditProfileModal = false"
></edit-profile-modal>

</template>

<script setup>
Expand Down
8 changes: 1 addition & 7 deletions src/components/Navbar/Hamburguer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<div class="bar"></div>
</div>
<ul class="menu" :class="{ show: state.isMenuOpen }" @click="state.isMenuOpen = false">
<li
v-if="userStore.userData.name"
:class="{ active: state.showEditProfileModal }"
@click="emit('showEditProfile')"
>Profile</li>
<li
v-for="{ title, link, isVisible, leftIcon, rightIcon } in steps"
:key="title"
Expand Down Expand Up @@ -49,8 +44,7 @@ const selectItem = (link) => {
}
const state = reactive({
isMenuOpen: false,
showEditProfileModal: false
isMenuOpen: false
})
const toggleMenu = () => {
Expand Down
37 changes: 27 additions & 10 deletions src/components/Profile/ProfileDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,39 @@
<img
:src="userData.picture"
alt="img-profile"

>
<i class="fa fa-th-large"></i>
<i class="fa fa-caret-down"></i>
</div>

<div class="profile-menu" v-if="showMenu">
<ul>
<li>Profile</li>
<li @click="showEditProfile = true">Profile</li>
<li>Settings</li>
<li>Log out</li>
<li @click="userStore.logout()">Log out</li>
</ul>
</div>
</div>
<EditProfileModal
v-if="showEditProfile"
@close="showEditProfile = false"
/>
</template>

<script setup lang="ts">
import { NormalUser } from '../../typing/User'
import { ref } from 'vue'
import { useUserStore } from '../../store/useUserStore'
import EditProfileModal from '../Modal/EditProfileModal.vue'
const userStore = useUserStore()
interface Props {
userData: NormalUser
}
defineProps<Props>()
const showMenu = ref(false)
const showEditProfile = ref(false)
</script>

<style lang="scss">
Expand All @@ -55,29 +63,38 @@ const showMenu = ref(false)
}
.profile-image {
position: relative;
cursor: pointer;
i {
width: 2em;
height: 2em;
height: 1em;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
right: 7%;
bottom: 20%;
background-color: rgba(0, 0, 0, 0.28);
right: 30%;
bottom: -5%;
background-color: gray;
z-index: 1;
}
img {
width: 70px;
height: 70px;
border-radius: 50%;
}
@media (max-width: 500px) {
@media (max-width: 500px) {
img {
width: 50px;
height: 50px;
}
i {
right: 20%;
bottom: -15%;
}
}
}
Expand All @@ -88,7 +105,7 @@ const showMenu = ref(false)
background-color: rgba(255, 255, 255, 0.95);
color: black;
position: absolute;
top: 80%;
top: 115%;
left: 0;
ul {
Expand Down

1 comment on commit 9fb21e1

@vercel
Copy link

@vercel vercel bot commented on 9fb21e1 Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.