summaryrefslogtreecommitdiff
path: root/packages/frontend/src/widgets
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-01-09 20:23:06 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-01-09 20:23:06 +0900
commitc179d6f7354b7814a0215cf8a83c00c9ddbc2dfa (patch)
tree8270edd3e19f878bc2e6f905df63dfc1428a924c /packages/frontend/src/widgets
parenttypo (diff)
downloadmisskey-c179d6f7354b7814a0215cf8a83c00c9ddbc2dfa.tar.gz
misskey-c179d6f7354b7814a0215cf8a83c00c9ddbc2dfa.tar.bz2
misskey-c179d6f7354b7814a0215cf8a83c00c9ddbc2dfa.zip
feat(client): add profile widget
Resolve #7722
Diffstat (limited to 'packages/frontend/src/widgets')
-rw-r--r--packages/frontend/src/widgets/index.ts2
-rw-r--r--packages/frontend/src/widgets/profile.vue96
2 files changed, 98 insertions, 0 deletions
diff --git a/packages/frontend/src/widgets/index.ts b/packages/frontend/src/widgets/index.ts
index eba4abd2f7..0b81892419 100644
--- a/packages/frontend/src/widgets/index.ts
+++ b/packages/frontend/src/widgets/index.ts
@@ -1,6 +1,7 @@
import { App, defineAsyncComponent } from 'vue';
export default function(app: App) {
+ app.component('MkwProfile', defineAsyncComponent(() => import('./profile.vue')));
app.component('MkwMemo', defineAsyncComponent(() => import('./memo.vue')));
app.component('MkwNotifications', defineAsyncComponent(() => import('./notifications.vue')));
app.component('MkwTimeline', defineAsyncComponent(() => import('./timeline.vue')));
@@ -29,6 +30,7 @@ export default function(app: App) {
}
export const widgets = [
+ 'profile',
'memo',
'notifications',
'timeline',
diff --git a/packages/frontend/src/widgets/profile.vue b/packages/frontend/src/widgets/profile.vue
new file mode 100644
index 0000000000..3c70be12c3
--- /dev/null
+++ b/packages/frontend/src/widgets/profile.vue
@@ -0,0 +1,96 @@
+<template>
+<div class="_panel">
+ <div :class="$style.container" :style="{ backgroundImage: $i.bannerUrl ? `url(${ $i.bannerUrl })` : null }">
+ <div :class="$style.avatarContainer">
+ <MkAvatar :class="$style.avatar" :user="$i" :disable-link="true" :disable-preview="true"/>
+ </div>
+ <div :class="$style.bodyContainer">
+ <div :class="$style.body">
+ <MkA v-once :class="$style.name" :to="userPage($i)">
+ <MkUserName :user="$i"/>
+ </MkA>
+ <div :class="$style.username"><MkAcct :user="$i" detail/></div>
+ </div>
+ </div>
+ </div>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { onMounted, onUnmounted, Ref, ref, watch } from 'vue';
+import { useWidgetPropsManager, Widget, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget';
+import { GetFormResultType } from '@/scripts/form';
+import { $i } from '@/account';
+import { userPage } from '@/filters/user';
+
+const name = 'profile';
+
+const widgetPropsDef = {
+};
+
+type WidgetProps = GetFormResultType<typeof widgetPropsDef>;
+
+// 現時点ではvueの制限によりimportしたtypeをジェネリックに渡せない
+//const props = defineProps<WidgetComponentProps<WidgetProps>>();
+//const emit = defineEmits<WidgetComponentEmits<WidgetProps>>();
+const props = defineProps<{ widget?: Widget<WidgetProps>; }>();
+const emit = defineEmits<{ (ev: 'updateProps', props: WidgetProps); }>();
+
+const { widgetProps, configure } = useWidgetPropsManager(name,
+ widgetPropsDef,
+ props,
+ emit,
+);
+
+defineExpose<WidgetComponentExpose>({
+ name,
+ configure,
+ id: props.widget ? props.widget.id : null,
+});
+</script>
+
+<style lang="scss" module>
+.container {
+ position: relative;
+ background-size: cover;
+ background-position: center;
+ display: flex;
+}
+
+.avatarContainer {
+ display: inline-block;
+ text-align: center;
+ padding: 16px;
+}
+
+.avatar {
+ display: inline-block;
+ width: 60px;
+ height: 60px;
+ box-sizing: border-box;
+ border: solid 3px #fff;
+}
+
+.bodyContainer {
+ display: flex;
+ align-items: center;
+ min-width: 0;
+ padding: 0 16px 0 0;
+}
+
+.body {
+ text-overflow: ellipsis;
+ overflow: clip;
+}
+
+.name {
+ color: #fff;
+ filter: drop-shadow(0 0 4px #000);
+ font-weight: bold;
+}
+
+.username {
+ color: #fff;
+ filter: drop-shadow(0 0 4px #000);
+}
+</style>