-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring to community polls & fixes for quizzes (#3865)
* Refactoring to community polls & fixes for quizzes * Replaced the interactive quiz with a reveal button and small fixes * Replaced the interactive quiz with a reveal button and small fixes * Implemented vote formatting * vote translation fix * Accessibility additions * Fixed local API is_correct typo * Fixed inconsistent indents
- Loading branch information
Showing
10 changed files
with
188 additions
and
59 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/renderer/components/ft-community-poll/ft-community-poll.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
.vote-count { | ||
padding-bottom: 6px; | ||
font-size: smaller; | ||
} | ||
|
||
.empty-circle { | ||
background-color: transparent; | ||
border-radius: 50%; | ||
border-style: solid; | ||
border-width: 2px; | ||
display: block; | ||
float: left; | ||
height: 10px; | ||
left: 5px; | ||
position: relative; | ||
top: 8px; | ||
width: 10px; | ||
} | ||
|
||
.filled-circle { | ||
border-radius: 50%; | ||
background-color: black; | ||
float: left; | ||
height: 6px; | ||
left: 2px; | ||
top: 2px; | ||
position: relative; | ||
width: 6px; | ||
} | ||
|
||
.option-text { | ||
border-radius: 5px; | ||
border-style: solid; | ||
border-width: 2px; | ||
padding: 5px 25px; | ||
} | ||
|
||
.option { | ||
padding-bottom: 10px; | ||
} | ||
|
||
.correct-option { | ||
background-color: #78da71; | ||
} | ||
|
||
.incorrect-option { | ||
background-color: #dd4e4e; | ||
} | ||
|
||
.reveal-answer { | ||
text-align: center; | ||
cursor: pointer; | ||
} | ||
|
||
.reveal-answer:hover > .option-text, .reveal-answer:focus > .option-text { | ||
background-color: var(--side-nav-hover-color) | ||
} |
22 changes: 22 additions & 0 deletions
22
src/renderer/components/ft-community-poll/ft-community-poll.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { defineComponent } from 'vue' | ||
import { formatNumber } from '../../helpers/utils' | ||
|
||
export default defineComponent({ | ||
name: 'FtCommunityPoll', | ||
props: { | ||
data: { | ||
type: Object, | ||
required: true | ||
} | ||
}, | ||
data: function () { | ||
return { | ||
revealAnswer: false | ||
} | ||
}, | ||
computed: { | ||
formattedVotes: function () { | ||
return formatNumber(this.data.totalVotes) | ||
}, | ||
} | ||
}) |
63 changes: 63 additions & 0 deletions
63
src/renderer/components/ft-community-poll/ft-community-poll.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<template> | ||
<div class="poll"> | ||
<div | ||
class="vote-count" | ||
> | ||
<!-- Format the votes to be split by commas ie. 1000 -> 1,000 --> | ||
{{ $t('Channel.Community.votes', {votes: formattedVotes}) }} | ||
</div> | ||
<div | ||
v-for="(choice, index) in data.content" | ||
:key="index" | ||
> | ||
<div | ||
v-if="data.type === 'quiz'" | ||
class="option quiz-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> | ||
</div> | ||
<div | ||
v-else | ||
class="option poll-option" | ||
> | ||
<span class="empty-circle" /> | ||
<div class="option-text"> | ||
{{ choice.text }} | ||
</div> | ||
</div> | ||
</div> | ||
<div | ||
v-if="data.type === 'quiz'" | ||
class="reveal-answer option" | ||
tabindex="0" | ||
role="button" | ||
@click="revealAnswer = !revealAnswer" | ||
@keydown.enter.prevent="revealAnswer = !revealAnswer" | ||
@keydown.space.prevent="revealAnswer = !revealAnswer" | ||
> | ||
<div | ||
v-if="!revealAnswer" | ||
class="option-text" | ||
> | ||
<font-awesome-icon :icon="['fas', 'eye']" /> {{ $t('Channel.Community.Reveal Answers') }} | ||
</div> | ||
<div | ||
v-else | ||
class="option-text" | ||
> | ||
<font-awesome-icon :icon="['fas', 'eye-slash']" /> {{ $t('Channel.Community.Hide Answers') }} | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script src="./ft-community-poll.js" /> | ||
<style scoped src="./ft-community-poll.css" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters