UX: If I can't unselect an answer, show text not a button (#80)
* UX: If I can't unselect an answer, show text not a button * UX: Hide button text when post controls are expanded on mobile
This commit is contained in:
parent
8e8bf5e2d8
commit
9550ced040
|
@ -8,6 +8,7 @@ import { ajax } from "discourse/lib/ajax";
|
||||||
import PostCooked from "discourse/widgets/post-cooked";
|
import PostCooked from "discourse/widgets/post-cooked";
|
||||||
import { formatUsername } from "discourse/lib/utilities";
|
import { formatUsername } from "discourse/lib/utilities";
|
||||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||||
|
import { iconNode } from "discourse-common/lib/icon-library";
|
||||||
|
|
||||||
function clearAccepted(topic) {
|
function clearAccepted(topic) {
|
||||||
const posts = topic.get("postStream.posts");
|
const posts = topic.get("postStream.posts");
|
||||||
|
@ -95,9 +96,10 @@ function initializeWithApi(api) {
|
||||||
icon: "far-check-square",
|
icon: "far-check-square",
|
||||||
className: "unaccepted",
|
className: "unaccepted",
|
||||||
title: "solved.accept_answer",
|
title: "solved.accept_answer",
|
||||||
|
label: "solved.solution",
|
||||||
position
|
position
|
||||||
};
|
};
|
||||||
} else if (canUnaccept || accepted) {
|
} else if (canUnaccept && accepted) {
|
||||||
const title = canUnaccept
|
const title = canUnaccept
|
||||||
? "solved.unaccept_answer"
|
? "solved.unaccept_answer"
|
||||||
: "solved.accepted_answer";
|
: "solved.accepted_answer";
|
||||||
|
@ -107,8 +109,25 @@ function initializeWithApi(api) {
|
||||||
title,
|
title,
|
||||||
className: "accepted fade-out",
|
className: "accepted fade-out",
|
||||||
position,
|
position,
|
||||||
|
label: "solved.solution"
|
||||||
|
};
|
||||||
|
} else if (!canAccept && accepted) {
|
||||||
|
let solutionText = iconHTML("check");
|
||||||
|
return {
|
||||||
|
className: "hidden",
|
||||||
|
disabled: "true",
|
||||||
|
position,
|
||||||
beforeButton(h) {
|
beforeButton(h) {
|
||||||
return h("span.accepted-text", I18n.t("solved.solution"));
|
return h(
|
||||||
|
"span.accepted-text",
|
||||||
|
{
|
||||||
|
title: I18n.t("solved.accepted_description")
|
||||||
|
},
|
||||||
|
[
|
||||||
|
h("span", iconNode("check")),
|
||||||
|
h("span.accepted-label", I18n.t("solved.solution"))
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,25 @@
|
||||||
#topic-title .d-icon-far-check-square {
|
#topic-title .d-icon-far-check-square {
|
||||||
margin-top: 0.25em;
|
margin-top: 0.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.topic-post {
|
||||||
|
nav.post-controls {
|
||||||
|
.extra-buttons {
|
||||||
|
button {
|
||||||
|
max-width: unset;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.expanded {
|
||||||
|
.accepted,
|
||||||
|
.unaccepted {
|
||||||
|
.d-icon {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.d-button-label {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,11 +13,15 @@
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-controls .accepted-text {
|
.post-controls span.accepted-text {
|
||||||
|
padding: 8px 10px;
|
||||||
|
font-size: $font-up-1;
|
||||||
|
span {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-size: inherit;
|
}
|
||||||
margin-right: -3px;
|
.accepted-label {
|
||||||
z-index: 2;
|
margin-left: 7px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// you can style accepted answers however your want
|
// you can style accepted answers however your want
|
||||||
|
|
|
@ -9,6 +9,7 @@ en:
|
||||||
title: "Solved"
|
title: "Solved"
|
||||||
allow_accepted_answers: "Allow topic owner and staff to mark a reply as the solution"
|
allow_accepted_answers: "Allow topic owner and staff to mark a reply as the solution"
|
||||||
accept_answer: "Select if this reply solves the problem"
|
accept_answer: "Select if this reply solves the problem"
|
||||||
|
accepted_description: "This is the accepted solution to this topic"
|
||||||
has_no_accepted_answer: "This topic has no solution"
|
has_no_accepted_answer: "This topic has no solution"
|
||||||
unaccept_answer: "Unselect if this reply no longer solves the problem"
|
unaccept_answer: "Unselect if this reply no longer solves the problem"
|
||||||
accepted_answer: "Solution"
|
accepted_answer: "Solution"
|
||||||
|
|
Loading…
Reference in New Issue