-
Notifications
You must be signed in to change notification settings - Fork 1
Implement dark theme #12
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
Conversation
This will avoid rerendering this list each time a state changes.
|
Visit the preview URL for this PR (updated for commit 915975d): https://podcodar-webapp--pr12-marco-add-dark-theme-km5zjbex.web.app (expires Tue, 24 Aug 2021 15:55:42 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
frattezi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apenas algumas perguntinhas
| const { isOpen, onOpen, onClose } = useDisclosure(); | ||
| const navbarBgColor = useColorModeValue('gray.50', 'gray.900'); | ||
| const actionButtons = useMemo( | ||
| () => [...socialIcons, <ToggleThemeButton key="toggle-theme" />], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
não entendi mto bem o useMemo aqui com o array vazio, oque ele está otimizando neste caso? N seria o objetivo colocar a variável de colorMode como condicionador ou algo assim?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Na verdade o botão ja tem seus estados internos né. A ideia aqui é simplesmente evitar re-renderizar a actionButtons sempre que algum estado mudar.
Neste componentes temos por exemplo o estado de isOpen. Sempre que ele for atualizado, sem o useMemo a listagem será obrigatoriamente criada de novo, mesmo não precisando, já que suas props (inexistentes no caso) não mudaram.
Como o ToggleThemeButton não tem props, a lista de dependência do useMemo é vazia. Se ele tivesse alguma props, ai essa lista deveria conter todos os estado usados como dependências.
Descrição
Este PR adiciona a funcionalidade de alterar o tema da página.
Vale notar o uso do hook de cores
useColorModeValueusado para definir uma cor para cada tema (light/dark).Changes
Notes