Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add images to community polls #4318

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions src/renderer/components/ft-community-poll/ft-community-poll.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
display: block;
float: var(--float-left-ltr-rtl-value);
block-size: 10px;
inset-inline-start: 5px;
position: relative;
inset-block-start: 8px;
inline-size: 10px;
}

Expand All @@ -29,30 +27,45 @@
}

.option-text {
margin-inline-start: 10px;
}

.option {
display: flex;
align-items: center;
padding-block-end: 10px;
border-radius: 5px;
border-style: solid;
border-width: 2px;
border-width: 1px;
padding-block: 5px;
padding-inline: 25px;
padding-inline-start: 10px;
margin-block-end: 10px;
}

.option {
padding-block-end: 10px;
.option > img {
margin-inline-start: 10px;
block-size: 125px;
}

.correct-option {
border-color: #78da71;
border-width: 2px;
}

.correct-option .filled-circle {
background-color: #78da71;
}

.incorrect-option {
background-color: #dd4e4e;
border-color: #dd4e4e;
border-width: 2px;
}

.reveal-answer {
text-align: center;
.reveal-answer {
justify-content: center;
cursor: pointer;
}

.reveal-answer:hover > .option-text, .reveal-answer:focus > .option-text {
.reveal-answer:hover, .reveal-answer:focus {
background-color: var(--side-nav-hover-color)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@ export default defineComponent({
formattedVotes: function () {
return formatNumber(this.data.totalVotes)
},
},
methods: {
// Use smallest as it's resized to 125px anyways and they're usually all larger than that
findSmallestPollImage: function (images) {
return images.reduce((prev, img) => (img.height < prev.height) ? img : prev, images[0]).url
}
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<div
v-if="data.type === 'quiz'"
class="option quiz-option"
:class="revealAnswer && choice.isCorrect ? 'correct-option' : ''"
>
<span class="empty-circle">
<span :class="revealAnswer && choice.isCorrect ? 'filled-circle' : ''" />
</span>
<div
class="option-text"
:class="revealAnswer && choice.isCorrect ? 'correct-option' : ''"
>
{{ choice.text }}
</div>
Expand All @@ -29,6 +29,11 @@
class="option poll-option"
>
<span class="empty-circle" />
<img
v-if="choice.image"
:src="findSmallestPollImage(choice.image)"
alt=""
>
<div class="option-text">
{{ choice.text }}
</div>
Expand Down