Skip to content

Commit 8c04163

Browse files
committed
style(polls): Added polls to the top of the thread; added collapse functionality
1 parent c89f33a commit 8c04163

File tree

2 files changed

+55
-10
lines changed

2 files changed

+55
-10
lines changed

src/components/polls/PollViewer.vue

+52-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
<template>
22
<div class="polls" id="poll-view" v-if="poll">
33
<!-- Poll Header -->
4-
<div class="poll-title">
4+
<div class="poll-title collapse-section" @click="togglePollsCollapsed()">
55
<span class="poll-title-text">
6+
<a :class="{ 'is-open': !options.polls_collapsed, 'is-closed': options.polls_collapsed }">
7+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 39.84 22.63" class="icon__caretDown">
8+
<title></title>
9+
<g id="Layer_2" data-name="Layer 2">
10+
<polyline class="icon" points="37.92 1.92 19.92 19.92 1.92 1.92" />
11+
</g>
12+
</svg>
13+
</a>
614
Poll
715
<span class="is_locked" v-if="pollCopy.locked">(Locked)</span>
816
</span>
9-
<div class="poll-controls">
17+
<div v-if="!options.polls_collapsed" class="poll-controls">
1018
<!-- Poll Controls -->
1119
<div class="poll-control" v-if="canLock()">
1220
<input id="lockPoll" class="icon" type="checkbox" v-model="pollCopy.locked">
@@ -32,7 +40,7 @@
3240
</div>
3341

3442
<!-- Poll Edit -->
35-
<div class="poll-edit" v-if="canEdit()" :class="{'showing': editPoll, 'hidden': !editPoll}">
43+
<div class="poll-edit" v-if="canEdit() && !options.polls_collapsed" :class="{'showing': editPoll, 'hidden': !editPoll}">
3644
<div class="slide-wrapper">
3745
<div class="poll-edit-container">
3846
<h5 class="panelTitle">Edit Poll Options:</h5>
@@ -71,7 +79,7 @@
7179
</div>
7280
</div>
7381

74-
<div class="poll-body">
82+
<div v-if="!options.polls_collapsed" class="poll-body">
7583
<div class="poll-header">
7684
<!-- Poll Details -->
7785
<div class="poll-header-main">
@@ -117,7 +125,7 @@
117125
</div>
118126
</div>
119127
</div>
120-
<div class="actionsBar">
128+
<div v-if="!options.polls_collapsed" class="actionsBar">
121129
<button @click="vote()" :disabled="pollAnswers.length === 0" v-if="canVote()">Vote</button>
122130
<button v-if="canRemoveVote()" @click="removeVote()" class="secondary">Remove Vote</button>
123131
</div>
@@ -288,6 +296,11 @@ export default {
288296
console.log('scrollPollView')
289297
// $('#poll-view').animate({ scrollTop: 0 }, 250)
290298
}
299+
300+
const togglePollsCollapsed = () => {
301+
v.options.polls_collapsed = !v.options.polls_collapsed
302+
}
303+
291304
/* Internal Data */
292305
const $auth = inject(AuthStore)
293306
const $alertStore = inject('$alertStore')
@@ -303,7 +316,8 @@ export default {
303316
display_mode: props.poll.display_mode,
304317
// used in view to track date and time from input field
305318
expiration_date: props.poll.expiration ? dayjs(props.poll.expiration).format('YYYY-MM-DD') : undefined,
306-
expiration_time: props.poll.expiration ? dayjs(props.poll.expiration).format('HH:mm') : undefined
319+
expiration_time: props.poll.expiration ? dayjs(props.poll.expiration).format('HH:mm') : undefined,
320+
polls_collapsed: false
307321
},
308322
editPoll: false,
309323
pollAnswers: [],
@@ -334,7 +348,8 @@ export default {
334348
updateLockPoll,
335349
calcExpiration,
336350
scrollPollView,
337-
humanDate
351+
humanDate,
352+
togglePollsCollapsed
338353
}
339354
}
340355
}
@@ -351,4 +366,34 @@ export default {
351366
max-height: 0rem;
352367
}
353368
}
369+
370+
.collapse-section {
371+
@include no-select;
372+
cursor: pointer;
373+
a { margin-left: -0.5rem; }
374+
.title { display: inline-block; margin-left: .5rem; }
375+
.is-open {
376+
.icon__caretDown {
377+
transform: rotateZ(0deg);
378+
transition: all ease-in-out 150ms;
379+
}
380+
}
381+
.is-closed {
382+
.icon__caretDown {
383+
transform: rotateZ(-90deg);
384+
transition: all ease-in-out 150ms;
385+
}
386+
}
387+
.icon__caretDown {
388+
margin-bottom: 3px;
389+
width: 8px;
390+
polyline {
391+
fill: none;
392+
stroke: $secondary-font-color;
393+
stroke-linecap: round;
394+
stroke-miterlimit: 10;
395+
stroke-width: 7px;
396+
}
397+
}
398+
}
354399
</style>

src/views/Posts.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@
9999
</div>
100100

101101
<!-- <pagination page-count="PostsParentCtrl.pageCount" page="PostsParentCtrl.page"></pagination> -->
102+
103+
<!-- Poll Viewer -->
104+
<poll-viewer v-if="postData.data.thread?.poll" :poll="postData.data.thread.poll" :thread="postData.data.thread" :user-priority="postData.data.posts[0].user.priority" :reset="resetPoll" :banned-from-board="bannedFromBoard"></poll-viewer>
102105

103106
</div>
104107

@@ -399,9 +402,6 @@
399402

400403
</div>
401404
</div>
402-
403-
<!-- Poll Viewer -->
404-
<poll-viewer v-if="postData.data.thread?.poll" :poll="postData.data.thread.poll" :thread="postData.data.thread" :user-priority="postData.data.posts[0].user.priority" :reset="resetPoll" :banned-from-board="bannedFromBoard"></poll-viewer>
405405
</div>
406406

407407
</div>

0 commit comments

Comments
 (0)