summaryrefslogtreecommitdiff
path: root/packages/client/src/components
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-07-24 15:45:16 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-07-24 15:45:16 +0900
commit92f9392bcf767efd170dfc27cfa6d3c14e7df892 (patch)
tree58e4c327286e1358f854f49bdfffc16a668cc07a /packages/client/src/components
parentchore(client): tweak style (diff)
downloadsharkey-92f9392bcf767efd170dfc27cfa6d3c14e7df892.tar.gz
sharkey-92f9392bcf767efd170dfc27cfa6d3c14e7df892.tar.bz2
sharkey-92f9392bcf767efd170dfc27cfa6d3c14e7df892.zip
refactor(client): refactor components
Diffstat (limited to 'packages/client/src/components')
-rw-r--r--packages/client/src/components/renote-button.vue106
-rw-r--r--packages/client/src/components/sparkle.vue92
-rw-r--r--packages/client/src/components/tab.vue8
3 files changed, 90 insertions, 116 deletions
diff --git a/packages/client/src/components/renote-button.vue b/packages/client/src/components/renote-button.vue
index 3bcbe665bf..d267f30403 100644
--- a/packages/client/src/components/renote-button.vue
+++ b/packages/client/src/components/renote-button.vue
@@ -1,5 +1,6 @@
<template>
-<button v-if="canRenote"
+<button
+ v-if="canRenote"
ref="buttonRef"
class="eddddedb _button canRenote"
@click="renote()"
@@ -12,8 +13,9 @@
</button>
</template>
-<script lang="ts">
-import { computed, defineComponent, ref } from 'vue';
+<script lang="ts" setup>
+import { computed, ref } from 'vue';
+import * as misskey from 'misskey-js';
import XDetails from '@/components/users-tooltip.vue';
import { pleaseLogin } from '@/scripts/please-login';
import * as os from '@/os';
@@ -21,71 +23,55 @@ import { $i } from '@/account';
import { useTooltip } from '@/scripts/use-tooltip';
import { i18n } from '@/i18n';
-export default defineComponent({
- props: {
- count: {
- type: Number,
- required: true,
- },
- note: {
- type: Object,
- required: true,
- },
- },
+const props = defineProps<{
+ note: misskey.entities.Note;
+ count: number;
+}>();
- setup(props) {
- const buttonRef = ref<HTMLElement>();
+const buttonRef = ref<HTMLElement>();
- const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i.id);
+const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i.id);
- useTooltip(buttonRef, async (showing) => {
- const renotes = await os.api('notes/renotes', {
- noteId: props.note.id,
- limit: 11
- });
+useTooltip(buttonRef, async (showing) => {
+ const renotes = await os.api('notes/renotes', {
+ noteId: props.note.id,
+ limit: 11,
+ });
- const users = renotes.map(x => x.user);
+ const users = renotes.map(x => x.user);
- if (users.length < 1) return;
+ if (users.length < 1) return;
- os.popup(XDetails, {
- showing,
- users,
- count: props.count,
- targetElement: buttonRef.value
- }, {}, 'closed');
- });
+ os.popup(XDetails, {
+ showing,
+ users,
+ count: props.count,
+ targetElement: buttonRef.value,
+ }, {}, 'closed');
+});
- const renote = (viaKeyboard = false) => {
- pleaseLogin();
- os.popupMenu([{
- text: i18n.ts.renote,
- icon: 'fas fa-retweet',
- action: () => {
- os.api('notes/create', {
- renoteId: props.note.id
- });
- }
- }, {
- text: i18n.ts.quote,
- icon: 'fas fa-quote-right',
- action: () => {
- os.post({
- renote: props.note,
- });
- }
- }], buttonRef.value, {
- viaKeyboard
+const renote = (viaKeyboard = false) => {
+ pleaseLogin();
+ os.popupMenu([{
+ text: i18n.ts.renote,
+ icon: 'fas fa-retweet',
+ action: () => {
+ os.api('notes/create', {
+ renoteId: props.note.id,
});
- };
-
- return {
- buttonRef,
- canRenote,
- renote,
- };
- },
-});
+ },
+ }, {
+ text: i18n.ts.quote,
+ icon: 'fas fa-quote-right',
+ action: () => {
+ os.post({
+ renote: props.note,
+ });
+ },
+ }], buttonRef.value, {
+ viaKeyboard,
+ });
+};
</script>
<style lang="scss" scoped>
diff --git a/packages/client/src/components/sparkle.vue b/packages/client/src/components/sparkle.vue
index b52dbe31c4..cdeaf9c417 100644
--- a/packages/client/src/components/sparkle.vue
+++ b/packages/client/src/components/sparkle.vue
@@ -63,63 +63,51 @@
</span>
</template>
-<script lang="ts">
-import { defineComponent, onMounted, onUnmounted, ref } from 'vue';
-import * as os from '@/os';
+<script lang="ts" setup>
+import { onMounted, onUnmounted, ref } from 'vue';
-export default defineComponent({
- setup() {
- const particles = ref([]);
- const el = ref<HTMLElement>();
- const width = ref(0);
- const height = ref(0);
- const colors = ['#FF1493', '#00FFFF', '#FFE202', '#FFE202', '#FFE202'];
- let stop = false;
- let ro: ResizeObserver | undefined;
+const particles = ref([]);
+const el = ref<HTMLElement>();
+const width = ref(0);
+const height = ref(0);
+const colors = ['#FF1493', '#00FFFF', '#FFE202', '#FFE202', '#FFE202'];
+let stop = false;
+let ro: ResizeObserver | undefined;
- onMounted(() => {
- ro = new ResizeObserver((entries, observer) => {
- width.value = el.value?.offsetWidth + 64;
- height.value = el.value?.offsetHeight + 64;
- });
- ro.observe(el.value);
- const add = () => {
- if (stop) return;
- const x = (Math.random() * (width.value - 64));
- const y = (Math.random() * (height.value - 64));
- const sizeFactor = Math.random();
- const particle = {
- id: Math.random().toString(),
- x,
- y,
- size: 0.2 + ((sizeFactor / 10) * 3),
- dur: 1000 + (sizeFactor * 1000),
- color: colors[Math.floor(Math.random() * colors.length)],
- };
- particles.value.push(particle);
- window.setTimeout(() => {
- particles.value = particles.value.filter(x => x.id !== particle.id);
- }, particle.dur - 100);
+onMounted(() => {
+ ro = new ResizeObserver((entries, observer) => {
+ width.value = el.value?.offsetWidth + 64;
+ height.value = el.value?.offsetHeight + 64;
+ });
+ ro.observe(el.value);
+ const add = () => {
+ if (stop) return;
+ const x = (Math.random() * (width.value - 64));
+ const y = (Math.random() * (height.value - 64));
+ const sizeFactor = Math.random();
+ const particle = {
+ id: Math.random().toString(),
+ x,
+ y,
+ size: 0.2 + ((sizeFactor / 10) * 3),
+ dur: 1000 + (sizeFactor * 1000),
+ color: colors[Math.floor(Math.random() * colors.length)],
+ };
+ particles.value.push(particle);
+ window.setTimeout(() => {
+ particles.value = particles.value.filter(x => x.id !== particle.id);
+ }, particle.dur - 100);
- window.setTimeout(() => {
- add();
- }, 500 + (Math.random() * 500));
- };
+ window.setTimeout(() => {
add();
- });
-
- onUnmounted(() => {
- if (ro) ro.disconnect();
- stop = true;
- });
+ }, 500 + (Math.random() * 500));
+ };
+ add();
+});
- return {
- el,
- width,
- height,
- particles,
- };
- },
+onUnmounted(() => {
+ if (ro) ro.disconnect();
+ stop = true;
});
</script>
diff --git a/packages/client/src/components/tab.vue b/packages/client/src/components/tab.vue
index c629727358..669e9e2e11 100644
--- a/packages/client/src/components/tab.vue
+++ b/packages/client/src/components/tab.vue
@@ -18,13 +18,13 @@ export default defineComponent({
disabled: this.modelValue === option.props.value,
onClick: () => {
this.$emit('update:modelValue', option.props.value);
- }
+ },
}, option.children), [
- [resolveDirective('click-anime')]
+ [resolveDirective('click-anime')],
]))), [
- [resolveDirective('size'), { max: [500] }]
+ [resolveDirective('size'), { max: [500] }],
]);
- }
+ },
});
</script>