-
Notifications
You must be signed in to change notification settings - Fork 0
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
ユーザーセッティング画面実装 #80
base: main
Are you sure you want to change the base?
ユーザーセッティング画面実装 #80
Changes from all commits
317d19b
c7a2ea8
e588edb
8102cb3
e548c42
a0cf8ad
cd83243
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
<template> | ||
<div> | ||
<h1>Settings</h1> | ||
<RouterView /> | ||
</div> | ||
</template> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,170 @@ | ||
<script setup lang="ts"></script> | ||
<script setup lang="ts"> | ||
import { ref, onMounted } from 'vue'; | ||
import { useRouter } from 'vue-router'; | ||
const router = useRouter(); | ||
const selectedItem = ref<string>(window.location.pathname.split('/').pop() || 'account'); | ||
function selectItem(item: string) { | ||
selectedItem.value = item; | ||
router.push(`/settings/${item}`); | ||
} | ||
Comment on lines
+8
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. これでも全く問題ないのですが,tOJ-frontの他のコードでは https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Functions/Arrow_functions |
||
onMounted(() => { | ||
window.addEventListener('popstate', () => { | ||
selectedItem.value = window.location.pathname.split('/').pop() || 'account'; | ||
}); | ||
}); | ||
const username = ref<string>(''); | ||
const email = ref<string>(''); | ||
const currentPassword = ref<string>(''); | ||
const newPassword = ref<string>(''); | ||
const confirmPassword = ref<string>(''); | ||
interface Service { | ||
name: string; | ||
linked: boolean; | ||
ID: string; | ||
icon: string; | ||
} | ||
import GitHubIcon from '@/assets/service_icons/github.svg'; | ||
import GoogleIcon from '@/assets/service_icons/google.svg'; | ||
import traQIcon from '@/assets/service_icons/traq.svg'; | ||
import checkIcon from '@/assets/status_icons/check.svg'; | ||
import profileIcon from '@/assets/status_icons/profile.svg'; | ||
import accountIcon from '@/assets/status_icons/account.svg'; | ||
Comment on lines
+32
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. importは先頭にまとめてしまった方が読みやすいと思います |
||
const services = ref<Service[]>([ | ||
{ name: 'GitHub', linked: false, ID: '', icon: GitHubIcon }, | ||
{ name: 'Google', linked: false, ID: '', icon: GoogleIcon }, | ||
{ name: 'traQ', linked: false, ID: '@test_user', icon: traQIcon }, | ||
]); | ||
Comment on lines
+40
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここの値のlinkedについては,ページのマウント時に 参照; https://github.com/traP-jp/traO-Judge-docs/blob/develop/api/backend/frontend-backend.yaml |
||
function toggleLink(service: Service) { | ||
service.linked = !service.linked; | ||
console.log(`TODO: ${service.name} との連携を${service.linked ? '開始' : '解除'}する`); | ||
} | ||
function changeUsername() { | ||
console.log('TODO: ユーザー名の変更を反映する'); | ||
} | ||
function changeEmail() { | ||
console.log('TODO: メールアドレスの変更を反映する'); | ||
} | ||
function changePassword() { | ||
console.log('TODO: パスワードの変更を反映する'); | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<h2>Settings Account</h2> | ||
<div class="flex gap-12 px-6 py-8" style="font-family: 'Open Sans', 'Noto Sans', sans-serif;"> | ||
<aside class="gap-3 p-3" style="min-width: 250px;"> | ||
<h2 class="h-10 pb-3 text-xl font-medium">設定</h2> | ||
<ul> | ||
<li class="mb-3"> | ||
<a | ||
href="/settings/account" | ||
class="flex rounded px-4 py-1" | ||
style="font-weight: 500; background-color: #FFE5E5; color: #8E3535; gap: 5px;" | ||
@click.prevent="selectItem('account')" | ||
> | ||
<img :src="accountIcon" alt="" width="20" height="20" /> | ||
<p>アカウント</p> | ||
</a> | ||
</li> | ||
<li class="mb-3"> | ||
<a | ||
href="/settings/profile" | ||
class="flex rounded px-4 py-1" | ||
style="font-weight: 500; background-color: white; color: #5F5F5F; gap: 5px;" | ||
@click.prevent="selectItem('profile')" | ||
> | ||
<img :src="profileIcon" alt="" width="20" height="20" style="filter: invert(33%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(85%);" /> | ||
<p>プロフィール</p> | ||
</a> | ||
</li> | ||
</ul> | ||
</aside> | ||
<div class="flex flex-col gap-6 p-3" style="width: 800px;"> | ||
Comment on lines
+66
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. これは僕が周知していなかったのが悪い部分も大きいのですが,ページ左側のメニュー/ボタン/フォームなど多くのページで共通に使われることがわかっているものはすでにコンポーネントとして |
||
<div class="flex flex-col gap-3 pb-3"> | ||
<h2 class="h-9 border-b-2 pb-2 text-xl font-medium" style="border-color: #D8D8D8B2;">基本情報</h2> | ||
<div class="flex-col"> | ||
<label class="text-sm font-medium" for="username">ユーザー名</label> | ||
<div class="flex items-center gap-2"> | ||
<input id="username" v-model="username" type="text" class="h-8 w-48 rounded border" style="border-color: #D8D8D8; padding-left: 10px; color: #3A3A3A;" /> | ||
<button class="h-10 w-20 rounded-lg" style="background-color: #AC004B; color: white;" @click="changeUsername">変更</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
</div> | ||
<div class="flex-col"> | ||
<label class="text-sm font-medium" for="email">メールアドレス</label> | ||
<div class="flex items-center gap-2"> | ||
<input id="email" v-model="email" type="email" class="h-8 w-96 rounded border" style="border-color: #D8D8D8; padding-left: 10px; color: #3A3A3A;" /> | ||
<button class="h-10 w-20 rounded-lg" style="background-color: #AC004B; color: white;" @click="changeEmail">変更</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
</div> | ||
</div> | ||
<div class="flex flex-col gap-3 pb-3"> | ||
<h2 class="h-9 border-b-2 pb-2 text-xl font-medium" style="border-color: #D8D8D8B2;">パスワードの変更</h2> | ||
<div class="flex flex-col gap-2"> | ||
<div class="flex-col"> | ||
<label class="text-sm font-medium" for="current-password">現在のパスワード</label> | ||
<div class="flex items-center "> | ||
<input id="current-password" v-model="currentPassword" type="password" class="h-8 w-72 rounded border" style="border-color: #D8D8D8; padding-left: 10px; color: #3A3A3A;" /> | ||
</div> | ||
</div> | ||
<div class="flex-col"> | ||
<label class="text-sm font-medium" for="new-password">新しいパスワード</label> | ||
<div class="flex items-center "> | ||
<input id="new-password" v-model="newPassword" type="password" class="h-8 w-72 rounded border" style="border-color: #D8D8D8; padding-left: 10px; color: #3A3A3A;" /> | ||
</div> | ||
</div> | ||
<div class="flex-col"> | ||
<label class="text-sm font-medium" for="confirm-password">新しいパスワード (確認)</label> | ||
<div class="flex items-center "> | ||
<input id="confirm-password" v-model="confirmPassword" type="password" class="h-8 w-72 rounded border" style="border-color: #D8D8D8; padding-left: 10px; color: #3A3A3A;" /> | ||
</div> | ||
</div> | ||
<div> | ||
<button class="h-10 w-20 rounded-lg" style="background-color: #AC004B; color: white;" @click="changePassword"> | ||
変更 | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
Comment on lines
+112
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<div class="flex flex-col gap-3 pb-3"> | ||
<h2 class="h-9 border-b-2 pb-2 text-xl font-medium" style="border-color: #D8D8D8B2;">外部サービスとの連携</h2> | ||
<div> | ||
<div v-for="service in services" :key="service.name" class="flex-col border-b-2" style="border-color: #D8D8D8B2;"> | ||
<div class="flex h-12 items-center gap-2.5"> | ||
<div class="flex items-center gap-2"> | ||
<img :src="service.icon" alt="" width="20" height="20" /> | ||
<label class="w-32"> | ||
{{ service.name }} | ||
</label> | ||
</div> | ||
<span :style="[service.linked ? 'color: #16B179;' : 'color: #5F5F5F;']" class="flex w-32 gap-1"> | ||
{{ service.linked ? '連携済' : '未連携' }} | ||
<img v-if="service.linked" :src="checkIcon" alt="" width="16" height="16" /> | ||
</span> | ||
<span class="h-12 min-w-72 content-around text-base font-normal" style="color: #5F5F5F;"> | ||
{{ service.ID }} | ||
</span> | ||
<button class="mr-10 h-8 rounded border px-4 py-1 text-sm" style="border-color: #D8D8D8; color: #5F5F5F;" @click="toggleLink(service)"> | ||
{{ service.linked ? '連携解除' : '連携' }} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> | ||
<style scoped> | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,77 @@ | ||
<script setup lang="ts"></script> | ||
<script setup lang="ts"> | ||
import { ref, onMounted } from 'vue'; | ||
import { useRouter } from 'vue-router'; | ||
|
||
const router = useRouter(); | ||
const selectedItem = ref<string>(window.location.pathname.split('/').pop() || 'profile'); | ||
|
||
function selectItem(item: string) { | ||
selectedItem.value = item; | ||
router.push(`/settings/${item}`); | ||
} | ||
|
||
onMounted(() => { | ||
window.addEventListener('popstate', () => { | ||
selectedItem.value = window.location.pathname.split('/').pop() || 'profile'; | ||
}); | ||
}); | ||
|
||
const words = ref<string>(''); | ||
|
||
function changeWords() { | ||
console.log('TODO: ひとことの変更を反映する'); | ||
} | ||
|
||
import profileIcon from '@/assets/status_icons/profile.svg'; | ||
import accountIcon from '@/assets/status_icons/account.svg'; | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<h2>Settings Profile</h2> | ||
<div class="flex gap-12 px-6 py-8" style="font-family: 'Open Sans', 'Noto Sans', sans-serif;"> | ||
<aside class="gap-3 p-3" style="min-width: 250px;"> | ||
<h2 class="pb-3 text-xl font-medium">設定</h2> | ||
<ul> | ||
<li class="mb-3"> | ||
<a | ||
href="/settings/account" | ||
class="flex rounded px-4 py-1" | ||
style="font-weight: 500; background-color: white; color: #5F5F5F; gap: 5px;" | ||
@click.prevent="selectItem('account')" | ||
> | ||
<img :src="accountIcon" alt="" width="20" height="20" style="filter: invert(33%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(85%);" /> | ||
<p>アカウント</p> | ||
</a> | ||
</li> | ||
<li class="mb-3"> | ||
<a | ||
href="/settings/profile" | ||
class="flex rounded px-4 py-1" | ||
style="font-weight: 500; background-color: #FFE5E5; color: #8E3535; gap: 5px;" | ||
@click.prevent="selectItem('profile')" | ||
> | ||
<img :src="profileIcon" alt="" width="20" height="20" /> | ||
<p>プロフィール</p> | ||
</a> | ||
</li> | ||
</ul> | ||
</aside> | ||
<div class="flex flex-col gap-3 p-3" style="width: 800px;"> | ||
<h2 class="h-9 border-b-2 pb-2 text-xl font-medium" style="border-color: #D8D8D8B2;">プロフィール</h2> | ||
<div class="mb-3 flex-col"> | ||
<label class="text-sm font-medium" for="word">ひとこと</label> | ||
<div class="flex flex-col gap-3"> | ||
<textarea id="word" v-model="words" class="rounded border px-3 py-1" style="height: 256px; width: 600px;"></textarea> | ||
<button class="h-10 w-20 rounded-lg" style="background-color: #AC004B; color: white;" @click="changeWords">保存</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> | ||
<style scoped> | ||
hr { | ||
border-top: 1px solid #D8D8D8; | ||
margin-top: 12px; | ||
margin-bottom: 12px; | ||
} | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このページが呼び出されるのは
/settings/account
だけなのでわざわざパスからとってこなくても良い気がします。(Profileの方も同様に。)