Skip to content

Commit

Permalink
feat(ui): clicking on the user status avatar or user quickProfile ava…
Browse files Browse the repository at this point in the history
…tar shows profile modal
  • Loading branch information
Samir Vimercati committed Feb 3, 2022
1 parent fa1a15a commit 0f07c88
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 18 deletions.
14 changes: 8 additions & 6 deletions components/interactables/QuickProfile/QuickProfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
<InteractablesClose :action="close" />
</div>
<div class="header">
<UiCircle
:type="src ? 'image' : 'random'"
:seed="user.address"
:size="45"
:source="src"
/>
<div class="avatar-wrapper" @click="openProfile">
<UiCircle
:type="src ? 'image' : 'random'"
:seed="user.address"
:size="45"
:source="src"
/>
</div>
</div>
<TypographyTitle :text="user.name" :size="6" />
<TypographyText
Expand Down
4 changes: 4 additions & 0 deletions components/interactables/QuickProfile/QuickProfile.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
height: 3rem;
margin: -@normal-spacing -@normal-spacing calc(@normal-spacing + 20px) -@normal-spacing;
position: relative;

.avatar-wrapper {
cursor: pointer;
}
}
.action {
position: absolute;
Expand Down
18 changes: 18 additions & 0 deletions components/interactables/QuickProfile/QuickProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,24 @@ export default Vue.extend({
})
this.close()
},
openProfile() {
if (this.user) {
const isMe = this.user.address === this.$store.state.accounts.active
if (isMe) {
this.$store.commit('ui/toggleSettings', {
show: true,
defaultRoute: 'profile',
})
} else {
this.$store.commit('ui/toggleModal', {
name: 'userProfile',
state: true,
})
this.$store.commit('ui/setUserProfile', this.user)
}
}
},
},
})
</script>
Expand Down
2 changes: 1 addition & 1 deletion components/views/navigation/mobile/nav/Nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div :class="`${$route.path.includes('/settings') ? 'active' : ''}`">
<settings-icon
size="1x"
v-on:click="$store.commit('ui/toggleSettings', true)"
v-on:click="$store.commit('ui/toggleSettings', { show: true })"
/>
</div>
</div>
10 changes: 6 additions & 4 deletions components/views/navigation/sidebar/status/Status.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<div id="status">
<UiUserState
:user="{address: accounts.active, state: accounts.details.state}"
:src="src"
/>
<div @click="openProfile">
<UiUserState
:user="{address: accounts.active, state: accounts.details.state}"
:src="src"
/>
</div>
<div
class="user-info has-tooltip has-tooltip-top has-tooltip-primary"
v-on:click="$toast.show($t('ui.copied'))"
Expand Down
1 change: 1 addition & 0 deletions components/views/navigation/sidebar/status/Status.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#status {
display: flex;
cursor: pointer;

.circle {
align-self: center;
Expand Down
8 changes: 8 additions & 0 deletions components/views/navigation/sidebar/status/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export default Vue.extend({
return hash ? `${this.$Config.textile.browser}/ipfs/${hash}` : ''
},
},
methods: {
openProfile() {
this.$store.commit('ui/toggleSettings', {
show: true,
defaultRoute: 'profile',
})
},
},
})
</script>

Expand Down
2 changes: 1 addition & 1 deletion components/views/navigation/slimbar/Slimbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<div
class="circle-group has-tooltip-right has-tooltip-primary"
:data-tooltip="$t('pages.settings.settings')"
v-on:click="$store.commit('ui/toggleSettings', true)"
v-on:click="$store.commit('ui/toggleSettings', { show: true })"
>
<UiCircle type="icon" :size="40">
<settings-icon size="0.75x" />
Expand Down
2 changes: 1 addition & 1 deletion components/views/settings/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default Vue.extend({
},
data() {
return {
route: 'personalize',
route: this.$store.state.ui.settingsDefaultRoute,
sidebarLayout: [
{
title: 'General',
Expand Down
6 changes: 3 additions & 3 deletions components/views/settings/modal/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export default Vue.extend({
},
data() {
return {
page: 'personalize',
page: this.$store.state.ui.settingsDefaultRoute,
settingSwiperOption: {
initialSlide: 0,
resistanceRatio: 0,
slidesPerView: 'auto',
noSwiping: !this.$device.isMobile,
allowTouchMove: !!this.$device.isMobile,
allowTouchMove: this.$device.isMobile,
},
}
},
Expand Down Expand Up @@ -76,7 +76,7 @@ export default Vue.extend({
* @example
*/
closeModal() {
this.$store.commit('ui/toggleSettings', false)
this.$store.commit('ui/toggleSettings', { show: false })
},
},
})
Expand Down
1 change: 1 addition & 0 deletions store/ui/__snapshots__/state.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Object {
"messageID": null,
"status": false,
},
"settingsDefaultRoute": "personalize",
"settingsSideBar": true,
"showPinned": false,
"showSearchResult": false,
Expand Down
2 changes: 1 addition & 1 deletion store/ui/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default {
* @example Mousetrap.bind('ctrl+s', dispatch('audio/toggleMute') )
*/
openSettings({ commit, state }: any) {
commit('toggleSettings', !state.showSettings)
commit('toggleSettings', { show: !state.showSettings })
},
/**
* @method activateKeybinds
Expand Down
8 changes: 7 additions & 1 deletion store/ui/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ export default {
route: options.route || 'emotes',
}
},
toggleSettings(state: UIState, show: boolean) {
toggleSettings(
state: UIState,
options: { show: boolean; defaultRoute?: string },
) {
const { show, defaultRoute } = options

state.showSettings = show
state.settingsDefaultRoute = defaultRoute || 'personalize'
},
toggleSettingsSidebar(state: UIState, show: boolean) {
state.settingsSideBar = show
Expand Down
1 change: 1 addition & 0 deletions store/ui/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const InitialUIState = (): UIState => ({
showSearchResult: false,
showSettings: false,
settingsSideBar: true,
settingsDefaultRoute: 'personalize',
quickProfile: false,
userProfile: {},
contextMenuValues: [],
Expand Down
1 change: 1 addition & 0 deletions store/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export interface UIState {
quickProfilePosition: object
showSettings: boolean
settingsSideBar: boolean
settingsDefaultRoute: string
showSidebarUsers: boolean
showSearchResult: boolean
showSidebar: boolean
Expand Down

0 comments on commit 0f07c88

Please sign in to comment.