You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/5/ptbr/part5b.md
+28-27Lines changed: 28 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,24 +2,24 @@
2
2
mainImage: ../../../images/part-5.svg
3
3
part: 5
4
4
letter: b
5
-
lang: en
5
+
lang: ptbr
6
6
---
7
7
8
8
<divclass="content">
9
9
10
-
### Displaying the login form only when appropriate
10
+
### Mostrando o formulário de login apenas quando apropriado
11
11
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:
13
13
14
-

14
+

15
15
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>:
17
17
18
-

18
+

19
19
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>.
21
21
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:
23
23
24
24
```js
25
25
constLoginForm= ({
@@ -58,9 +58,9 @@ const LoginForm = ({
58
58
exportdefaultLoginForm
59
59
```
60
60
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.
62
62
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:
64
64
65
65
```js
66
66
constLoginForm= (props) => {
@@ -84,9 +84,9 @@ const LoginForm = (props) => {
84
84
}
85
85
```
86
86
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.
88
88
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:
90
90
91
91
```js
92
92
constApp= () => {
@@ -121,17 +121,17 @@ const App = () => {
121
121
}
122
122
```
123
123
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.
125
125
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:
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:
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á:
150
150
151
151
```css
152
152
display: 'none';
153
153
```
154
154
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.
156
156
157
-
### The components children, aka. props.children
157
+
### Os componentes filhos, conhecidos como props.children
158
158
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.
160
160
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:
162
162
163
163
```js
164
164
<Togglable buttonLabel='login'>
@@ -172,9 +172,9 @@ Our goal is to implement a new <i>Togglable</i> component that can be used in th
172
172
</Togglable>
173
173
```
174
174
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>.
176
176
177
-
We can add any React elements we want between the opening and closing tags of <i>Togglable</i>, like this for example:
177
+
Nós podemos adicionar qualquer elemento React que quisermos entre as tags de abertura e fechamento de <i>Togglable</i>, como este, por exemplo:
178
178
179
179
```js
180
180
<Togglable buttonLabel="reveal">
@@ -183,7 +183,7 @@ We can add any React elements we want between the opening and closing tags of <i
183
183
</Togglable>
184
184
```
185
185
186
-
The code for the <i>Togglable</i>component is shown below:
186
+
O código do componente <i>Togglable</i>é mostrado abaixo:
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.
218
218
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:
220
221
221
222
```js
222
223
<div style={showWhenVisible}>
@@ -225,7 +226,7 @@ This time the children are rendered in the code that is used for rendering the c
225
226
</div>
226
227
```
227
228
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:
229
230
230
231
```js
231
232
<Note
@@ -235,7 +236,7 @@ Unlike the "normal" props we've seen before, <i>children</i> is automatically ad
235
236
/>
236
237
```
237
238
238
-
Then <i>props.children</i> is an empty array.
239
+
Então <i>props.children</i> é um array vazio.
239
240
240
241
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.
0 commit comments