Accessible follow button
This commit is contained in:
parent
da0a0503ba
commit
55b6b6075d
|
@ -1,6 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<button
|
<button
|
||||||
class="kpoogebi _button"
|
v-if="$i != null && $i.id != user.id"
|
||||||
|
class="kpoogebi _button follow-button"
|
||||||
:class="{
|
:class="{
|
||||||
wait,
|
wait,
|
||||||
active: isFollowing || hasPendingFollowRequestFromYou,
|
active: isFollowing || hasPendingFollowRequestFromYou,
|
||||||
|
@ -10,40 +11,41 @@
|
||||||
}"
|
}"
|
||||||
:disabled="wait"
|
:disabled="wait"
|
||||||
@click="onClick"
|
@click="onClick"
|
||||||
|
:aria-label=" `${state} ${user.name || user.username}` "
|
||||||
>
|
>
|
||||||
<template v-if="!wait">
|
<template v-if="!wait">
|
||||||
<template v-if="isBlocking">
|
<template v-if="isBlocking">
|
||||||
<span v-if="full">{{ i18n.ts.blocked }}</span
|
<span v-if="full">{{ state = i18n.ts.blocked }}</span
|
||||||
><i class="ph-prohibit ph-bold ph-lg"></i>
|
><i class="ph-prohibit ph-bold ph-lg"></i>
|
||||||
</template>
|
</template>
|
||||||
<template
|
<template
|
||||||
v-else-if="hasPendingFollowRequestFromYou && user.isLocked"
|
v-else-if="hasPendingFollowRequestFromYou && user.isLocked"
|
||||||
>
|
>
|
||||||
<span v-if="full">{{ i18n.ts.followRequestPending }}</span
|
<span v-if="full">{{ state = i18n.ts.followRequestPending }}</span
|
||||||
><i class="ph-hourglass-medium ph-bold ph-lg"></i>
|
><i class="ph-hourglass-medium ph-bold ph-lg"></i>
|
||||||
</template>
|
</template>
|
||||||
<template
|
<template
|
||||||
v-else-if="hasPendingFollowRequestFromYou && !user.isLocked"
|
v-else-if="hasPendingFollowRequestFromYou && !user.isLocked"
|
||||||
>
|
>
|
||||||
<!-- つまりリモートフォローの場合。 -->
|
<!-- つまりリモートフォローの場合。 -->
|
||||||
<span v-if="full">{{ i18n.ts.processing }}</span
|
<span v-if="full">{{ state = i18n.ts.processing }}</span
|
||||||
><i class="ph-circle-notch ph-bold ph-lg fa-pulse"></i>
|
><i class="ph-circle-notch ph-bold ph-lg fa-pulse"></i>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="isFollowing">
|
<template v-else-if="isFollowing">
|
||||||
<span v-if="full">{{ i18n.ts.unfollow }}</span
|
<span v-if="full">{{ state = i18n.ts.unfollow }}</span
|
||||||
><i class="ph-minus ph-bold ph-lg"></i>
|
><i class="ph-minus ph-bold ph-lg"></i>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="!isFollowing && user.isLocked">
|
<template v-else-if="!isFollowing && user.isLocked">
|
||||||
<span v-if="full">{{ i18n.ts.followRequest }}</span
|
<span v-if="full">{{ state = i18n.ts.followRequest }}</span
|
||||||
><i class="ph-plus ph-bold ph-lg"></i>
|
><i class="ph-plus ph-bold ph-lg"></i>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="!isFollowing && !user.isLocked">
|
<template v-else-if="!isFollowing && !user.isLocked">
|
||||||
<span v-if="full">{{ i18n.ts.follow }}</span
|
<span v-if="full">{{ state = i18n.ts.follow }}</span
|
||||||
><i class="ph-plus ph-bold ph-lg"></i>
|
><i class="ph-plus ph-bold ph-lg"></i>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<span v-if="full">{{ i18n.ts.processing }}</span
|
<span v-if="full">{{ state = i18n.ts.processing }}</span
|
||||||
><i class="ph-circle-notch ph-bold ph-lg fa-pulse ph-fw ph-lg"></i>
|
><i class="ph-circle-notch ph-bold ph-lg fa-pulse ph-fw ph-lg"></i>
|
||||||
</template>
|
</template>
|
||||||
</button>
|
</button>
|
||||||
|
@ -55,6 +57,7 @@ import type * as Misskey from "calckey-js";
|
||||||
import * as os from "@/os";
|
import * as os from "@/os";
|
||||||
import { stream } from "@/stream";
|
import { stream } from "@/stream";
|
||||||
import { i18n } from "@/i18n";
|
import { i18n } from "@/i18n";
|
||||||
|
import { $i } from "@/account";
|
||||||
|
|
||||||
const emit = defineEmits(["refresh"]);
|
const emit = defineEmits(["refresh"]);
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
|
@ -71,6 +74,8 @@ const props = withDefaults(
|
||||||
|
|
||||||
const isBlocking = computed(() => props.user.isBlocking);
|
const isBlocking = computed(() => props.user.isBlocking);
|
||||||
|
|
||||||
|
let state = $ref(i18n.ts.processing);
|
||||||
|
|
||||||
let isFollowing = $ref(props.user.isFollowing);
|
let isFollowing = $ref(props.user.isFollowing);
|
||||||
let hasPendingFollowRequestFromYou = $ref(
|
let hasPendingFollowRequestFromYou = $ref(
|
||||||
props.user.hasPendingFollowRequestFromYou
|
props.user.hasPendingFollowRequestFromYou
|
||||||
|
@ -155,7 +160,7 @@ onBeforeUnmount(() => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.kpoogebi {
|
.follow-button {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -164,13 +169,15 @@ onBeforeUnmount(() => {
|
||||||
color: var(--accent);
|
color: var(--accent);
|
||||||
border: solid 1px var(--accent);
|
border: solid 1px var(--accent);
|
||||||
padding: 0;
|
padding: 0;
|
||||||
height: 31px;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
border-radius: 32px;
|
width: 2em;
|
||||||
|
height: 2em;
|
||||||
|
border-radius: 100px;
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
|
|
||||||
&.full {
|
&.full {
|
||||||
padding: 0 8px 0 12px;
|
padding: 0.2em .7em;
|
||||||
|
width: auto;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +214,7 @@ onBeforeUnmount(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
color: #fff;
|
color: var(--fgOnAccent);
|
||||||
background: var(--accent);
|
background: var(--accent);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|
|
@ -135,7 +135,6 @@
|
||||||
<div class="follow-container">
|
<div class="follow-container">
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<MkFollowButton
|
<MkFollowButton
|
||||||
v-if="$i != null && $i.id != user.id"
|
|
||||||
:user="user"
|
:user="user"
|
||||||
@refresh="emit('refresh')"
|
@refresh="emit('refresh')"
|
||||||
:inline="true"
|
:inline="true"
|
||||||
|
|
Loading…
Reference in New Issue