Skip to content

Commit

Permalink
Merge pull request #48 from ICEI-PUC-Minas-PPLCC-TI/develop
Browse files Browse the repository at this point in the history
Adicionando quebra de linha nos conteúdos (posts e projetos)
  • Loading branch information
andreeluis authored Dec 2, 2023
2 parents 377738e + c0ecd86 commit 9943a8a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/forum/assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ async function showPosts() {
try {
await loadPosts();

const textoHTML = postsList.map(generateHTML).join('');
orderPostsList = orderList();

const textoHTML = orderPostsList.map(generateHTML).join('');

document.querySelector("#posts").innerHTML = textoHTML;

Expand Down Expand Up @@ -186,20 +188,18 @@ async function deletePost() {


// ORDER POSTS
document.querySelector('.order').addEventListener('input', order, false);
document.querySelector('.order').addEventListener('input', showPosts, false);

function order() {
function orderList()
{
const orderType = document.querySelector('#order').value;
console.log(orderType);

const sortFunctions = {
'date': (a, b) => new Date(b.dataPostagem) - new Date(a.dataPostagem),
'likes': (a, b) => b.curtidas - a.curtidas
};

if (sortFunctions[orderType]) {
const sortedPosts = postsList.sort(sortFunctions[orderType]);
const textoHTML = sortedPosts.map(generateHTML).join('');
document.querySelector("#posts").innerHTML = textoHTML;
return postsList.sort(sortFunctions[orderType]);
}
}
2 changes: 1 addition & 1 deletion src/forum/assets/js/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function showPost() {
document.querySelector('.autor').innerHTML = post.autor;


document.querySelector('.conteudo').innerHTML = `<p>${post.conteudo}</p>`;
document.querySelector('.conteudo').innerHTML = `<p>${post.conteudo.replaceAll('\n', '<br>')}</p>`;

document.querySelector('.comentarios').innerHTML = `${comentariosHTML}`;

Expand Down
14 changes: 14 additions & 0 deletions src/projetos/assets/css/projetos.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,17 @@
.itens-list article p.hard {
background-color: var(--light-red);
}


p.categoria {
display: inline-block;
padding: .3em .6em;
background-color: var(--grey);
color: var(--white);
font-weight: bold;
border-radius: .5vmax;
}

.conteudo {
margin: 2em 1em 0;
}
2 changes: 1 addition & 1 deletion src/projetos/assets/js/projeto.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function showProject() {
document.querySelector('.autor').innerHTML = project.autor;


document.querySelector('.conteudo').innerHTML = `<p>${project.conteudo}</p>`;
document.querySelector('.conteudo').innerHTML = `<p>${project.conteudo.replaceAll('\n', '<br>')}</p>`;
} catch (error) {
console.error('Falha ao carregar e exibir os posts:', error);
}
Expand Down

0 comments on commit 9943a8a

Please sign in to comment.