mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add fully styled author edits ui and tested logic
This commit is contained in:
@@ -7,6 +7,7 @@ import Draggable from 'react-draggable';
|
|||||||
|
|
||||||
const EditModal = ({ isOpen, closeModal, originalCommentContent }) => {
|
const EditModal = ({ isOpen, closeModal, originalCommentContent }) => {
|
||||||
const {
|
const {
|
||||||
|
setEditedComment,
|
||||||
selectedStyle,
|
selectedStyle,
|
||||||
} = useGeneralStore(state => state);
|
} = useGeneralStore(state => state);
|
||||||
|
|
||||||
@@ -27,6 +28,10 @@ const EditModal = ({ isOpen, closeModal, originalCommentContent }) => {
|
|||||||
}, [setIsMobile]);
|
}, [setIsMobile]);
|
||||||
|
|
||||||
|
|
||||||
|
const handleSaveEdit = () => {
|
||||||
|
setEditedComment(commentRef.current.value);
|
||||||
|
closeModal();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledModal
|
<StyledModal
|
||||||
@@ -47,13 +52,14 @@ const EditModal = ({ isOpen, closeModal, originalCommentContent }) => {
|
|||||||
<div className="textarea-wrapper">
|
<div className="textarea-wrapper">
|
||||||
<textarea className="textarea"
|
<textarea className="textarea"
|
||||||
rows="4"
|
rows="4"
|
||||||
|
style={{paddingTop: '0'}}
|
||||||
placeholder="Comment"
|
placeholder="Comment"
|
||||||
defaultValue={originalCommentContent}
|
defaultValue={originalCommentContent}
|
||||||
wrap="soft"
|
wrap="soft"
|
||||||
ref={commentRef} />
|
ref={commentRef} />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button id="next">Save</button>
|
<button id="next" onClick={handleSaveEdit}>Save</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3208,17 +3208,76 @@ export const Footer = styled.div`
|
|||||||
|
|
||||||
export const AuthorDeleteAlert = styled.div`
|
export const AuthorDeleteAlert = styled.div`
|
||||||
.author-delete-alert {
|
.author-delete-alert {
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
background: #fff;
|
border: 1px solid #ccc;
|
||||||
border-radius: 5px;
|
|
||||||
box-shadow: 0 0 10px 0 rgba(0,0,0,.25);
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 40%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
|
|
||||||
|
.author-delete-buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
& > button {
|
||||||
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& > button:first-child {
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
${({ selectedStyle }) => {
|
||||||
|
switch (selectedStyle) {
|
||||||
|
case 'Yotsuba':
|
||||||
|
return `
|
||||||
|
.author-delete-alert {
|
||||||
|
background-color: #f0e0d6;
|
||||||
|
border: 1px solid #d9bfb7;
|
||||||
|
}`;
|
||||||
|
|
||||||
|
case 'Yotsuba-B':
|
||||||
|
return `
|
||||||
|
.author-delete-alert {
|
||||||
|
background-color: #d6daf0;
|
||||||
|
border: 1px solid #b7c5d9;
|
||||||
|
}`;
|
||||||
|
|
||||||
|
case 'Futaba':
|
||||||
|
return `
|
||||||
|
.author-delete-alert {
|
||||||
|
background-color: #f0e0d6;
|
||||||
|
border: 1px solid #d9bfb7;
|
||||||
|
}`;
|
||||||
|
|
||||||
|
case 'Burichan':
|
||||||
|
return `
|
||||||
|
.author-delete-alert {
|
||||||
|
background-color: #d6daf0;
|
||||||
|
border: 1px solid #b7c5d9;
|
||||||
|
}`;
|
||||||
|
|
||||||
|
case 'Tomorrow':
|
||||||
|
return `
|
||||||
|
.author-delete-alert {
|
||||||
|
background-color: #282a2e;
|
||||||
|
border: 1px solid #111;
|
||||||
|
}`;
|
||||||
|
|
||||||
|
case 'Photon':
|
||||||
|
return `
|
||||||
|
.author-delete-alert {
|
||||||
|
background-color: #ddd;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}`;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}}
|
||||||
`;
|
`;
|
||||||
@@ -37,6 +37,7 @@ const Thread = () => {
|
|||||||
captchaResponse, setCaptchaResponse,
|
captchaResponse, setCaptchaResponse,
|
||||||
setChallengesArray,
|
setChallengesArray,
|
||||||
defaultSubplebbits,
|
defaultSubplebbits,
|
||||||
|
editedComment,
|
||||||
setIsCaptchaOpen,
|
setIsCaptchaOpen,
|
||||||
isModerationOpen, setIsModerationOpen,
|
isModerationOpen, setIsModerationOpen,
|
||||||
isSettingsOpen, setIsSettingsOpen,
|
isSettingsOpen, setIsSettingsOpen,
|
||||||
@@ -78,7 +79,6 @@ const Thread = () => {
|
|||||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||||
const [isModerator, setIsModerator] = useState(false);
|
const [isModerator, setIsModerator] = useState(false);
|
||||||
const [commentCid, setCommentCid] = useState(null);
|
const [commentCid, setCommentCid] = useState(null);
|
||||||
const [editedComment, setEditedComment] = useState(null);
|
|
||||||
|
|
||||||
useError(errorMessage, [errorMessage]);
|
useError(errorMessage, [errorMessage]);
|
||||||
useSuccess(successMessage, [successMessage]);
|
useSuccess(successMessage, [successMessage]);
|
||||||
@@ -339,6 +339,7 @@ const Thread = () => {
|
|||||||
|
|
||||||
const [publishCommentEditOptions, setPublishCommentEditOptions] = useState({
|
const [publishCommentEditOptions, setPublishCommentEditOptions] = useState({
|
||||||
commentCid: commentCid,
|
commentCid: commentCid,
|
||||||
|
content: editedComment || undefined,
|
||||||
subplebbitAddress: selectedAddress,
|
subplebbitAddress: selectedAddress,
|
||||||
onChallenge,
|
onChallenge,
|
||||||
onChallengeVerification,
|
onChallengeVerification,
|
||||||
@@ -366,6 +367,7 @@ const Thread = () => {
|
|||||||
<AuthorDeleteAlert selectedStyle={selectedStyle}>
|
<AuthorDeleteAlert selectedStyle={selectedStyle}>
|
||||||
<div className='author-delete-alert'>
|
<div className='author-delete-alert'>
|
||||||
<p>Are you sure you want to delete this post?</p>
|
<p>Are you sure you want to delete this post?</p>
|
||||||
|
<div className="author-delete-buttons">
|
||||||
<button onClick={onClose}>No</button>
|
<button onClick={onClose}>No</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -381,6 +383,7 @@ const Thread = () => {
|
|||||||
Yes
|
Yes
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</AuthorDeleteAlert>
|
</AuthorDeleteAlert>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -399,8 +402,16 @@ const Thread = () => {
|
|||||||
setPublishCommentEditOptions((prevOptions) => ({
|
setPublishCommentEditOptions((prevOptions) => ({
|
||||||
...prevOptions,
|
...prevOptions,
|
||||||
commentCid: commentCid,
|
commentCid: commentCid,
|
||||||
|
content: editedComment || undefined,
|
||||||
}));
|
}));
|
||||||
}, [commentCid]);
|
}, [commentCid, editedComment]);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (editedComment !== '') {
|
||||||
|
setTriggerPublishCommentEdit(true);
|
||||||
|
}
|
||||||
|
}, [editedComment]);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -803,7 +814,7 @@ const Thread = () => {
|
|||||||
{comment?.author?.shortAddress === account?.author?.shortAddress ? (
|
{comment?.author?.shortAddress === account?.author?.shortAddress ? (
|
||||||
<>
|
<>
|
||||||
<li onClick={() => handleAuthorEditClick(comment)}>Edit post</li>
|
<li onClick={() => handleAuthorEditClick(comment)}>Edit post</li>
|
||||||
<li onClick={() => handleAuthorDeleteClick(comment.cid)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(comment.cid, selectedStyle)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{isModerator ? (
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ const useGeneralStore = create((set) => ({
|
|||||||
defaultSubplebbits: [],
|
defaultSubplebbits: [],
|
||||||
setDefaultSubplebbits: (subplebbits) => set({ defaultSubplebbits: subplebbits }),
|
setDefaultSubplebbits: (subplebbits) => set({ defaultSubplebbits: subplebbits }),
|
||||||
|
|
||||||
|
editedComment: '',
|
||||||
|
setEditedComment: (comment) => set({ editedComment: comment }),
|
||||||
|
|
||||||
isCaptchaOpen: false,
|
isCaptchaOpen: false,
|
||||||
setIsCaptchaOpen: (isOpen) => set({ isCaptchaOpen: isOpen }),
|
setIsCaptchaOpen: (isOpen) => set({ isCaptchaOpen: isOpen }),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user