forked from AkkomaGang/akkoma-fe
Separated tab-switcher into a reusable component. This depends on JSX addition
This commit is contained in:
parent
b4cc1e020b
commit
eacbd9b500
4 changed files with 215 additions and 126 deletions
44
src/components/tab_switcher/tab_switcher.jsx
Normal file
44
src/components/tab_switcher/tab_switcher.jsx
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
import Vue from 'vue'
|
||||||
|
|
||||||
|
import './tab_switcher.scss'
|
||||||
|
|
||||||
|
export default Vue.component('tab-switcher', {
|
||||||
|
name: 'TabSwitcher',
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
active: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
activateTab(index) {
|
||||||
|
return () => this.active = index;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render(h) {
|
||||||
|
const tabs = this.$slots.default
|
||||||
|
.filter(slot => slot.data)
|
||||||
|
.map((slot, index) => {
|
||||||
|
const classes = ['tab']
|
||||||
|
|
||||||
|
if (index === this.active) {
|
||||||
|
classes.push('active')
|
||||||
|
}
|
||||||
|
return (<button onClick={this.activateTab(index)} class={ classes.join(' ') }>{slot.data.attrs.title}</button>)
|
||||||
|
});
|
||||||
|
const contents = (
|
||||||
|
<div>
|
||||||
|
{this.$slots.default.filter(slot => slot.data)[this.active]}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<div class="tab-switcher">
|
||||||
|
<div class="tabs">
|
||||||
|
{tabs}
|
||||||
|
</div>
|
||||||
|
<div class="contents">
|
||||||
|
{contents}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
47
src/components/tab_switcher/tab_switcher.scss
Normal file
47
src/components/tab_switcher/tab_switcher.scss
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
|
.tab-switcher {
|
||||||
|
.tabs {
|
||||||
|
display: flex;
|
||||||
|
position: relative;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
padding-top: 5px;
|
||||||
|
|
||||||
|
&::after, &::before {
|
||||||
|
display: block;
|
||||||
|
content: '';
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab, &::after, &::before {
|
||||||
|
border-bottom: 1px solid;
|
||||||
|
border-bottom-color: $fallback--btn;
|
||||||
|
border-bottom-color: var(--btn, $fallback--btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab {
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
padding: .3em 1em;
|
||||||
|
|
||||||
|
&::-moz-focus-inner {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:not(.active) {
|
||||||
|
border-bottom: 1px solid;
|
||||||
|
border-bottom-color: $fallback--btn;
|
||||||
|
border-bottom-color: var(--btn, $fallback--btn);
|
||||||
|
z-index: 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background: transparent;
|
||||||
|
border-bottom: none;
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
import TabSwitcher from '../tab_switcher/tab_switcher.jsx'
|
||||||
import StyleSwitcher from '../style_switcher/style_switcher.vue'
|
import StyleSwitcher from '../style_switcher/style_switcher.vue'
|
||||||
|
|
||||||
const UserSettings = {
|
const UserSettings = {
|
||||||
|
@ -23,7 +24,8 @@ const UserSettings = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
StyleSwitcher
|
StyleSwitcher,
|
||||||
|
TabSwitcher
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
user () {
|
user () {
|
||||||
|
|
|
@ -4,126 +4,131 @@
|
||||||
{{$t('settings.user_settings')}}
|
{{$t('settings.user_settings')}}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body profile-edit">
|
<div class="panel-body profile-edit">
|
||||||
<div class="tab-switcher">
|
<tab-switcher>
|
||||||
<button class="btn btn-default" @click="activateTab('profile')">{{$t('settings.profile_tab')}}</button>
|
<div :title="$t('settings.profile_tab')">
|
||||||
<button class="btn btn-default" @click="activateTab('security')">{{$t('settings.security_tab')}}</button>
|
<div class="setting-item" >
|
||||||
<button class="btn btn-default" @click="activateTab('data_import_export')" v-if="pleromaBackend">{{$t('settings.data_import_export_tab')}}</button>
|
<h2>{{$t('settings.name_bio')}}</h2>
|
||||||
</div>
|
<p>{{$t('settings.name')}}</p>
|
||||||
<div class="setting-item" v-if="activeTab == 'profile'">
|
<input class='name-changer' id='username' v-model="newname"></input>
|
||||||
<h2>{{$t('settings.name_bio')}}</h2>
|
<p>{{$t('settings.bio')}}</p>
|
||||||
<p>{{$t('settings.name')}}</p>
|
<textarea class="bio" v-model="newbio"></textarea>
|
||||||
<input class='name-changer' id='username' v-model="newname"></input>
|
<p>
|
||||||
<p>{{$t('settings.bio')}}</p>
|
<input type="checkbox" v-model="newlocked" id="account-locked">
|
||||||
<textarea class="bio" v-model="newbio"></textarea>
|
<label for="account-locked">{{$t('settings.lock_account_description')}}</label>
|
||||||
<p>
|
</p>
|
||||||
<input type="checkbox" v-model="newlocked" id="account-locked">
|
<div v-if="scopeOptionsEnabled">
|
||||||
<label for="account-locked">{{$t('settings.lock_account_description')}}</label>
|
<label for="default-vis">{{$t('settings.default_vis')}}</label>
|
||||||
</p>
|
<div id="default-vis" class="visibility-tray">
|
||||||
<div v-if="scopeOptionsEnabled">
|
<i v-on:click="changeVis('direct')" class="icon-mail-alt" :class="vis.direct"></i>
|
||||||
<label for="default-vis">{{$t('settings.default_vis')}}</label>
|
<i v-on:click="changeVis('private')" class="icon-lock" :class="vis.private"></i>
|
||||||
<div id="default-vis" class="visibility-tray">
|
<i v-on:click="changeVis('unlisted')" class="icon-lock-open-alt" :class="vis.unlisted"></i>
|
||||||
<i v-on:click="changeVis('direct')" class="icon-mail-alt" :class="vis.direct"></i>
|
<i v-on:click="changeVis('public')" class="icon-globe" :class="vis.public"></i>
|
||||||
<i v-on:click="changeVis('private')" class="icon-lock" :class="vis.private"></i>
|
</div>
|
||||||
<i v-on:click="changeVis('unlisted')" class="icon-lock-open-alt" :class="vis.unlisted"></i>
|
</div>
|
||||||
<i v-on:click="changeVis('public')" class="icon-globe" :class="vis.public"></i>
|
<button :disabled='newname.length <= 0' class="btn btn-default" @click="updateProfile">{{$t('general.submit')}}</button>
|
||||||
|
</div>
|
||||||
|
<div class="setting-item">
|
||||||
|
<h2>{{$t('settings.avatar')}}</h2>
|
||||||
|
<p>{{$t('settings.current_avatar')}}</p>
|
||||||
|
<img :src="user.profile_image_url_original" class="old-avatar"></img>
|
||||||
|
<p>{{$t('settings.set_new_avatar')}}</p>
|
||||||
|
<img class="new-avatar" v-bind:src="previews[0]" v-if="previews[0]">
|
||||||
|
</img>
|
||||||
|
<div>
|
||||||
|
<input type="file" @change="uploadFile(0, $event)" ></input>
|
||||||
|
</div>
|
||||||
|
<i class="icon-spin4 animate-spin" v-if="uploading[0]"></i>
|
||||||
|
<button class="btn btn-default" v-else-if="previews[0]" @click="submitAvatar">{{$t('general.submit')}}</button>
|
||||||
|
</div>
|
||||||
|
<div class="setting-item">
|
||||||
|
<h2>{{$t('settings.profile_banner')}}</h2>
|
||||||
|
<p>{{$t('settings.current_profile_banner')}}</p>
|
||||||
|
<img :src="user.cover_photo" class="banner"></img>
|
||||||
|
<p>{{$t('settings.set_new_profile_banner')}}</p>
|
||||||
|
<img class="banner" v-bind:src="previews[1]" v-if="previews[1]">
|
||||||
|
</img>
|
||||||
|
<div>
|
||||||
|
<input type="file" @change="uploadFile(1, $event)" ></input>
|
||||||
|
</div>
|
||||||
|
<i class=" icon-spin4 animate-spin uploading" v-if="uploading[1]"></i>
|
||||||
|
<button class="btn btn-default" v-else-if="previews[1]" @click="submitBanner">{{$t('general.submit')}}</button>
|
||||||
|
</div>
|
||||||
|
<div class="setting-item">
|
||||||
|
<h2>{{$t('settings.profile_background')}}</h2>
|
||||||
|
<p>{{$t('settings.set_new_profile_background')}}</p>
|
||||||
|
<img class="bg" v-bind:src="previews[2]" v-if="previews[2]">
|
||||||
|
</img>
|
||||||
|
<div>
|
||||||
|
<input type="file" @change="uploadFile(2, $event)" ></input>
|
||||||
|
</div>
|
||||||
|
<i class=" icon-spin4 animate-spin uploading" v-if="uploading[2]"></i>
|
||||||
|
<button class="btn btn-default" v-else-if="previews[2]" @click="submitBg">{{$t('general.submit')}}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button :disabled='newname.length <= 0' class="btn btn-default" @click="updateProfile">{{$t('general.submit')}}</button>
|
|
||||||
</div>
|
<div :title="$t('settings.security_tab')">
|
||||||
<div class="setting-item" v-if="activeTab == 'profile'">
|
<div class="setting-item">
|
||||||
<h2>{{$t('settings.avatar')}}</h2>
|
<h2>{{$t('settings.change_password')}}</h2>
|
||||||
<p>{{$t('settings.current_avatar')}}</p>
|
<div>
|
||||||
<img :src="user.profile_image_url_original" class="old-avatar"></img>
|
<p>{{$t('settings.current_password')}}</p>
|
||||||
<p>{{$t('settings.set_new_avatar')}}</p>
|
<input type="password" v-model="changePasswordInputs[0]">
|
||||||
<img class="new-avatar" v-bind:src="previews[0]" v-if="previews[0]">
|
</div>
|
||||||
</img>
|
<div>
|
||||||
<div>
|
<p>{{$t('settings.new_password')}}</p>
|
||||||
<input type="file" @change="uploadFile(0, $event)" ></input>
|
<input type="password" v-model="changePasswordInputs[1]">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>{{$t('settings.confirm_new_password')}}</p>
|
||||||
|
<input type="password" v-model="changePasswordInputs[2]">
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-default" @click="changePassword">{{$t('general.submit')}}</button>
|
||||||
|
<p v-if="changedPassword">{{$t('settings.changed_password')}}</p>
|
||||||
|
<p v-else-if="changePasswordError !== false">{{$t('settings.change_password_error')}}</p>
|
||||||
|
<p v-if="changePasswordError">{{changePasswordError}}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<h2>{{$t('settings.delete_account')}}</h2>
|
||||||
|
<p v-if="!deletingAccount">{{$t('settings.delete_account_description')}}</p>
|
||||||
|
<div v-if="deletingAccount">
|
||||||
|
<p>{{$t('settings.delete_account_instructions')}}</p>
|
||||||
|
<p>{{$t('login.password')}}</p>
|
||||||
|
<input type="password" v-model="deleteAccountConfirmPasswordInput">
|
||||||
|
<button class="btn btn-default" @click="deleteAccount">{{$t('settings.delete_account')}}</button>
|
||||||
|
</div>
|
||||||
|
<p v-if="deleteAccountError !== false">{{$t('settings.delete_account_error')}}</p>
|
||||||
|
<p v-if="deleteAccountError">{{deleteAccountError}}</p>
|
||||||
|
<button class="btn btn-default" v-if="!deletingAccount" @click="confirmDelete">{{$t('general.submit')}}</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<i class="icon-spin4 animate-spin" v-if="uploading[0]"></i>
|
|
||||||
<button class="btn btn-default" v-else-if="previews[0]" @click="submitAvatar">{{$t('general.submit')}}</button>
|
<div :title="$t('settings.data_import_export_tab')" v-if="pleromaBackend">
|
||||||
</div>
|
<div class="setting-item">
|
||||||
<div class="setting-item" v-if="activeTab == 'profile'">
|
<h2>{{$t('settings.follow_import')}}</h2>
|
||||||
<h2>{{$t('settings.profile_banner')}}</h2>
|
<p>{{$t('settings.import_followers_from_a_csv_file')}}</p>
|
||||||
<p>{{$t('settings.current_profile_banner')}}</p>
|
<form v-model="followImportForm">
|
||||||
<img :src="user.cover_photo" class="banner"></img>
|
<input type="file" ref="followlist" v-on:change="followListChange"></input>
|
||||||
<p>{{$t('settings.set_new_profile_banner')}}</p>
|
</form>
|
||||||
<img class="banner" v-bind:src="previews[1]" v-if="previews[1]">
|
<i class=" icon-spin4 animate-spin uploading" v-if="uploading[3]"></i>
|
||||||
</img>
|
<button class="btn btn-default" v-else @click="importFollows">{{$t('general.submit')}}</button>
|
||||||
<div>
|
<div v-if="followsImported">
|
||||||
<input type="file" @change="uploadFile(1, $event)" ></input>
|
<i class="icon-cross" @click="dismissImported"></i>
|
||||||
|
<p>{{$t('settings.follows_imported')}}</p>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="followImportError">
|
||||||
|
<i class="icon-cross" @click="dismissImported"></i>
|
||||||
|
<p>{{$t('settings.follow_import_error')}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting-item" v-if="enableFollowsExport">
|
||||||
|
<h2>{{$t('settings.follow_export')}}</h2>
|
||||||
|
<button class="btn btn-default" @click="exportFollows">{{$t('settings.follow_export_button')}}</button>
|
||||||
|
</div>
|
||||||
|
<div class="setting-item" v-else>
|
||||||
|
<h2>{{$t('settings.follow_export_processing')}}</h2>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<i class=" icon-spin4 animate-spin uploading" v-if="uploading[1]"></i>
|
</tab-switcher>
|
||||||
<button class="btn btn-default" v-else-if="previews[1]" @click="submitBanner">{{$t('general.submit')}}</button>
|
|
||||||
</div>
|
|
||||||
<div class="setting-item" v-if="activeTab == 'profile'">
|
|
||||||
<h2>{{$t('settings.profile_background')}}</h2>
|
|
||||||
<p>{{$t('settings.set_new_profile_background')}}</p>
|
|
||||||
<img class="bg" v-bind:src="previews[2]" v-if="previews[2]">
|
|
||||||
</img>
|
|
||||||
<div>
|
|
||||||
<input type="file" @change="uploadFile(2, $event)" ></input>
|
|
||||||
</div>
|
|
||||||
<i class=" icon-spin4 animate-spin uploading" v-if="uploading[2]"></i>
|
|
||||||
<button class="btn btn-default" v-else-if="previews[2]" @click="submitBg">{{$t('general.submit')}}</button>
|
|
||||||
</div>
|
|
||||||
<div class="setting-item" v-if="activeTab == 'security'">
|
|
||||||
<h2>{{$t('settings.change_password')}}</h2>
|
|
||||||
<div>
|
|
||||||
<p>{{$t('settings.current_password')}}</p>
|
|
||||||
<input type="password" v-model="changePasswordInputs[0]">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<p>{{$t('settings.new_password')}}</p>
|
|
||||||
<input type="password" v-model="changePasswordInputs[1]">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<p>{{$t('settings.confirm_new_password')}}</p>
|
|
||||||
<input type="password" v-model="changePasswordInputs[2]">
|
|
||||||
</div>
|
|
||||||
<button class="btn btn-default" @click="changePassword">{{$t('general.submit')}}</button>
|
|
||||||
<p v-if="changedPassword">{{$t('settings.changed_password')}}</p>
|
|
||||||
<p v-else-if="changePasswordError !== false">{{$t('settings.change_password_error')}}</p>
|
|
||||||
<p v-if="changePasswordError">{{changePasswordError}}</p>
|
|
||||||
</div>
|
|
||||||
<div class="setting-item" v-if="pleromaBackend && activeTab == 'data_import_export'">
|
|
||||||
<h2>{{$t('settings.follow_import')}}</h2>
|
|
||||||
<p>{{$t('settings.import_followers_from_a_csv_file')}}</p>
|
|
||||||
<form v-model="followImportForm">
|
|
||||||
<input type="file" ref="followlist" v-on:change="followListChange"></input>
|
|
||||||
</form>
|
|
||||||
<i class=" icon-spin4 animate-spin uploading" v-if="uploading[3]"></i>
|
|
||||||
<button class="btn btn-default" v-else @click="importFollows">{{$t('general.submit')}}</button>
|
|
||||||
<div v-if="followsImported">
|
|
||||||
<i class="icon-cross" @click="dismissImported"></i>
|
|
||||||
<p>{{$t('settings.follows_imported')}}</p>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="followImportError">
|
|
||||||
<i class="icon-cross" @click="dismissImported"></i>
|
|
||||||
<p>{{$t('settings.follow_import_error')}}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="setting-item" v-if="enableFollowsExport && activeTab == 'data_import_export'">
|
|
||||||
<h2>{{$t('settings.follow_export')}}</h2>
|
|
||||||
<button class="btn btn-default" @click="exportFollows">{{$t('settings.follow_export_button')}}</button>
|
|
||||||
</div>
|
|
||||||
<div class="setting-item" v-else-if="activeTab == 'data_import_export'">
|
|
||||||
<h2>{{$t('settings.follow_export_processing')}}</h2>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
<div class="setting-item" v-if="activeTab == 'security'">
|
|
||||||
<h2>{{$t('settings.delete_account')}}</h2>
|
|
||||||
<p v-if="!deletingAccount">{{$t('settings.delete_account_description')}}</p>
|
|
||||||
<div v-if="deletingAccount">
|
|
||||||
<p>{{$t('settings.delete_account_instructions')}}</p>
|
|
||||||
<p>{{$t('login.password')}}</p>
|
|
||||||
<input type="password" v-model="deleteAccountConfirmPasswordInput">
|
|
||||||
<button class="btn btn-default" @click="deleteAccount">{{$t('settings.delete_account')}}</button>
|
|
||||||
</div>
|
|
||||||
<p v-if="deleteAccountError !== false">{{$t('settings.delete_account_error')}}</p>
|
|
||||||
<p v-if="deleteAccountError">{{deleteAccountError}}</p>
|
|
||||||
<button class="btn btn-default" v-if="!deletingAccount" @click="confirmDelete">{{$t('general.submit')}}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -151,13 +156,4 @@
|
||||||
margin: 0.25em;
|
margin: 0.25em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-switcher {
|
|
||||||
margin: 7px 7px;
|
|
||||||
display: inline-block;
|
|
||||||
|
|
||||||
button {
|
|
||||||
height: 30px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue