mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Front page forum
This commit is contained in:
parent
a09e9734da
commit
561aa21d93
15 changed files with 484 additions and 136 deletions
|
@ -1,30 +1,36 @@
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
import ReactButton from './reactButton.js'
|
import ReactButton from './reactButton.js'
|
||||||
|
import Modal from './modal.js'
|
||||||
|
|
||||||
import styles from './comments.module.css'
|
import styles from './comments.module.css'
|
||||||
|
|
||||||
function CommentInput({ onSubmit }) {
|
function CommentInput({ onSubmit, onCancel }) {
|
||||||
const [val, setVal] = useState('')
|
const [val, setVal] = useState('')
|
||||||
return (
|
return (
|
||||||
<div className={styles.commentAreaContainer}>
|
<div className={styles.commentAreaContainer}>
|
||||||
<textarea
|
<textarea
|
||||||
autoFocus
|
autoFocus
|
||||||
className={styles.commentArea}
|
|
||||||
value={val}
|
value={val}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setVal(e.target.value)
|
setVal(e.target.value)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div>
|
<div className={'actions'}>
|
||||||
<span
|
<span
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onSubmit(val)
|
onSubmit(val)
|
||||||
}}
|
}}
|
||||||
className={styles.button}
|
|
||||||
>
|
>
|
||||||
Submit
|
Submit
|
||||||
</span>
|
</span>
|
||||||
|
<span
|
||||||
|
onClick={() => {
|
||||||
|
onCancel()
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -33,10 +39,10 @@ function CommentInput({ onSubmit }) {
|
||||||
function Comment({ comment, index, onComment, onDelete, onReact, uid }) {
|
function Comment({ comment, index, onComment, onDelete, onReact, uid }) {
|
||||||
const [displayed, setDisplayed] = useState(true)
|
const [displayed, setDisplayed] = useState(true)
|
||||||
const [commenting, setCommenting] = useState(false)
|
const [commenting, setCommenting] = useState(false)
|
||||||
const { text, subComments, date, user, reacts, adminComment } = comment
|
const { content, subComments, date, user, reacts, admin } = comment
|
||||||
const own = uid === user
|
const own = uid === user
|
||||||
|
|
||||||
const commentStyle = adminComment
|
const commentStyle = admin
|
||||||
? styles.adminComment
|
? styles.adminComment
|
||||||
: own
|
: own
|
||||||
? styles.ownComment
|
? styles.ownComment
|
||||||
|
@ -60,25 +66,23 @@ function Comment({ comment, index, onComment, onDelete, onReact, uid }) {
|
||||||
<div>{date}</div>
|
<div>{date}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={`${!displayed && styles.hidden}`}>
|
<div className={`${!displayed && styles.hidden}`}>
|
||||||
<div className={styles.commentText}> {text}</div>
|
<div className={styles.commentText}> {content}</div>
|
||||||
<div className={styles.actionsContainer}>
|
<div className={'actions'}>
|
||||||
<div
|
<span
|
||||||
className={styles.button}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCommenting(true)
|
setCommenting(true)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Reply...
|
Reply...
|
||||||
</div>
|
</span>
|
||||||
{own && (
|
{own && (
|
||||||
<div
|
<span
|
||||||
className={styles.button}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onDelete([index])
|
onDelete([index])
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
</div>
|
</span>
|
||||||
)}
|
)}
|
||||||
<ReactButton
|
<ReactButton
|
||||||
onClick={(reaction, isDelete) => {
|
onClick={(reaction, isDelete) => {
|
||||||
|
@ -90,6 +94,9 @@ function Comment({ comment, index, onComment, onDelete, onReact, uid }) {
|
||||||
</div>
|
</div>
|
||||||
{commenting && (
|
{commenting && (
|
||||||
<CommentInput
|
<CommentInput
|
||||||
|
onCancel={() => {
|
||||||
|
setCommenting(false)
|
||||||
|
}}
|
||||||
onSubmit={(e) => {
|
onSubmit={(e) => {
|
||||||
onComment([index], e)
|
onComment([index], e)
|
||||||
setCommenting(false)
|
setCommenting(false)
|
||||||
|
@ -110,8 +117,8 @@ function Comment({ comment, index, onComment, onDelete, onReact, uid }) {
|
||||||
onDelete={(path) => {
|
onDelete={(path) => {
|
||||||
onDelete([...path, index])
|
onDelete([...path, index])
|
||||||
}}
|
}}
|
||||||
onComment={(path, text) => {
|
onComment={(path, content) => {
|
||||||
onComment([...path, index], text)
|
onComment([...path, index], content)
|
||||||
}}
|
}}
|
||||||
index={i}
|
index={i}
|
||||||
key={i}
|
key={i}
|
||||||
|
@ -124,6 +131,17 @@ function Comment({ comment, index, onComment, onDelete, onReact, uid }) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function countComments(comments) {
|
||||||
|
return comments.reduce((acc, comment) => {
|
||||||
|
if (comment.subComments) {
|
||||||
|
acc += countComments(comment.subComments) + 1
|
||||||
|
} else {
|
||||||
|
acc += 1
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
|
||||||
export default function Comments({
|
export default function Comments({
|
||||||
comments,
|
comments,
|
||||||
onComment,
|
onComment,
|
||||||
|
@ -132,10 +150,19 @@ export default function Comments({
|
||||||
uid,
|
uid,
|
||||||
}) {
|
}) {
|
||||||
const [addingNewComment, setAddingNewComment] = useState(false)
|
const [addingNewComment, setAddingNewComment] = useState(false)
|
||||||
|
const [commentsShowing, setCommentsShowing] = useState(false)
|
||||||
|
const commentCount = comments ? countComments(comments) : 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{comments && comments.length > 0 ? (
|
{commentsShowing ? (
|
||||||
comments.map((comment, i) => {
|
<Modal
|
||||||
|
closeClick={() => {
|
||||||
|
setCommentsShowing(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{comments && comments.length > 0
|
||||||
|
? comments.map((comment, i) => {
|
||||||
return (
|
return (
|
||||||
<Comment
|
<Comment
|
||||||
onReact={onReact}
|
onReact={onReact}
|
||||||
|
@ -148,28 +175,53 @@ export default function Comments({
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
) : (
|
: null}
|
||||||
<div>
|
{commentCount !== 0 ? (
|
||||||
<div>No comments yet</div>
|
<div className={'actions'}>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{addingNewComment ? (
|
|
||||||
<CommentInput
|
|
||||||
onSubmit={(e) => {
|
|
||||||
setAddingNewComment(false)
|
|
||||||
onComment([], e)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<span
|
<span
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setAddingNewComment(true)
|
setAddingNewComment(true)
|
||||||
}}
|
}}
|
||||||
className={styles.button}
|
|
||||||
>
|
>
|
||||||
Add new
|
New comment
|
||||||
</span>
|
</span>
|
||||||
)}
|
</div>
|
||||||
|
) : null}
|
||||||
|
{addingNewComment ? (
|
||||||
|
<CommentInput
|
||||||
|
onSubmit={(e) => {
|
||||||
|
if (!e) {
|
||||||
|
alert('Írj be valamit, hogy kommentelhess...')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setAddingNewComment(false)
|
||||||
|
onComment([], e)
|
||||||
|
}}
|
||||||
|
onCancel={() => {
|
||||||
|
setAddingNewComment(false)
|
||||||
|
if (commentCount === 0) {
|
||||||
|
setCommentsShowing(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</Modal>
|
||||||
|
) : null}
|
||||||
|
<div
|
||||||
|
className={'actions'}
|
||||||
|
onClick={() => {
|
||||||
|
setCommentsShowing(true)
|
||||||
|
if (commentCount === 0) {
|
||||||
|
setAddingNewComment(true)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
{commentCount === 0
|
||||||
|
? 'New comment'
|
||||||
|
: `Show ${commentCount} comment${commentCount > 1 ? 's' : ''}`}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,13 @@
|
||||||
.commentData {
|
.commentData {
|
||||||
padding: 5px 2px;
|
padding: 5px 2px;
|
||||||
border-left: 2px solid var(--text-color);
|
border-left: 2px solid var(--text-color);
|
||||||
background-color: #222;
|
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.commentData:hover {
|
||||||
|
background-color: var(--hoover-color);
|
||||||
|
}
|
||||||
|
|
||||||
.commentHeader {
|
.commentHeader {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
@ -46,32 +49,6 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.actionsContainer {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button {
|
|
||||||
margin: 2px 2px;
|
|
||||||
padding: 0px 10px;
|
|
||||||
border: 1px solid #444;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button:hover {
|
|
||||||
background-color: #444;
|
|
||||||
}
|
|
||||||
|
|
||||||
.commentArea {
|
|
||||||
color: var(--text-color);
|
|
||||||
background-color: var(--background-color);
|
|
||||||
font-size: 16px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
height: 120px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.commentAreaContainer {
|
.commentAreaContainer {
|
||||||
margin: 0px 8px 3px 8px;
|
margin: 0px 8px 3px 8px;
|
||||||
}
|
}
|
||||||
|
|
119
src/components/composer.js
Normal file
119
src/components/composer.js
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
|
import Modal from './modal'
|
||||||
|
|
||||||
|
import styles from './composer.module.css'
|
||||||
|
|
||||||
|
function FileUploader({ onChange }) {
|
||||||
|
return (
|
||||||
|
<div className={styles.inputArea}>
|
||||||
|
<div className={styles.textTitle}>Fájl csatolása</div>
|
||||||
|
<input
|
||||||
|
className={styles.fileInput}
|
||||||
|
type="file"
|
||||||
|
name="file"
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Composer({ onSubmit }) {
|
||||||
|
const [editorShowing, setEditorShowing] = useState(false)
|
||||||
|
const [val, setVal] = useState('')
|
||||||
|
const [type, setType] = useState('public')
|
||||||
|
const [title, setTitle] = useState('')
|
||||||
|
const [file, setFile] = useState()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
onClick={() => {
|
||||||
|
setEditorShowing(true)
|
||||||
|
}}
|
||||||
|
className={styles.new}
|
||||||
|
>
|
||||||
|
Új bejegyzés / feedback
|
||||||
|
</div>
|
||||||
|
{editorShowing && (
|
||||||
|
<Modal
|
||||||
|
closeClick={() => {
|
||||||
|
setEditorShowing(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className={styles.container}>
|
||||||
|
{type !== 'private' && (
|
||||||
|
<input
|
||||||
|
placeholder={'Téma'}
|
||||||
|
value={title}
|
||||||
|
onChange={(e) => {
|
||||||
|
setTitle(e.target.value)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<textarea
|
||||||
|
placeholder={'...'}
|
||||||
|
value={val}
|
||||||
|
onChange={(e) => {
|
||||||
|
setVal(e.target.value)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{type === 'private' && (
|
||||||
|
<FileUploader
|
||||||
|
onChange={(e) => {
|
||||||
|
setFile(e.target.files[0])
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<div className={styles.typeSelector}>
|
||||||
|
<div>Post típusa:</div>
|
||||||
|
<div title="Minden felhasználó látja főoldalon, és tudnak rá válaszolni">
|
||||||
|
<input
|
||||||
|
onChange={(e) => {
|
||||||
|
setType(e.target.value)
|
||||||
|
}}
|
||||||
|
type="radio"
|
||||||
|
name="type"
|
||||||
|
value="public"
|
||||||
|
defaultChecked
|
||||||
|
/>
|
||||||
|
Publikus
|
||||||
|
</div>
|
||||||
|
<div title="Csak a weboldal üzemeltetője látja">
|
||||||
|
<input
|
||||||
|
onChange={(e) => {
|
||||||
|
setType(e.target.value)
|
||||||
|
}}
|
||||||
|
type="radio"
|
||||||
|
name="type"
|
||||||
|
value="private"
|
||||||
|
/>
|
||||||
|
Privát
|
||||||
|
</div>
|
||||||
|
<div className={styles.tip}>
|
||||||
|
(Tartsd egered opciókra több infóért)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={'actions'}>
|
||||||
|
<span
|
||||||
|
onClick={() => {
|
||||||
|
onSubmit(type, title, val, file)
|
||||||
|
setEditorShowing(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Post
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
onClick={() => {
|
||||||
|
setEditorShowing(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
32
src/components/composer.module.css
Normal file
32
src/components/composer.module.css
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container > input,
|
||||||
|
.container > textarea {
|
||||||
|
margin: 5px 0px;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.typeSelector {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tip {
|
||||||
|
font-size: 10px;
|
||||||
|
margin: 0px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new {
|
||||||
|
padding: 10px;
|
||||||
|
text-align: center;
|
||||||
|
border: 2px dashed var(--text-color);
|
||||||
|
border-radius: 3px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new:hover {
|
||||||
|
background-color: var(--hoover-color);
|
||||||
|
}
|
|
@ -15,7 +15,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.listItem:hover {
|
.listItem:hover {
|
||||||
background-color: #666;
|
background-color: var(--hoover-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.text {
|
.text {
|
||||||
|
|
|
@ -46,7 +46,7 @@ export default function Modal(props) {
|
||||||
❌
|
❌
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{props.children}
|
<div className={styles.children}>{props.children}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
.modal {
|
.modal {
|
||||||
|
z-index: 9999;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
@ -8,16 +9,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.modalContent {
|
.modalContent {
|
||||||
|
display: flex;
|
||||||
|
align-items: stretch;
|
||||||
|
max-height: 80%;
|
||||||
|
width: 80%;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
background: var(--background-color);
|
background: var(--background-color);
|
||||||
width: 70%;
|
|
||||||
height: auto;
|
height: auto;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
border-radius: 5px;
|
border-radius: 8px;
|
||||||
|
|
||||||
padding: 20px;
|
padding: 20px 30px;
|
||||||
cursor: auto;
|
cursor: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +30,14 @@
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
||||||
position: absolute;
|
|
||||||
top: 10px;
|
top: 10px;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.children {
|
||||||
|
max-height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
overflow-y: scroll;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
|
@ -6,20 +6,18 @@ import Comments from './comments.js'
|
||||||
import styles from './newsEntry.module.css'
|
import styles from './newsEntry.module.css'
|
||||||
|
|
||||||
export default function NewsEntry({
|
export default function NewsEntry({
|
||||||
newsKey,
|
|
||||||
newsItem,
|
newsItem,
|
||||||
uid,
|
uid,
|
||||||
onReact,
|
onReact,
|
||||||
onComment,
|
onComment,
|
||||||
onDelete,
|
onDelete,
|
||||||
|
onPostDelete,
|
||||||
}) {
|
}) {
|
||||||
const { reacts, title, text, user, comments, date, adminPost } = newsItem
|
const { reacts, title, content, user, comments, date, admin } = newsItem
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div className={`${styles.newsContainer} ${admin && styles.adminPost}`}>
|
||||||
className={`${styles.newsContainer} ${adminPost && styles.adminPost}`}
|
|
||||||
>
|
|
||||||
<div className={styles.newsHeader}>
|
<div className={styles.newsHeader}>
|
||||||
<div
|
<div
|
||||||
className={styles.newsTitle}
|
className={styles.newsTitle}
|
||||||
|
@ -32,8 +30,19 @@ export default function NewsEntry({
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={styles.newsBody}
|
className={styles.newsBody}
|
||||||
dangerouslySetInnerHTML={{ __html: text }}
|
dangerouslySetInnerHTML={{ __html: content }}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
<div className={'actions'}>
|
||||||
|
{uid === user ? (
|
||||||
|
<span
|
||||||
|
onClick={() => {
|
||||||
|
onPostDelete()
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
<ReactButton
|
<ReactButton
|
||||||
existingReacts={reacts}
|
existingReacts={reacts}
|
||||||
uid={uid}
|
uid={uid}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.adminPost {
|
.adminPost {
|
||||||
border-left: 5px solid yellow;
|
border-left: 2px solid yellow;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,6 @@ import Tooltip from './tooltip.js'
|
||||||
import styles from './reactButton.module.css'
|
import styles from './reactButton.module.css'
|
||||||
import reactions from '../data/reactions.json'
|
import reactions from '../data/reactions.json'
|
||||||
|
|
||||||
// TODO: fixdis
|
|
||||||
const breakEvery = 7
|
|
||||||
|
|
||||||
function ExistingReacts({ existingReacts, onClick, uid }) {
|
function ExistingReacts({ existingReacts, onClick, uid }) {
|
||||||
return (
|
return (
|
||||||
<div className={styles.reactionContainer}>
|
<div className={styles.reactionContainer}>
|
||||||
|
@ -24,7 +21,8 @@ function ExistingReacts({ existingReacts, onClick, uid }) {
|
||||||
title={currReact.join(', ')}
|
title={currReact.join(', ')}
|
||||||
className={`${currReact.includes(uid) && styles.reacted}`}
|
className={`${currReact.includes(uid) && styles.reacted}`}
|
||||||
key={key}
|
key={key}
|
||||||
onClick={() => {
|
onClick={(e) => {
|
||||||
|
e.stopPropagation()
|
||||||
onClick(key, currReact.includes(uid))
|
onClick(key, currReact.includes(uid))
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -39,7 +37,6 @@ function ExistingReacts({ existingReacts, onClick, uid }) {
|
||||||
function RenderEmojis({ onClick }) {
|
function RenderEmojis({ onClick }) {
|
||||||
const [search, setSearch] = useState('')
|
const [search, setSearch] = useState('')
|
||||||
|
|
||||||
let index = 0
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<input
|
<input
|
||||||
|
@ -55,10 +52,6 @@ function RenderEmojis({ onClick }) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
{index++ % breakEvery === 0 && (
|
|
||||||
<div key={`${key}_break`} className={styles.break} />
|
|
||||||
)}
|
|
||||||
<div
|
<div
|
||||||
title={key}
|
title={key}
|
||||||
key={key}
|
key={key}
|
||||||
|
@ -68,7 +61,6 @@ function RenderEmojis({ onClick }) {
|
||||||
>
|
>
|
||||||
{reaction.emoji}
|
{reaction.emoji}
|
||||||
</div>
|
</div>
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</>
|
</>
|
||||||
|
@ -81,9 +73,10 @@ export default function ReactButton({ onClick, existingReacts, uid }) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={styles.reactContainer}
|
className={styles.reactContainer}
|
||||||
onMouseEnter={() => {
|
onClick={() => {
|
||||||
setOpened(true)
|
setOpened(true)
|
||||||
}}
|
}}
|
||||||
|
onMouseEnter={() => {}}
|
||||||
onMouseLeave={() => {
|
onMouseLeave={() => {
|
||||||
setOpened(false)
|
setOpened(false)
|
||||||
}}
|
}}
|
||||||
|
@ -93,7 +86,10 @@ export default function ReactButton({ onClick, existingReacts, uid }) {
|
||||||
text={() => (
|
text={() => (
|
||||||
<ExistingReacts
|
<ExistingReacts
|
||||||
uid={uid}
|
uid={uid}
|
||||||
onClick={onClick}
|
onClick={(key, isDelete) => {
|
||||||
|
onClick(key, isDelete)
|
||||||
|
setOpened(false)
|
||||||
|
}}
|
||||||
existingReacts={existingReacts}
|
existingReacts={existingReacts}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -19,10 +19,11 @@
|
||||||
border: 1px solid #444;
|
border: 1px solid #444;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.reactionContainer > div:hover {
|
.reactionContainer > div:hover {
|
||||||
background-color: #666;
|
background-color: var(--hoover-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.break {
|
.break {
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltip .tooltiptext {
|
.tooltip .tooltiptext {
|
||||||
width: 280px;
|
width: 300px;
|
||||||
|
max-width: 300px;
|
||||||
height: 250px;
|
height: 250px;
|
||||||
max-width: 280px;
|
|
||||||
max-height: 250px;
|
max-height: 250px;
|
||||||
background-color: #555;
|
background-color: var(--background-color);
|
||||||
|
border-radius: 5px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
:root {
|
:root {
|
||||||
--text-color: #9999ff;
|
--text-color: #9999ff;
|
||||||
|
--primary-color: #9999ff;
|
||||||
--bright-color: #f2f2f2;
|
--bright-color: #f2f2f2;
|
||||||
--background-color: #222426;
|
--background-color: #222426;
|
||||||
--hoover-color: #202020;
|
--hoover-color: #202020;
|
||||||
|
@ -14,6 +15,23 @@ a {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
color: var(--text-color);
|
||||||
|
background-color: var(--background-color);
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 120px;
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid #666;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
color: var(--text-color);
|
||||||
|
background-color: var(--background-color);
|
||||||
|
border: 1px solid #444;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
.link {
|
.link {
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
@ -263,3 +281,21 @@ select:hover {
|
||||||
.msgs > div {
|
.msgs > div {
|
||||||
margin: 0px 5px;
|
margin: 0px 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions > span {
|
||||||
|
margin: 2px 2px;
|
||||||
|
padding: 0px 10px;
|
||||||
|
border: 1px solid #444;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions > span:hover {
|
||||||
|
background-color: var(--hoover-color);
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import Link from 'next/link'
|
||||||
import LoadingIndicator from '../components/LoadingIndicator'
|
import LoadingIndicator from '../components/LoadingIndicator'
|
||||||
import Sleep from '../components/sleep'
|
import Sleep from '../components/sleep'
|
||||||
import NewsEntry from '../components/newsEntry'
|
import NewsEntry from '../components/newsEntry'
|
||||||
|
import Composer from '../components/composer'
|
||||||
import DbSelector from '../components/dbSelector.js'
|
import DbSelector from '../components/dbSelector.js'
|
||||||
|
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
|
@ -36,6 +37,72 @@ function fetchNews() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addPost(title, content) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
fetch(constants.apiUrl + 'addPost', {
|
||||||
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
title: title,
|
||||||
|
content: content,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
return res.json()
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
resolve(res)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function postFeedback(content, file) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const promises = [
|
||||||
|
fetch(constants.apiUrl + 'postfeedback', {
|
||||||
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
content: content,
|
||||||
|
}),
|
||||||
|
}).then((res) => {
|
||||||
|
return res.json()
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
console.log('FIEEEEEEEEEELE')
|
||||||
|
const formData = new FormData() // eslint-disable-line
|
||||||
|
formData.append('file', file)
|
||||||
|
|
||||||
|
promises.push(
|
||||||
|
fetch(constants.apiUrl + 'postfeedbackfile', {
|
||||||
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
},
|
||||||
|
body: formData,
|
||||||
|
}).then((res) => {
|
||||||
|
return res.json()
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Promise.all(promises).then((res) => {
|
||||||
|
resolve(res)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export default function Index({ globalData }) {
|
export default function Index({ globalData }) {
|
||||||
const userId = globalData.userId
|
const userId = globalData.userId
|
||||||
const motd = globalData.motd
|
const motd = globalData.motd
|
||||||
|
@ -57,6 +124,25 @@ export default function Index({ globalData }) {
|
||||||
let newsEntryData = news[key]
|
let newsEntryData = news[key]
|
||||||
return (
|
return (
|
||||||
<NewsEntry
|
<NewsEntry
|
||||||
|
onPostDelete={() => {
|
||||||
|
fetch(constants.apiUrl + 'rmPost', {
|
||||||
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
newsKey: key,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
return res.json()
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setNews(res.news)
|
||||||
|
})
|
||||||
|
}}
|
||||||
onReact={({ type, path, reaction, isDelete }) => {
|
onReact={({ type, path, reaction, isDelete }) => {
|
||||||
if (type === 'news') {
|
if (type === 'news') {
|
||||||
fetch(constants.apiUrl + 'infos', {
|
fetch(constants.apiUrl + 'infos', {
|
||||||
|
@ -71,11 +157,12 @@ export default function Index({ globalData }) {
|
||||||
newsKey: key,
|
newsKey: key,
|
||||||
isDelete: isDelete,
|
isDelete: isDelete,
|
||||||
}),
|
}),
|
||||||
}).then((res) => {
|
|
||||||
// TODO: dont refetch news
|
|
||||||
fetchNews().then((res) => {
|
|
||||||
setNews(res)
|
|
||||||
})
|
})
|
||||||
|
.then((res) => {
|
||||||
|
return res.json()
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setNews(res.news)
|
||||||
})
|
})
|
||||||
} else if (type === 'comment') {
|
} else if (type === 'comment') {
|
||||||
fetch(constants.apiUrl + 'comment', {
|
fetch(constants.apiUrl + 'comment', {
|
||||||
|
@ -92,10 +179,12 @@ export default function Index({ globalData }) {
|
||||||
reaction: reaction,
|
reaction: reaction,
|
||||||
isDelete: isDelete,
|
isDelete: isDelete,
|
||||||
}),
|
}),
|
||||||
}).then((res) => {
|
|
||||||
fetchNews().then((res) => {
|
|
||||||
setNews(res)
|
|
||||||
})
|
})
|
||||||
|
.then((res) => {
|
||||||
|
return res.json()
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setNews(res.news)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -112,13 +201,15 @@ export default function Index({ globalData }) {
|
||||||
path: path,
|
path: path,
|
||||||
newsKey: key,
|
newsKey: key,
|
||||||
}),
|
}),
|
||||||
}).then(() => {
|
|
||||||
fetchNews().then((res) => {
|
|
||||||
setNews(res)
|
|
||||||
})
|
})
|
||||||
|
.then((res) => {
|
||||||
|
return res.json()
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setNews(res.news)
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
onComment={(path, text) => {
|
onComment={(path, content) => {
|
||||||
fetch(constants.apiUrl + 'comment', {
|
fetch(constants.apiUrl + 'comment', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
|
@ -129,13 +220,15 @@ export default function Index({ globalData }) {
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
type: 'add',
|
type: 'add',
|
||||||
path: path,
|
path: path,
|
||||||
text: text,
|
content: content,
|
||||||
newsKey: key,
|
newsKey: key,
|
||||||
}),
|
}),
|
||||||
}).then(() => {
|
|
||||||
fetchNews().then((res) => {
|
|
||||||
setNews(res)
|
|
||||||
})
|
})
|
||||||
|
.then((res) => {
|
||||||
|
return res.json()
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setNews(res.news)
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
uid={userId}
|
uid={userId}
|
||||||
|
@ -149,8 +242,31 @@ export default function Index({ globalData }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className={styles.title}>News</div>
|
<div className={styles.title}>Forum</div>
|
||||||
<hr />
|
<hr />
|
||||||
|
<Composer
|
||||||
|
onSubmit={(type, title, content, file) => {
|
||||||
|
if (!content) {
|
||||||
|
alert('Üres a tartalom!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log(type, title, content, file)
|
||||||
|
if (type === 'private') {
|
||||||
|
postFeedback(content, file).then((res) => {
|
||||||
|
console.log(res)
|
||||||
|
alert('Privát visszajelzés elküldve!')
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if (!title) {
|
||||||
|
alert('Üres a téma!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
addPost(title, content).then((res) => {
|
||||||
|
setNews(res.news)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<hr />
|
<hr />
|
||||||
<div>{newsItems}</div>
|
<div>{newsItems}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -165,7 +281,6 @@ export default function Index({ globalData }) {
|
||||||
<div>
|
<div>
|
||||||
<div className={styles.title}>MOTD</div>
|
<div className={styles.title}>MOTD</div>
|
||||||
<hr />
|
<hr />
|
||||||
<hr />
|
|
||||||
{motd ? (
|
{motd ? (
|
||||||
<div
|
<div
|
||||||
className={styles.motd}
|
className={styles.motd}
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.clickable:hover {
|
.clickable:hover {
|
||||||
background-color: #666666;
|
background-color: var(--hoover-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.clickable {
|
.clickable {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue