From 41de3316bc1ed9efaba6f51fecd156bf3f9bc810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lu=C3=ADs?= Date: Sat, 2 Dec 2023 10:54:03 -0300 Subject: [PATCH 1/2] =?UTF-8?q?Refatorando=20fun=C3=A7=C3=A3o=20de=20orden?= =?UTF-8?q?amento=20de=20post?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forum/assets/js/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/forum/assets/js/index.js b/src/forum/assets/js/index.js index 5eddadc..fb28eae 100644 --- a/src/forum/assets/js/index.js +++ b/src/forum/assets/js/index.js @@ -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; @@ -186,11 +188,11 @@ 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), @@ -198,8 +200,6 @@ function order() { }; 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]); } } From c0ecd8698b1b020087c1a63357fd4f8ad8e693cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lu=C3=ADs?= Date: Sat, 2 Dec 2023 11:01:39 -0300 Subject: [PATCH 2/2] Adicionando quebra de linha nos posts e projetos --- src/forum/assets/js/posts.js | 2 +- src/projetos/assets/css/projetos.css | 14 ++++++++++++++ src/projetos/assets/js/projeto.js | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/forum/assets/js/posts.js b/src/forum/assets/js/posts.js index 63e2b06..b37bfcf 100644 --- a/src/forum/assets/js/posts.js +++ b/src/forum/assets/js/posts.js @@ -42,7 +42,7 @@ async function showPost() { document.querySelector('.autor').innerHTML = post.autor; - document.querySelector('.conteudo').innerHTML = `

${post.conteudo}

`; + document.querySelector('.conteudo').innerHTML = `

${post.conteudo.replaceAll('\n', '
')}

`; document.querySelector('.comentarios').innerHTML = `${comentariosHTML}`; diff --git a/src/projetos/assets/css/projetos.css b/src/projetos/assets/css/projetos.css index 5eea88c..d0573d0 100644 --- a/src/projetos/assets/css/projetos.css +++ b/src/projetos/assets/css/projetos.css @@ -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; +} diff --git a/src/projetos/assets/js/projeto.js b/src/projetos/assets/js/projeto.js index 65fd176..5efcc3e 100644 --- a/src/projetos/assets/js/projeto.js +++ b/src/projetos/assets/js/projeto.js @@ -17,7 +17,7 @@ async function showProject() { document.querySelector('.autor').innerHTML = project.autor; - document.querySelector('.conteudo').innerHTML = `

${project.conteudo}

`; + document.querySelector('.conteudo').innerHTML = `

${project.conteudo.replaceAll('\n', '
')}

`; } catch (error) { console.error('Falha ao carregar e exibir os posts:', error); }