Skip to content

Commit ac1e5a0

Browse files
committed
merge: Feat: Implement "Show Below Avatar" for Avatar Decorations (!645)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/645 Approved-by: dakkar <[email protected]> Approved-by: Marie <[email protected]>
2 parents aedc5fb + 9b130b3 commit ac1e5a0

File tree

12 files changed

+36
-1
lines changed

12 files changed

+36
-1
lines changed

locales/en-US.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,7 @@ detach: "Remove"
12791279
detachAll: "Remove All"
12801280
angle: "Angle"
12811281
flip: "Flip"
1282+
showBelowAvatar: "Show Below Avatar"
12821283
showAvatarDecorations: "Show avatar decorations"
12831284
releaseToRefresh: "Release to refresh"
12841285
refreshing: "Refreshing..."

locales/index.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -5133,6 +5133,10 @@ export interface Locale extends ILocale {
51335133
* 反転
51345134
*/
51355135
"flip": string;
5136+
/**
5137+
* アイコンの後ろに表示
5138+
*/
5139+
"showBelowAvatar": string;
51365140
/**
51375141
* アイコンのデコレーションを表示
51385142
*/

locales/ja-JP.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,7 @@ detach: "外す"
12791279
detachAll: "全て外す"
12801280
angle: "角度"
12811281
flip: "反転"
1282+
showBelowAvatar: "アイコンの後ろに表示"
12821283
showAvatarDecorations: "アイコンのデコレーションを表示"
12831284
releaseToRefresh: "離してリロード"
12841285
refreshing: "リロード中"

packages/backend/src/core/entities/UserEntityService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ export class UserEntityService implements OnModuleInit {
525525
flipH: ud.flipH || undefined,
526526
offsetX: ud.offsetX || undefined,
527527
offsetY: ud.offsetY || undefined,
528+
showBelow: ud.showBelow || undefined,
528529
url: decorations.find(d => d.id === ud.id)!.url,
529530
}))) : [],
530531
isBot: user.isBot,

packages/backend/src/models/User.ts

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export class MiUser {
170170
flipH?: boolean;
171171
offsetX?: number;
172172
offsetY?: number;
173+
showBelow?: boolean;
173174
}[];
174175

175176
@Index()

packages/backend/src/models/json-schema/user.ts

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ export const packedUserLiteSchema = {
104104
type: 'number',
105105
nullable: false, optional: true,
106106
},
107+
showBelow: {
108+
type: 'boolean',
109+
nullable: false, optional: true,
110+
},
107111
},
108112
},
109113
},

packages/backend/src/server/api/endpoints/i/update.ts

+2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export const paramDef = {
159159
flipH: { type: 'boolean', nullable: true },
160160
offsetX: { type: 'number', nullable: true, maximum: 0.25, minimum: -0.25 },
161161
offsetY: { type: 'number', nullable: true, maximum: 0.25, minimum: -0.25 },
162+
showBelow: { type: 'boolean', nullable: true },
162163
},
163164
required: ['id'],
164165
} },
@@ -417,6 +418,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
417418
flipH: d.flipH ?? false,
418419
offsetX: d.offsetX ?? 0,
419420
offsetY: d.offsetY ?? 0,
421+
showBelow: d.showBelow ?? false,
420422
}));
421423
}
422424

packages/frontend/src/components/global/MkAvatar.vue

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ SPDX-License-Identifier: AGPL-3.0-only
3232
rotate: getDecorationAngle(decoration),
3333
scale: getDecorationScale(decoration),
3434
translate: getDecorationOffset(decoration),
35+
zIndex: getDecorationZIndex(decoration),
3536
}"
3637
alt=""
3738
>
@@ -113,6 +114,10 @@ function getDecorationOffset(decoration: Omit<Misskey.entities.UserDetailed['ava
113114
return offsetX === 0 && offsetY === 0 ? undefined : `${offsetX * 100}% ${offsetY * 100}%`;
114115
}
115116

117+
function getDecorationZIndex(decoration: Omit<Misskey.entities.UserDetailed['avatarDecorations'][number], 'id'>) {
118+
return decoration.showBelow ? '-1' : undefined;
119+
}
120+
116121
const color = ref<string | undefined>();
117122

118123
watch(() => props.user.avatarBlurhash, () => {
@@ -159,6 +164,7 @@ watch(() => props.user.avatarBlurhash, () => {
159164
flex-shrink: 0;
160165
border-radius: 100%; // sharkey: controlled by square avatars setting!
161166
line-height: 16px;
167+
z-index: 0; // sharkey: starts stacking context to help with showing decorations behind the avatar
162168
}
163169

164170
.inner {

packages/frontend/src/pages/settings/avatar-decoration.decoration.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only
99
@click="emit('click')"
1010
>
1111
<div :class="$style.name"><MkCondensedLine :minScale="0.5">{{ decoration.name }}</MkCondensedLine></div>
12-
<MkAvatar style="width: 60px; height: 60px;" :user="$i" :decorations="[{ url: decoration.url, angle, flipH, offsetX, offsetY }]" forceShowDecoration/>
12+
<MkAvatar style="width: 60px; height: 60px;" :user="$i" :decorations="[{ url: decoration.url, angle, flipH, offsetX, offsetY, showBelow }]" forceShowDecoration/>
1313
<i v-if="decoration.roleIdsThatCanBeUsedThisDecoration.length > 0 && !$i.roles.some(r => decoration.roleIdsThatCanBeUsedThisDecoration.includes(r.id))" :class="$style.lock" class="ti ti-lock"></i>
1414
</div>
1515
</template>
@@ -32,6 +32,7 @@ const props = defineProps<{
3232
flipH?: boolean;
3333
offsetX?: number;
3434
offsetY?: number;
35+
showBelow?: boolean;
3536
}>();
3637

3738
const emit = defineEmits<{

packages/frontend/src/pages/settings/avatar-decoration.dialog.vue

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ SPDX-License-Identifier: AGPL-3.0-only
2929
<MkRange v-model="offsetY" continuousUpdate :min="-0.25" :max="0.25" :step="0.025" :textConverter="(v) => `${Math.floor(v * 100)}%`">
3030
<template #label>Y {{ i18n.ts.position }}</template>
3131
</MkRange>
32+
<MkSwitch v-model="showBelow">
33+
<template #label>{{ i18n.ts.showBelowAvatar }}</template>
34+
</MkSwitch>
3235
<MkSwitch v-model="flipH">
3336
<template #label>{{ i18n.ts.flip }}</template>
3437
</MkSwitch>
@@ -71,12 +74,14 @@ const emit = defineEmits<{
7174
flipH: boolean;
7275
offsetX: number;
7376
offsetY: number;
77+
showBelow: boolean;
7478
}): void;
7579
(ev: 'update', payload: {
7680
angle: number;
7781
flipH: boolean;
7882
offsetX: number;
7983
offsetY: number;
84+
showBelow: boolean;
8085
}): void;
8186
(ev: 'detach'): void;
8287
}>();
@@ -87,6 +92,7 @@ const angle = ref((props.usingIndex != null ? $i.avatarDecorations[props.usingIn
8792
const flipH = ref((props.usingIndex != null ? $i.avatarDecorations[props.usingIndex].flipH : null) ?? false);
8893
const offsetX = ref((props.usingIndex != null ? $i.avatarDecorations[props.usingIndex].offsetX : null) ?? 0);
8994
const offsetY = ref((props.usingIndex != null ? $i.avatarDecorations[props.usingIndex].offsetY : null) ?? 0);
95+
const showBelow = ref((props.usingIndex != null ? $i.avatarDecorations[props.usingIndex].showBelow : null) ?? false);
9096

9197
const decorationsForPreview = computed(() => {
9298
const decoration = {
@@ -96,6 +102,7 @@ const decorationsForPreview = computed(() => {
96102
flipH: flipH.value,
97103
offsetX: offsetX.value,
98104
offsetY: offsetY.value,
105+
showBelow: showBelow.value,
99106
};
100107
const decorations = [...$i.avatarDecorations];
101108
if (props.usingIndex != null) {
@@ -116,6 +123,7 @@ async function update() {
116123
flipH: flipH.value,
117124
offsetX: offsetX.value,
118125
offsetY: offsetY.value,
126+
showBelow: showBelow.value,
119127
});
120128
dialog.value.close();
121129
}
@@ -126,6 +134,7 @@ async function attach() {
126134
flipH: flipH.value,
127135
offsetX: offsetX.value,
128136
offsetY: offsetY.value,
137+
showBelow: showBelow.value,
129138
});
130139
dialog.value.close();
131140
}

packages/frontend/src/pages/settings/avatar-decoration.vue

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ SPDX-License-Identifier: AGPL-3.0-only
2121
:flipH="avatarDecoration.flipH"
2222
:offsetX="avatarDecoration.offsetX"
2323
:offsetY="avatarDecoration.offsetY"
24+
:showBelow="avatarDecoration.showBelow"
2425
:active="true"
2526
@click="openDecoration(avatarDecoration, i)"
2627
/>
@@ -78,6 +79,7 @@ function openDecoration(avatarDecoration, index?: number) {
7879
flipH: payload.flipH,
7980
offsetX: payload.offsetX,
8081
offsetY: payload.offsetY,
82+
showBelow: payload.showBelow,
8183
};
8284
const update = [...$i.avatarDecorations, decoration];
8385
await os.apiWithDialog('i/update', {
@@ -92,6 +94,7 @@ function openDecoration(avatarDecoration, index?: number) {
9294
flipH: payload.flipH,
9395
offsetX: payload.offsetX,
9496
offsetY: payload.offsetY,
97+
showBelow: payload.showBelow,
9598
};
9699
const update = [...$i.avatarDecorations];
97100
update[index] = decoration;

packages/misskey-js/src/autogen/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3814,6 +3814,7 @@ export type components = {
38143814
url: string;
38153815
offsetX?: number;
38163816
offsetY?: number;
3817+
showBelow?: boolean;
38173818
}[];
38183819
/** @default false */
38193820
isAdmin?: boolean;
@@ -20227,6 +20228,7 @@ export type operations = {
2022720228
flipH?: boolean | null;
2022820229
offsetX?: number | null;
2022920230
offsetY?: number | null;
20231+
showBelow?: boolean | null;
2023020232
})[];
2023120233
/** Format: misskey:id */
2023220234
bannerId?: string | null;

0 commit comments

Comments
 (0)