Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(settings-profile): add functionality for updating about me #4598

Merged
merged 3 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/interactables/Input/Input.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{
'show-clear-button': showClearButton,
'is-danger': error || invalid,
transparent,
},
]"
:value="text"
Expand Down
12 changes: 12 additions & 0 deletions components/interactables/Input/Input.less
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
padding-right: 2rem;
}

&.transparent {
padding: 0;
border: none;
background: #fff0;
flex-grow: 1;

&:focus {
outline: none;
background: #fff0;
}
}

&:focus {
background-image: @semitransparent-lightest-gradient;
}
Expand Down
4 changes: 4 additions & 0 deletions components/interactables/Input/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export default Vue.extend({
type: String as PropType<InputType>,
default: 'button',
},
transparent: {
type: Boolean,
default: false,
},
},
computed: {
isEmpty(): boolean {
Expand Down
8 changes: 3 additions & 5 deletions components/ui/ContextMenu/ContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@
:class="{ danger: item.type === 'danger' }"
@click="(e) => handleAction(e, item.func)"
>
<TypographySubtitle
:text="item.text"
:size="6"
:class="{ danger: item.type === 'danger' }"
/>
<TypographyText :class="{ danger: item.type === 'danger' }">
{{ item.text }}
</TypographyText>
</button>
</template>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/views/navigation/sidebar/list/item/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<script lang="ts">
import Vue, { PropType } from 'vue'
import { mapGetters } from 'vuex'
josephmcg marked this conversation as resolved.
Show resolved Hide resolved
import { TranslateResult } from 'vue-i18n'
import VueMarkdown from 'vue-markdown'
import { mapGetters } from 'vuex'
import { toHTML } from '~/libraries/ui/Markdown'
import { ContextMenuItem } from '~/store/ui/types'
import iridium from '~/libraries/Iridium/IridiumManager'
Expand Down
1 change: 0 additions & 1 deletion components/views/navigation/sidebar/live/Live.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Vue from 'vue'
import { mapState } from 'vuex'
import { RadioIcon, XIcon } from 'satellite-lucide-icons'
import iridium from '~/libraries/Iridium/IridiumManager'
import { TrackKind } from '~/libraries/WebRTC/types'
import { GroupMemberDetails } from '~/libraries/Iridium/groups/types'
import Group from '~/libraries/Iridium/groups/Group'
import type { Friend, User } from '~/libraries/Iridium/friends/types'
Expand Down
6 changes: 4 additions & 2 deletions components/views/navigation/toolbar/Toolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
</template>
</div>
<div class="user-info">
<TypographyText as="h4" v-if="conversation">
<TypographyText class="header" as="h4" v-if="conversation">
{{ conversation.name }}
</TypographyText>
<TypographyText color="dark">{{ subtitleText }}</TypographyText>
<TypographyText class="header" color="dark">
{{ subtitleText }}
</TypographyText>
</div>
<div class="controls">
<button
Expand Down
4 changes: 4 additions & 0 deletions components/views/navigation/toolbar/Toolbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
margin-bottom: @normal-spacing;
flex-shrink: 0;

.header {
&:extend(.ellipsis);
}

.circle-container {
display: flex;
flex-shrink: 0;
Expand Down
89 changes: 47 additions & 42 deletions components/views/settings/pages/profile/Profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,47 +80,57 @@
>
<span>{{ $t('pages.settings.profile.remove_image') }}</span>
</button>
<div class="username">
<form
@submit="
(e) => updateUserDetail(e, 'name', inputs.name ?? '')
"
<form
class="editable-wrapper username"
@submit="
(e) => submitEdit(e, 'name')
"
>
<typography-text
v-if="!editing.has('name')"
class="username-label"
>
<InteractablesInput
v-model="inputs.name"
size="xs"
type="text"
:placeholder="
$t('user.registration.username_placeholder')
"
:loading="loading.has('status')"
button-type="submit"
>
<edit-icon size="1x" />
</InteractablesInput>
</form>
</div>
<div class="status-input">
<form
@submit="
{{ inputs.name }}
</typography-text>

<InteractablesInput
v-else
v-model="inputs.name"
class="username-input"
:placeholder="$t('user.registration.username_placeholder')"
autofocus
transparent
/>

<button
josephmcg marked this conversation as resolved.
Show resolved Hide resolved
class="edit-button"
:class="{active: editing.has('name')}"
type="submit"
>
{{ getEditButtonText('name') }}
</button>
</form>
<form
class="status-input"
@click="editing.add('status')"
@submit="
(e) =>
updateUserDetail(e, 'status', inputs.status ?? '')
"
>
<InteractablesInput
v-model="inputs.status"
size="xs"
type="text"
:placeholder="
>
<InteractablesInput
v-model="inputs.status"
size="xs"
type="text"
:placeholder="
$t('pages.settings.profile.status_placeholder')
"
:loading="loading.has('status')"
button-type="submit"
>
<edit-icon size="1x" />
</InteractablesInput>
</form>
</div>
:loading="loading.has('status')"
button-type="submit"
>
<edit-icon size="1x" />
</InteractablesInput>
</form>
<div v-if="profile && !!profile.status" class="status">
<TypographyText as="h6">
{{ $t('pages.settings.profile.current_status') }}
Expand All @@ -134,7 +144,7 @@

<div class="profile-section">
<!-- About Me -->
<form @submit="(e) => submitEdit(e)" @click="">
<form @submit="(e) => submitEdit(e, 'about')">
<div class="section-title">
<div class="title-wrapper">
<align-left-icon size="1.5x" class="section-icon" />
Expand All @@ -157,19 +167,14 @@
/>
</div>
<div
class="about-input-wrapper"
class="editable-wrapper"
:class="{'readonly': !editing.has('about')}"
>
<InteractablesEditable
v-model="inputs.about"
ref="editable"
:placeholder="$t('ui.talk')"
:enabled="editing.has('about')"
/>
<!-- :focus="editing.has('about')" -->
<!-- :class="{'has-command' : hasCommand}" -->
<!-- @keydown="handleInputKeydown" -->
<!-- @paste="handlePaste" -->
</div>
</div>
</form>
Expand Down
76 changes: 53 additions & 23 deletions components/views/settings/pages/profile/Profile.less
Original file line number Diff line number Diff line change
Expand Up @@ -223,38 +223,68 @@
margin-bottom: 0;
}
}
}

.about-input-wrapper {
display: flex;
align-items: flex-end;
gap: 0.5rem;
padding: 0 8px;
margin: 0 -8px;
position: relative;
border-radius: @corner-rounding;
border: 1px solid transparent;
background: linear-gradient(
0deg,
rgba(34, 44, 63, 0.5) 0%,
rgba(36, 40, 57, 0.5) 100%
);

&.readonly {
background: transparent;
}
.editable-wrapper {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0 8px;
margin: 0 -8px;
position: relative;
border-radius: @corner-rounding;
border: 1px solid transparent;
background: linear-gradient(
0deg,
rgba(34, 44, 63, 0.5) 0%,
rgba(36, 40, 57, 0.5) 100%
);

&.username,
&.readonly {
background: transparent;
}

.edit-button {
font-style: italic;
white-space: nowrap;
color: @text-muted;
&.username {
padding: 0;
margin: 0;
border: none;

.username-label {
flex-grow: 1;
&:extend(.ellipsis);
}

.edit-button {
padding: 8px;
opacity: 0;

&.active,
&:focus {
opacity: 1;
}
}

&:hover {
opacity: 0.8;
.edit-button {
opacity: 1;
cursor: pointer;
}
}
}
}

.edit-button {
font-style: italic;
white-space: nowrap;
color: @text-muted;
transition: @animation-speed-long ease-in-out;

&:hover {
opacity: 0.8;
}
}

.accounts-main {
display: flex;
flex-direction: column;
Expand Down
16 changes: 7 additions & 9 deletions components/views/settings/pages/profile/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default Vue.extend({
inputs: {
name: iridium.profile.state?.name ?? '',
photoHash: iridium.profile.state?.photoHash ?? '',
status: iridium.profile.state?.status ?? '',
status: '',
about: iridium.profile.state?.about ?? '',
accountUrl: '',
} as Partial<User>,
Expand Down Expand Up @@ -66,9 +66,6 @@ export default Vue.extend({
profile(): User | undefined {
return iridium.profile.state
},
aboutChanged(): boolean {
return this.inputs.about !== this.profile?.about
},
},
beforeDestroy() {
URL.revokeObjectURL(this.croppedImage)
Expand Down Expand Up @@ -170,14 +167,15 @@ export default Vue.extend({
* @description Updates input value
* @example this.submitEdit('name', 'John Doe')
*/
submitEdit(e: SubmitEvent) {
submitEdit(e: SubmitEvent, key: Editables) {
e.stopPropagation()
e.preventDefault()
const about = this.inputs.about || ''
if (this.editing.has('about') && this.aboutChanged) {
this.updateUserDetail(e, 'about', about)
const value = this.inputs[key] || ''
const valueChanged = this.profile?.[key] !== value
if (this.editing.has(key) && valueChanged) {
this.updateUserDetail(e, key, value)
}
this.toggleEditing('about')
this.toggleEditing(key)
},
/**
* @method getEditButtonText
Expand Down