Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exibir tabela de conteúdos (links para os títulos) na publicação #1686

Closed
wants to merge 1 commit into from

Conversation

wendesongomes
Copy link

@wendesongomes wendesongomes commented May 2, 2024

Mudanças realizadas

(Removi o outro PR sem querer)

Exibir tabela de conteúdos (links para os títulos) na publicação

image

aberto:

image

Resolve #1679

Copy link

vercel bot commented May 2, 2024

@wendesongomes is attempting to deploy a commit to the TabNews Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Collaborator

@Rafatcb Rafatcb left a comment

Choose a reason for hiding this comment

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

Não cheguei a testar como ficou na prática após essas alterações, mas deixei alguns comentários. A maioria são coisas simples. Foram boas alterações 🤝

Se me surgir alguma ideia de solução melhor para o uso do componente e para a identificação dos títulos, eu crio outro comentário aqui.

const [isOpenDialogTopics, setOpenDialogTopics] = useState(false);
const returnFocusRefDialogTopics = useRef(null);

// set overflow on body to 'hidden' when dialog is open
Copy link
Collaborator

Choose a reason for hiding this comment

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

Não precisa desse comentário, pelo código dá para entender o que é feito.

import { Head } from 'pages/interface';

export default function DefaultLayout({ children, containerWidth = 'large', metadata }) {
const [isOpenDialogTopics, setOpenDialogTopics] = useState(false);
const returnFocusRefDialogTopics = useRef(null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pelo o que entendi, isso não está sendo usado, certo? Ainda não testei após as alterações usando o Primer para ver se o foco está sendo retornado corretamente.

setHeadings(Array.from(updatedHeadingsElements));
};

useEffect(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Por motivos de organização, e também tem um pouco a ver com as regras dos hooks, é melhor chamar todos os hooks antes de declarar outras funções.

Comment on lines +1 to +4
import { Box, Dialog } from '@primer/react';
import { useEffect, useRef, useState } from 'react';

import { Link } from '@/Link';
Copy link
Collaborator

Choose a reason for hiding this comment

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

No projeto temos um padrão para importar elementos visuais pelo @/TabNewsUI, isso facilita a substituição quando necessário. Então, ficaria assim:

Suggested change
import { Box, Dialog } from '@primer/react';
import { useEffect, useRef, useState } from 'react';
import { Link } from '@/Link';
import { useEffect, useRef, useState } from 'react';
import { Box, Dialog, Link } from '@/TabNewsUI';

E se você está usando um componente novo que ainda não é exportado pelo TabNewsUI/index.js, como é o caso do Dialog, basta adicionar a exportação lá (está em ordem alfabética).

Comment on lines +37 to +46
margin: 0,
left: 'auto',
right: 0,
maxHeight: '100vh',
height: '100vh',
transform: 'translate(0)',
overflow: 'auto',
padding: 4,
'@media screen and (max-width: 750px)': {
maxHeight: '100vh',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Aqui me parece que ainda tem mais estilos do que precisa. Não cheguei a testar para ver quais podem ser removidos, mas reparei que o maxHeight é declarado com o mesmo valor duas vezes, por exemplo. Tem algum motivo para usar a media query aqui, ou era algo que você estava testando e esqueceu de remover?

Copy link
Author

Choose a reason for hiding this comment

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

o maxHeight do media coloquei e esqueci de tirar, mas eu preciso colocar esses estilos para resetar o do próprio dialog para colocar do lado direito, pois o q esta na documentação n esta funcionando

@@ -0,0 +1,39 @@
import { ListUnorderedIcon } from '@primer/octicons-react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Já comentei sobre a importação de elementos visuais, mas no caso de ícones, importamos de @/TabNewsUI/icons.

Comment on lines +10 to +12
const updatedHeadingsElements = document.querySelectorAll(
'.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6',
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Essa solução está melhor do que o Regex, apesar de ainda ter alguns problemas. Seria interessante conseguirmos uma solução melhor. Vi que esse componente é usado no DefaultLayout, e por isso acho que não está sendo feito da melhor maneira, já que todas as páginas terão esse componente que não necessariamente faz sentido.

Não estou falando que você precisa resolver isso sozinho, é que ainda não tive uma ideia para isso. Se outra pessoa estiver vendo esse PR, pode contribuir também.

Copy link
Author

Choose a reason for hiding this comment

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

sim ele fica no defaultLayout, mas pelo o que eu vi o .markdown-body só existe nas postagens mesmo, mas vou dar uma olhada de como melhorar esse código, sobre as importações erradas, por algum motivo ele não importou do lugar certo e eu n tinha percebido, e muito obrigado pelas dicas

headings.length > 0 && (
<IconButton
variant="invisible"
aria-label="Retornar ao topo"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Label errado. Uma sugestão:

Suggested change
aria-label="Retornar ao topo"
aria-label="Exibir tabela de conteúdos"

Chamar de "tabela de conteúdo", que é uma tradução literal de "table of contents" (ToC), parece fazer mais sentido para mim do que chamar de "tópicos", mas talvez "índice" ou "sumário" fique melhor. Não sei como as plataformas costumam chamar isso em português.

@@ -0,0 +1,17 @@
import { Box } from '@primer/react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
import { Box } from '@primer/react';
import { Box } from '@/TabNewsUI';

Comment on lines +10 to +11
// hierarchy effect in dialog
const hierarchyEffect = (tag) => (Number(tag) - 1) * 20;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Aqui também não precisa do comentário, mas provavelmente poderia ter um nome melhor. Talvez getHeadingTabSize?

@Rafatcb Rafatcb added front Envolve modificações no frontend novo recurso Nova funcionalidade/recurso labels May 11, 2024
@Rafatcb Rafatcb added the pendente Aguardando ação do autor do Pull Request label May 18, 2024
@Rafatcb
Copy link
Collaborator

Rafatcb commented May 29, 2024

@wendesongomes você conseguirá realizar as alterações que comentei na revisão? Se não conseguir, não tem problema, mas fecharei o PR para organizar o repositório e deixarei como referência no issue para quando alguém for continuar a implementação, já que possivelmente o código ou a discussão podem ser "reaproveitados".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front Envolve modificações no frontend novo recurso Nova funcionalidade/recurso pendente Aguardando ação do autor do Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exibir tabela de conteúdos (links para os títulos) na publicação
2 participants