UX: Tweak 'Solution' button design (#230)
This commit is contained in:
parent
2c1c64af2b
commit
7ea62738c5
|
@ -86,39 +86,32 @@ function initializeWithApi(api) {
|
||||||
}
|
}
|
||||||
|
|
||||||
api.addPostMenuButton("solved", (attrs) => {
|
api.addPostMenuButton("solved", (attrs) => {
|
||||||
const canAccept = attrs.can_accept_answer;
|
const isOp = currentUser?.id === attrs.topicCreatedById;
|
||||||
const canUnaccept = attrs.can_unaccept_answer;
|
|
||||||
const accepted = attrs.accepted_answer;
|
|
||||||
const isOp = currentUser && currentUser.id === attrs.topicCreatedById;
|
|
||||||
const position =
|
|
||||||
!accepted && canAccept && !isOp ? "second-last-hidden" : "first";
|
|
||||||
|
|
||||||
if (canAccept) {
|
if (attrs.can_accept_answer) {
|
||||||
return {
|
return {
|
||||||
action: "acceptAnswer",
|
action: "acceptAnswer",
|
||||||
icon: "far-check-square",
|
icon: "far-check-square",
|
||||||
className: "unaccepted",
|
className: "unaccepted",
|
||||||
title: "solved.accept_answer",
|
title: "solved.accept_answer",
|
||||||
label: "solved.solution",
|
label: isOp ? "solved.solution" : null,
|
||||||
position,
|
position: isOp ? "first" : "second",
|
||||||
};
|
};
|
||||||
} else if (canUnaccept && accepted) {
|
} else if (attrs.accepted_answer) {
|
||||||
const title = canUnaccept
|
if (attrs.can_unaccept_answer) {
|
||||||
? "solved.unaccept_answer"
|
|
||||||
: "solved.accepted_answer";
|
|
||||||
return {
|
return {
|
||||||
action: "unacceptAnswer",
|
action: "unacceptAnswer",
|
||||||
icon: "check-square",
|
icon: "check-square",
|
||||||
title,
|
title: "solved.unaccept_answer",
|
||||||
className: "accepted fade-out",
|
className: "accepted fade-out",
|
||||||
position,
|
position: isOp ? "first" : "second",
|
||||||
label: "solved.solution",
|
label: isOp ? "solved.solution" : null,
|
||||||
};
|
};
|
||||||
} else if (!canAccept && accepted) {
|
} else {
|
||||||
return {
|
return {
|
||||||
className: "hidden",
|
className: "hidden",
|
||||||
disabled: "true",
|
disabled: "true",
|
||||||
position,
|
position: "first",
|
||||||
beforeButton(h) {
|
beforeButton(h) {
|
||||||
return h(
|
return h(
|
||||||
"span.accepted-text",
|
"span.accepted-text",
|
||||||
|
@ -133,6 +126,7 @@ function initializeWithApi(api) {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
api.decorateWidget("post-contents:after-cooked", (dec) => {
|
api.decorateWidget("post-contents:after-cooked", (dec) => {
|
||||||
|
|
Loading…
Reference in New Issue