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

設定画面スタンプタブの改修 #4141

Merged
merged 30 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
38fd9b2
一旦スタンプの作成ができるように
mehm8128 Nov 5, 2023
2d8023f
editも画像周り以外実装
mehm8128 Nov 6, 2023
510e3d3
モーダルをデザインの変更に従った
mehm8128 Nov 10, 2023
2bab0c0
三点リーダーメニューを表示
mehm8128 Nov 10, 2023
d764f1b
adminは他の人のスタンプを表示できるように
mehm8128 Nov 11, 2023
11a6df1
loading="lazy"で型エラーが出ないように
mehm8128 Nov 11, 2023
70adb1d
表示を調整
mehm8128 Nov 11, 2023
b8961be
表示ちょっと直した
mehm8128 Nov 11, 2023
4cf792c
ボタンの色を変更
mehm8128 Dec 3, 2023
3a33e65
スタンプを名前順にソート
mehm8128 Dec 3, 2023
8287e75
スタンプ情報編集で画像編集をできないように
mehm8128 Dec 3, 2023
ade377d
一通り動くようになった
mehm8128 Dec 3, 2023
e9ae2a5
ref外したのを戻した&format
mehm8128 Dec 3, 2023
d50e32d
uuidじゃなくてuidを表示するように
mehm8128 Dec 27, 2023
8596164
プロフィールタブを改修
mehm8128 Jan 6, 2024
05e3290
cropperのmargin消した
mehm8128 Jan 6, 2024
3bf8a0b
iconsizeを追加
mehm8128 Jan 6, 2024
84c0503
旧Twitterに
mehm8128 Apr 2, 2024
b139c30
アイコン変更ボタンを移動
mehm8128 Apr 5, 2024
c083003
format
mehm8128 Apr 5, 2024
7fd6584
ちょっと修正
mehm8128 May 9, 2024
3dfaffc
Merge pull request #4215 from traPtitech/feat/settings_profile
mehm8128 May 9, 2024
dedaffb
Merge remote-tracking branch 'origin' into feat/settings_stamp
mehm8128 May 9, 2024
5f27f84
spでスタンプ名が長いときにはみ出ないように
mehm8128 Jun 19, 2024
00aceac
Merge remote-tracking branch 'origin/master' into feat/settings_stamp
mehm8128 Jun 19, 2024
37251f4
remove unused import
mehm8128 Jun 19, 2024
d15c500
タブの背景色がバグってたのを直した
mehm8128 Jul 2, 2024
6d6d515
Merge remote-tracking branch 'origin/master' into feat/settings_stamp
mehm8128 Jul 24, 2024
668883f
Merge branch 'master' into feat/settings_stamp
nokhnaton Oct 17, 2024
bae8de0
fix format
nokhnaton Oct 17, 2024
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
6 changes: 4 additions & 2 deletions src/assets/mdi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ import {
mdiCrown,
mdiFormatTitle,
mdiCloseCircle,
mdiNotebook
mdiNotebook,
mdiDelete
} from '@mdi/js'

interface MdiIconsMapping {
Expand Down Expand Up @@ -167,7 +168,8 @@ const mdi: MdiIconsMapping = {
'music-note': mdiMusicNote,
stop: mdiStop,
crown: mdiCrown,
'format-title': mdiFormatTitle
'format-title': mdiFormatTitle,
delete: mdiDelete
}

export default mdi
2 changes: 1 addition & 1 deletion src/components/Modal/Common/ModalFrame.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const { clearModal } = useModalStore()
}
.body {
width: 100%;
padding: 16px 24px;
padding: 16px;
overflow: {
x: hidden;
y: auto;
Expand Down
19 changes: 18 additions & 1 deletion src/components/Modal/ModalContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
currentState.type === 'file' ||
currentState.type === 'channel-manage' ||
currentState.type === 'group-admin-add' ||
currentState.type === 'group-member-add'
currentState.type === 'group-member-add' ||
currentState.type === 'settings-stamp-edit' ||
currentState.type === 'settings-stamp-image-edit'
? currentState.id
: undefined
"
Expand Down Expand Up @@ -41,6 +43,13 @@
? currentState.userId
: undefined
"
:file="
currentState.type === 'settings-stamp-create' ||
currentState.type === 'settings-stamp-image-edit' ||
currentState.type === 'settings-profile-icon-edit'
? currentState.file
: undefined
"
/>
</div>
</transition>
Expand All @@ -63,6 +72,10 @@ import GroupCreateModal from './GroupCreateModal/GroupCreateModal.vue'
import GroupMemberEditModal from './GroupMemberEditModal/GroupMemberEditModal.vue'
import GroupAdminAddModal from './GroupAdminAddModal/GroupAdminAddModal.vue'
import GroupMemberAddModal from './GroupMemberAddModal/GroupMemberAddModal.vue'
import StampCreateModal from './StampCreateModal/StampCreateModal.vue'
import StampEditModal from './StampEditModal/StampEditModal.vue'
import StampImageEditModal from './StampImageEditModal/StampImageEditModal.vue'
import ProfileIconEditModal from './ProfileIconEditModal/ProfileIconEditModal.vue'
import SettingsCacheClearModal from './SettingsCacheClearModal/SettingsCacheClearModal.vue'
import SettingsThemeEditModal from './SettingsThemeEditModal/SettingsThemeEditModal.vue'
import type { ModalStateType } from '/@/store/ui/modal/states'
Expand All @@ -84,6 +97,10 @@ const components: Record<ModalStateType, Component> = {
'group-member-edit': GroupMemberEditModal,
'group-admin-add': GroupAdminAddModal,
'group-member-add': GroupMemberAddModal,
'settings-stamp-create': StampCreateModal,
'settings-stamp-edit': StampEditModal,
'settings-stamp-image-edit': StampImageEditModal,
'settings-profile-icon-edit': ProfileIconEditModal,
'settings-cache-clear': SettingsCacheClearModal,
'settings-theme-edit': SettingsThemeEditModal
}
Expand Down
79 changes: 79 additions & 0 deletions src/components/Modal/ProfileIconEditModal/ProfileIconEditModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<template>
<modal-frame
title="アイコンの編集"
subtitle="画像の位置・サイズを編集できます"
>
<div :class="$style.container">
<image-upload v-model="iconImage" />
</div>
<div :class="$style.buttonContainer">
<form-button label="キャンセル" type="tertiary" @click="cancel" />
<form-button
label="更新する"
:loading="isEditing"
@click="editIconImage"
/>
</div>
</modal-frame>
</template>

<script lang="ts" setup>
import { ref, type Ref } from 'vue'
import apis, { formatResizeError } from '/@/lib/apis'
import { useToastStore } from '/@/store/ui/toast'
import FormButton from '/@/components/UI/FormButton.vue'
import ModalFrame from '../Common/ModalFrame.vue'
import { useModalStore } from '/@/store/ui/modal'
import ImageUpload from '/@/components/Settings/ImageUpload.vue'

const props = defineProps<{
file: File
}>()

const { clearModal } = useModalStore()

const iconImage = ref<File>(props.file)

const useIconImageEdit = (iconImage: Ref<File>) => {
const { addSuccessToast, addErrorToast } = useToastStore()
const isEditing = ref(false)

const editIconImage = async () => {
if (!iconImage.value) return
isEditing.value = true
try {
await apis.changeMyIcon(iconImage.value)

addSuccessToast('アイコン画像を変更しました')
} catch (e) {
// eslint-disable-next-line no-console
console.error('アイコン画像の変更に失敗しました', e)
addErrorToast(formatResizeError(e, 'アイコン画像の変更に失敗しました'))
}
clearModal()
isEditing.value = false
}

return { isEditing, editIconImage }
}

const { isEditing, editIconImage } = useIconImageEdit(iconImage)
const cancel = () => {
clearModal()
}
</script>

<style lang="scss" module>
.container {
display: flex;
justify-content: center;
}

.buttonContainer {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 16px;
margin-top: 16px;
}
</style>
86 changes: 86 additions & 0 deletions src/components/Modal/StampCreateModal/StampCreateModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<template>
<modal-frame title="新規スタンプ登録" :subtitle="subtitle">
<stamp-image-edit
v-if="step === 'image'"
:file="file"
@update-file="updateFile"
/>
<stamp-info-edit v-else :stamp-image="stampImage" @back="backToImageEdit" />
</modal-frame>
</template>

<script lang="ts" setup>
import ModalFrame from '/@/components/Modal/Common/ModalFrame.vue'
import { ref, computed } from 'vue'
import StampImageEdit from './StampImageEdit.vue'
import StampInfoEdit from './StampInfoEdit.vue'

const props = defineProps<{
file: File
}>()

const stampImage = ref<File>(props.file)

const step = ref<'image' | 'info'>('image')
const subtitle = computed(() =>
step.value === 'image'
? '画像の位置・サイズを編集できます'
: 'スタンプの名前を入力してください'
)

const updateFile = (file: File) => {
stampImage.value = file
step.value = 'info'
}
const backToImageEdit = () => {
step.value = 'image'
}
</script>

<style lang="scss" module>
.form {
margin: 8px 0;
}

.container {
display: flex;
justify-content: space-between;
gap: 16px;
}
.leftContainer {
min-width: 136px;
width: 136px;
height: 136px;
margin: 8px 0;
flex-grow: 1;
}
.imgButton {
width: 100%;
height: 100%;
border: 2px solid $theme-ui-secondary-default;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}

.label {
@include color-ui-secondary;
margin-bottom: 16px;
}
.creator {
@include color-ui-primary;
}
.note {
@include color-ui-secondary;
margin-bottom: 12px;
font-size: 12px;
}
.buttonContainer {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 16px;
}
</style>
81 changes: 81 additions & 0 deletions src/components/Modal/StampCreateModal/StampImageEdit.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<template>
<div>
<div :class="$style.container">
<image-upload v-model="stampImage" />
</div>
<div :class="$style.buttonContainer">
<form-button label="キャンセル" type="tertiary" @click="cancel" />
<form-button
label="次へ"
:loading="isChecking"
@click="checkStampImage"
/>
</div>
</div>
</template>

<script lang="ts" setup>
import { ref, type Ref } from 'vue'
import { formatResizeError } from '/@/lib/apis'
import { useToastStore } from '/@/store/ui/toast'
import { imageSize } from '/@/components/Settings/StampTab/imageSize'
import FormButton from '/@/components/UI/FormButton.vue'
import { useModalStore } from '/@/store/ui/modal'
import ImageUpload from '/@/components/Settings/ImageUpload.vue'

const props = defineProps<{
file: File
}>()
const emit = defineEmits<{
(e: 'updateFile', file: File): void
}>()

const { popModal } = useModalStore()

const stampImage = ref<File>(props.file)

const useCheckStamp = (stampImage: Ref<File>) => {
const { addErrorToast } = useToastStore()
const isChecking = ref(false)

const checkStampImage = async () => {
if (!stampImage.value) return
isChecking.value = true
try {
const size = await imageSize(stampImage.value)
if (size.height !== size.width) {
addErrorToast('画像が正方形ではありません。編集してください')
return
}
} catch (e) {
// eslint-disable-next-line no-console
console.error('画像の整形に失敗しました', e)
addErrorToast(formatResizeError(e, '画像の整形に失敗しました'))
}
emit('updateFile', stampImage.value)
isChecking.value = false
}

return { isChecking, checkStampImage }
}

const { isChecking, checkStampImage } = useCheckStamp(stampImage)
const cancel = () => {
popModal()
}
</script>

<style lang="scss" module>
.container {
display: flex;
justify-content: center;
}

.buttonContainer {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 16px;
margin-top: 16px;
}
</style>
Loading
Loading