Merge branch 'master' into new_style

This commit is contained in:
mrfry 2021-03-06 14:54:49 +01:00
commit 843f0a7dad
6 changed files with 58 additions and 56 deletions

View file

@ -1,5 +1,5 @@
.modal { .modal {
z-index: 9999; z-index: 99;
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;

View file

@ -8,7 +8,8 @@ import styles from './newsEntry.module.css'
export default function NewsEntry({ export default function NewsEntry({
newsItem, newsItem,
uid, uid,
onReact, onCommentReact,
onNewsReact,
onComment, onComment,
onDelete, onDelete,
onPostDelete, onPostDelete,
@ -19,19 +20,20 @@ export default function NewsEntry({
<div className={styles.newsRoot}> <div className={styles.newsRoot}>
<div className={`${styles.newsContainer} ${admin && styles.adminPost}`}> <div className={`${styles.newsContainer} ${admin && styles.adminPost}`}>
<div className={styles.newsHeader}> <div className={styles.newsHeader}>
<div <div className={styles.newsTitle}>{title}</div>
className={styles.newsTitle}
dangerouslySetInnerHTML={{ __html: title }}
/>
<div className={styles.user}> <div className={styles.user}>
<div>User #{user}</div> <div>User #{user}</div>
<div className={styles.newsDate}>{date}</div> <div className={styles.newsDate}>{date}</div>
</div> </div>
</div> </div>
{admin ? (
<div <div
className={styles.newsBody} className={styles.newsBody}
dangerouslySetInnerHTML={{ __html: content }} dangerouslySetInnerHTML={{ __html: content }}
/> />
) : (
<div className={styles.newsBody}>{content}</div>
)}
</div> </div>
<div className={'actions'}> <div className={'actions'}>
{uid === user ? ( {uid === user ? (
@ -47,14 +49,14 @@ export default function NewsEntry({
existingReacts={reacts} existingReacts={reacts}
uid={uid} uid={uid}
onClick={(reaction, isDelete) => { onClick={(reaction, isDelete) => {
onReact({ type: 'news', reaction, isDelete }) onNewsReact({ reaction, isDelete })
}} }}
/> />
</div> </div>
<Comments <Comments
uid={uid} uid={uid}
onReact={(path, reaction, isDelete) => { onReact={(path, reaction, isDelete) => {
onReact({ type: 'comment', path, reaction, isDelete }) onCommentReact({ path, reaction, isDelete })
}} }}
onComment={onComment} onComment={onComment}
onDelete={onDelete} onDelete={onDelete}

View file

@ -1,6 +1,7 @@
.newsBody { .newsBody {
margin: 0px 5px; margin: 0px 5px;
color: #fff; color: #fff;
white-space: pre-line;
} }
.newsTitle { .newsTitle {

View file

@ -76,7 +76,6 @@ export default function ReactButton({ onClick, existingReacts, uid }) {
onClick={() => { onClick={() => {
setOpened(true) setOpened(true)
}} }}
onMouseEnter={() => {}}
onMouseLeave={() => { onMouseLeave={() => {
setOpened(false) setOpened(false)
}} }}

View file

@ -15,7 +15,7 @@
border-radius: 6px; border-radius: 6px;
padding: 5px; padding: 5px;
position: absolute; position: absolute;
z-index: 1; z-index: 9999;
bottom: 100%; bottom: 100%;
left: 0%; left: 0%;
margin-left: -60px; margin-left: -60px;

View file

@ -143,9 +143,8 @@ export default function Index({ globalData }) {
setNews(res.news) setNews(res.news)
}) })
}} }}
onReact={({ type, path, reaction, isDelete }) => { onNewsReact={({ reaction, isDelete }) => {
if (type === 'news') { fetch(constants.apiUrl + 'react', {
fetch(constants.apiUrl + 'infos', {
method: 'POST', method: 'POST',
credentials: 'include', credentials: 'include',
headers: { headers: {
@ -153,7 +152,7 @@ export default function Index({ globalData }) {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ body: JSON.stringify({
react: reaction, reaction: reaction,
newsKey: key, newsKey: key,
isDelete: isDelete, isDelete: isDelete,
}), }),
@ -162,10 +161,12 @@ export default function Index({ globalData }) {
return res.json() return res.json()
}) })
.then((res) => { .then((res) => {
console.log(res)
setNews(res.news) setNews(res.news)
}) })
} else if (type === 'comment') { }}
fetch(constants.apiUrl + 'comment', { onCommentReact={({ path, reaction, isDelete }) => {
fetch(constants.apiUrl + 'react', {
method: 'POST', method: 'POST',
credentials: 'include', credentials: 'include',
headers: { headers: {
@ -186,7 +187,6 @@ export default function Index({ globalData }) {
.then((res) => { .then((res) => {
setNews(res.news) setNews(res.news)
}) })
}
}} }}
onDelete={(path) => { onDelete={(path) => {
fetch(constants.apiUrl + 'comment', { fetch(constants.apiUrl + 'comment', {