Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
refactor(post): separate the post viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Oct 10, 2022
1 parent 4b4e2d3 commit 480e3d0
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 52 deletions.
64 changes: 64 additions & 0 deletions components/post/post_viewer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<template>
<div class="post-container" :hidden="post.isPostShown">
<div class="left">
<div><img src="./images/emptyUser.png"/></div>
<h2 class="title">
{{ post.user }}
</h2>
</div>
<div class="middle">
<h2 class="title">
{{ post.title }}
{{ post.badWordExist() }}
</h2>
</div>
<div class="right">
<h2 class="title">
{{ voteCountUpdate(post) }}
</h2>
<label class="switch">
<input
type="checkbox"
:checked="determineUserVoted(post)"
class="switch"
@click="upVote($event, post)"/>
<span class="slider"></span>
</label>
<h2 class="title">
{{ downVoteCountUpdate(post) }}
</h2>
<label class="switch">
<input
type="checkbox"
:checked="determineUserDownVoted(post)"
class="switch"
@click="downVote($event, post)"/>
<span class="slider"></span>
</label>

<h2 class="title">
{{ totalVotes(post) }}
</h2>
</div>
<p :class="`${post.id}`">
{{ post.desc }}
</p>
</div>
</template>

<style>
</style>

<script setup lang="ts">
import {
voteCountUpdate,
determineUserVoted,
upVote,
downVoteCountUpdate,
determineUserDownVoted,
downVote,
totalVotes
} from "./post"
</script>
55 changes: 3 additions & 52 deletions pages/forum/index.page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,51 +97,7 @@
</div>
</div>
<!-- -->
<div class="post-container" :hidden="post.isPostShown">
<div class="left">
<div><img src="./images/emptyUser.png"/></div>
<h2 class="title">
{{ post.user }}
</h2>
</div>
<div class="middle">
<h2 class="title">
{{ post.title }}
{{ post.badWordExist() }}
</h2>
</div>
<div class="right">
<h2 class="title">
{{ voteCountUpdate(post) }}
</h2>
<label class="switch">
<input
type="checkbox"
:checked="determineUserVoted(post)"
class="switch"
@click="upVote($event, post)"/>
<span class="slider"></span>
</label>
<h2 class="title">
{{ downVoteCountUpdate(post) }}
</h2>
<label class="switch">
<input
type="checkbox"
:checked="determineUserDownVoted(post)"
class="switch"
@click="downVote($event, post)"/>
<span class="slider"></span>
</label>

<h2 class="title">
{{ totalVotes(post) }}
</h2>
</div>
<p :class="`${post.id}`">
{{ post.desc }}
</p>
</div>
<PostViewer/>
</div>
<br/>
</div>
Expand All @@ -167,18 +123,13 @@
import { ref } from "vue"
import {
posts,
voteCountUpdate,
determineUserVoted,
upVote,
downVoteCountUpdate,
determineUserDownVoted,
downVote,
totalVotes,
secludePostDiv,
dummyUserDemo
} from "./post"
import makeSwitch from "$@/helpers/make_switch"
import PostViewer from "@/post/post_viewer.vue"
import PostMenu from "@/page_shell/dropdown.vue"
import CreatePostForm from "@/post/create_post_form.vue"
Expand Down

0 comments on commit 480e3d0

Please sign in to comment.