Skip to content

Commit 5914b29

Browse files
translation part5b stage 1
1 parent 85f46a8 commit 5914b29

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

src/content/5/ptbr/part5b.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
mainImage: ../../../images/part-5.svg
33
part: 5
44
letter: b
5-
lang: en
5+
lang: ptbr
66
---
77

88
<div class="content">
99

10-
### Displaying the login form only when appropriate
10+
### Mostrando o formulário de login apenas quando apropriado
1111

12-
Let's modify the application so that the login form is not displayed by default:
12+
Vamos modificar a aplicação para que o formulário de login não seja exibido por padrão:
1313

14-
![browser showing log in button by default](../../images/5/10e.png)
14+
![navegador mostrando o botão de login por padrão](../../images/5/10e.png)
1515

16-
The login form appears when the user presses the <i>login</i> button:
16+
O formulário de login aparece quando o usuário pressiona o botão <i>login</i>:
1717

18-
![user at login screen about to press cancel](../../images/5/11e.png)
18+
![usuário na tela de login prestes a apertar o botão cancelar](../../images/5/11e.png)
1919

20-
The user can close the login form by clicking the <i>cancel</i> button.
20+
O usuário pode fechar o formulário de login clicando no botão <i>cancelar</i>.
2121

22-
Let's start by extracting the login form into its own component:
22+
Vamos começar extraindo o formulário de login para um componente próprio:
2323

2424
```js
2525
const LoginForm = ({
@@ -58,9 +58,9 @@ const LoginForm = ({
5858
export default LoginForm
5959
```
6060

61-
The state and all the functions related to it are defined outside of the component and are passed to the component as props.
61+
O estado e todas as funções relacionadas a ele são definidos fora do componente e são passados para o componente por meio de props.
6262

63-
Notice that the props are assigned to variables through <i>destructuring</i>, which means that instead of writing:
63+
Perceba que as props são atribuídas a variáveis ​​através de <i>destructuring</i>, o que significa que, em vez de escrever:
6464

6565
```js
6666
const LoginForm = (props) => {
@@ -84,9 +84,9 @@ const LoginForm = (props) => {
8484
}
8585
```
8686

87-
where the properties of the _props_ object are accessed through e.g. _props.handleSubmit_, the properties are assigned directly to their own variables.
87+
Onde as propriedades do objeto _props_ são acessadas por meio de, por exemplo, _props.handleSubmit_, as propriedades são atribuídas diretamente às suas próprias variáveis.
8888

89-
One fast way of implementing the functionality is to change the _loginForm_ function of the <i>App</i> component like so:
89+
Uma forma rápida de implementar a funcionalidade é alterar a função _loginForm_ do componente <i>App</i> da seguinte maneira:
9090

9191
```js
9292
const App = () => {
@@ -121,17 +121,17 @@ const App = () => {
121121
}
122122
```
123123

124-
The <i>App</i> components state now contains the boolean <i>loginVisible</i>, which defines if the login form should be shown to the user or not.
124+
O estado do componente <i>App</i> agora contém o boolean <i>loginVisible</i>, que define se o formulário de login deve ser exibido ao usuário ou não.
125125

126-
The value of _loginVisible_ is toggled with two buttons. Both buttons have their event handlers defined directly in the component:
126+
O valor de _loginVisible_ é alternado com dois botões. Ambos os botões têm seus gerenciadores de eventos definidos diretamente no componente:
127127

128128
```js
129129
<button onClick={() => setLoginVisible(true)}>log in</button>
130130

131131
<button onClick={() => setLoginVisible(false)}>cancel</button>
132132
```
133133

134-
The visibility of the component is defined by giving the component an [inline](/en/part2/adding_styles_to_react_app#inline-styles) style rule, where the value of the [display](https://developer.mozilla.org/en-US/docs/Web/CSS/display) property is <i>none</i> if we do not want the component to be displayed:
134+
A visibilidade do componente é definida atribuindo uma regra de estilo [inline](/ptbr/part2/adicionando_estilos_a_aplicacao_react#estilos-inline), onde o valor da propriedade [display](https://developer.mozilla.org/pt-BR/docs/Web/CSS/display) é <i>none</i> se não quisermos que o componente seja exibido:
135135

136136
```js
137137
const hideWhenVisible = { display: loginVisible ? 'none' : '' }
@@ -146,19 +146,19 @@ const showWhenVisible = { display: loginVisible ? '' : 'none' }
146146
</div>
147147
```
148148

149-
We are once again using the "question mark" ternary operator. If _loginVisible_ is <i>true</i>, then the CSS rule of the component will be:
149+
Nós estamos usando novamente o operador ternário "ponto de interrogação". Se _loginVisible_ for <i>true</i>, então a regra CSS do componente será:
150150

151151
```css
152152
display: 'none';
153153
```
154154

155-
If _loginVisible_ is <i>false</i>, then <i>display</i> will not receive any value related to the visibility of the component.
155+
Se _loginVisible_ for <i>false</i>, então <i>display</i> não receberá nenhum valor relacionado à visibilidade do componente.
156156

157-
### The components children, aka. props.children
157+
### Os componentes filhos, conhecidos como props.children
158158

159-
The code related to managing the visibility of the login form could be considered to be its own logical entity, and for this reason, it would be good to extract it from the <i>App</i> component into a separate component.
159+
O código relacionado ao gerenciamento da visibilidade do formulário de login poderia ser considerado uma entidade lógica própria, e por esse motivo, seria bom extrai-lo do componente <i>App</i> para um componente separado.
160160

161-
Our goal is to implement a new <i>Togglable</i> component that can be used in the following way:
161+
Nosso objetivo é implementar um novo componente <i>Togglable</i> que possa ser usado da seguinte maneira:
162162

163163
```js
164164
<Togglable buttonLabel='login'>
@@ -172,9 +172,9 @@ Our goal is to implement a new <i>Togglable</i> component that can be used in th
172172
</Togglable>
173173
```
174174

175-
The way that the component is used is slightly different from our previous components. The component has both opening and closing tags that surround a <i>LoginForm</i> component. In React terminology <i>LoginForm</i> is a child component of <i>Togglable</i>.
175+
A maneira como o componente é usado é ligeiramente diferente dos nossos componentes anteriores. O componente tem tags de abertura e fechamento que cercam um componente <i>LoginForm</i>. Na terminologia React, <i>LoginForm</i> é um componente filho de <i>Togglable</i>.
176176

177-
We can add any React elements we want between the opening and closing tags of <i>Togglable</i>, like this for example:
177+
s podemos adicionar qualquer elemento React que quisermos entre as tags de abertura e fechamento de <i>Togglable</i>, como este, por exemplo:
178178

179179
```js
180180
<Togglable buttonLabel="reveal">
@@ -183,7 +183,7 @@ We can add any React elements we want between the opening and closing tags of <i
183183
</Togglable>
184184
```
185185

186-
The code for the <i>Togglable</i> component is shown below:
186+
O código do componente <i>Togglable</i> é mostrado abaixo:
187187

188188
```js
189189
import { useState } from 'react'
@@ -214,9 +214,10 @@ const Togglable = (props) => {
214214
export default Togglable
215215
```
216216

217-
The new and interesting part of the code is [props.children](https://reactjs.org/docs/glossary.html#propschildren), which is used for referencing the child components of the component. The child components are the React elements that we define between the opening and closing tags of a component.
217+
A nova e interessante parte do código é a [props.children](https://pt-br.reactjs.org/docs/glossary.html#propschildren), que é usada para referenciar os componentes filhos do componente. Os componentes filhos são os elementos React que definimos entre as tags de abertura e fechamento de um componente.
218218

219-
This time the children are rendered in the code that is used for rendering the component itself:
219+
220+
Dessa vez, os filhos são renderizados no código que é usado para renderizar o próprio componente:
220221

221222
```js
222223
<div style={showWhenVisible}>
@@ -225,7 +226,7 @@ This time the children are rendered in the code that is used for rendering the c
225226
</div>
226227
```
227228

228-
Unlike the "normal" props we've seen before, <i>children</i> is automatically added by React and always exists. If a component is defined with an automatically closing _/>_ tag, like this:
229+
Diferente das props "normais" que vimos antes, <i>children</i> é adicionada automaticamente pelo React e sempre existe na aplicação. Se um componente é definido com uma tag de fechamento automático _/>_, como este:
229230

230231
```js
231232
<Note
@@ -235,7 +236,7 @@ Unlike the "normal" props we've seen before, <i>children</i> is automatically ad
235236
/>
236237
```
237238

238-
Then <i>props.children</i> is an empty array.
239+
Então <i>props.children</i> é um array vazio.
239240

240241
The <i>Togglable</i> component is reusable and we can use it to add similar visibility toggling functionality to the form that is used for creating new notes.
241242

0 commit comments

Comments
 (0)