Skip to content

Browser Environment Eval Project#229

Open
cjedrasik03 wants to merge 1 commit intoprojectshft:masterfrom
cjedrasik03:master
Open

Browser Environment Eval Project#229
cjedrasik03 wants to merge 1 commit intoprojectshft:masterfrom
cjedrasik03:master

Conversation

@cjedrasik03
Copy link

No description provided.

// Wrapper div for grouping all post-related elements
let postWrapper = document.createElement('div');
postWrapper.classList.add('post-wrapper');
postWrapper.style.marginBottom = '20px'; // Optional spacing between posts

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hardcoding styles, you could use Bootstrap’s spacing utilities (mt-2, mb-3)

@@ -0,0 +1,3 @@
textarea {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never use the element as css identifier, use class or id.

deletePostButton.style.marginTop = '10px';

// Add functionality to delete the entire post
deletePostButton.addEventListener('click', function () {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use event delegation

document.querySelector('.posts').addEventListener('click', function (e) {
  if (e.target.classList.contains('btn-danger')) {
    e.target.closest('.post-wrapper').remove();
  }
});

Way more efficient

commentsThread.classList.add('comments-thread');

// Initially, comments thread is hidden
commentsThread.style.display = 'none';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use css classes, its a better practice
.hidden {
display: none;
}
then here
commentsThread.classList.toggle('hidden');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments