Skip to content

Commit 84f596f

Browse files
authored
docs: add portuguese translation to class and style section
docs: portuguese translation #3 "guide/class-and-style.md"
1 parent 489501c commit 84f596f

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

src/guide/class-and-style.md

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# Class and Style Bindings
1+
# Interligações de Classe e Estilo
22

3-
A common need for data binding is manipulating an element's class list and its inline styles. Since they are both attributes, we can use `v-bind` to handle them: we only need to calculate a final string with our expressions. However, meddling with string concatenation is annoying and error-prone. For this reason, Vue provides special enhancements when `v-bind` is used with `class` and `style`. In addition to strings, the expressions can also evaluate to objects or arrays.
3+
Uma necessidade comum de interligação de dados é manipular as classes dos elementos e seus estilos _inline_. Uma vez que ambos são atributos, podemos usar `v-bind` para lidar com eles: apenas precisamos calcular uma String final com nossas expressões. No entanto, mexer com concatenação de String é irritante e propenso a erros. Por esta razão, Vue fornece aprimoramentos especiais quando `v-bind` é usado com `class` e `style`. Além de Strings, as expressões também podem avaliar Objetos ou Arrays.
44

5-
## Binding HTML Classes
5+
## Interligando Classes HTML
66

7-
### Object Syntax
7+
### Sintaxe do Objeto
88

9-
We can pass an object to `:class` (short for `v-bind:class`) to dynamically toggle classes:
9+
Podemos passar um objeto para `:class` (abreviação de `v-bind:class`) para alternar classes dinamicamente:
1010

1111
```html
1212
<div :class="{ active: isActive }"></div>
1313
```
1414

15-
The above syntax means the presence of the `active` class will be determined by the [truthiness](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) of the data property `isActive`.
15+
A sintaxe acima significa que a presença da classe `active` será determinada pela [veracidade](https://developer.mozilla.org/pt-BR/docs/Glossary/Truthy) do valor do dado `isActive`.
1616

17-
You can have multiple classes toggled by having more fields in the object. In addition, the `:class` directive can also co-exist with the plain `class` attribute. So given the following template:
17+
Você pode ter múltiplas classes alternadas tendo mais campos no objeto. Além disso, a diretiva `:class` também pode coexistir com um atributo de classe "normal". Então, dado o seguinte modelo:
1818

1919
```html
2020
<div
@@ -23,7 +23,7 @@ You can have multiple classes toggled by having more fields in the object. In ad
2323
></div>
2424
```
2525

26-
And the following data:
26+
E os seguintes dados:
2727

2828
```js
2929
data() {
@@ -34,15 +34,15 @@ data() {
3434
}
3535
```
3636

37-
It will render:
37+
Irá renderizar:
3838

3939
```html
4040
<div class="static active"></div>
4141
```
4242

43-
When `isActive` or `hasError` changes, the class list will be updated accordingly. For example, if `hasError` becomes `true`, the class list will become `"static active text-danger"`.
43+
Quando `isActive` ou `hasError` mudar, a lista de classes será atualizada correspondentemente. Por exemplo, se `hasError` é `true`, a lista de classes será `"static active text-danger"`.
4444

45-
The bound object doesn't have to be inline:
45+
O objeto vinculado não precisa estar diretamente no _template_:
4646

4747
```html
4848
<div :class="classObject"></div>
@@ -59,7 +59,7 @@ data() {
5959
}
6060
```
6161

62-
This will render the same result. We can also bind to a [computed property](computed.md) that returns an object. This is a common and powerful pattern:
62+
Isso irá renderizar o mesmo resultado. Podemos também interligar a um [dado computado](computed.md) que retorne um objeto. Este é um padrão comum e poderoso:
6363

6464
```html
6565
<div :class="classObject"></div>
@@ -82,9 +82,9 @@ computed: {
8282
}
8383
```
8484

85-
### Array Syntax
85+
### Sintaxe de Array
8686

87-
We can pass an array to `:class` to apply a list of classes:
87+
Podemos passar um Array para `:class` para aplicar uma lista de classes:
8888

8989
```html
9090
<div :class="[activeClass, errorClass]"></div>
@@ -99,69 +99,69 @@ data() {
9999
}
100100
```
101101

102-
Which will render:
102+
Que renderizará:
103103

104104
```html
105105
<div class="active text-danger"></div>
106106
```
107107

108-
If you would like to also toggle a class in the list conditionally, you can do it with a ternary expression:
108+
Se você preferir também alternar entre uma classe na lista condicionalmente, use uma expressão ternária:
109109

110110
```html
111111
<div :class="[isActive ? activeClass : '', errorClass]"></div>
112112
```
113113

114-
This will always apply `errorClass`, but will only apply `activeClass` when `isActive` is truthy.
114+
Isso sempre aplicará `errorClass`, mas somente aplicará `activeClass` quando `isActive` for verdadeiro.
115115

116-
However, this can be a bit verbose if you have multiple conditional classes. That's why it's also possible to use the object syntax inside array syntax:
116+
No entanto, isso pode ser um tanto prolixo se você tiver várias classes condicionais. Por isso também é possível usar a sintaxe de objeto dentro da sintaxe de Array:
117117

118118
```html
119119
<div :class="[{ active: isActive }, errorClass]"></div>
120120
```
121121

122-
### With Components
122+
### Com Componentes
123123

124-
> This section assumes knowledge of [Vue Components](component-basics.md). Feel free to skip it and come back later.
124+
> Esta seção assume conhecimento sobre [Componentes Vue](component-basics.md). Pode pular esta parte e voltar depois.
125125
126-
When you use the `class` attribute on a custom component with a single root element, those classes will be added to this element. Existing classes on this element will not be overwritten.
126+
Quando você usa o atributo `class` em um componente personalizado com um único elemento raiz, essas classes serão adicionadas a este elemento. As classes existentes neste elemento não serão substituídas.
127127

128-
For example, if you declare this component:
128+
Por exemplo, se você declarar este componente:
129129

130130
```js
131131
const app = Vue.createApp({})
132132

133133
app.component('my-component', {
134-
template: `<p class="foo bar">Hi!</p>`
134+
template: `<p class="foo bar">Oi!</p>`
135135
})
136136
```
137137

138-
Then add some classes when using it:
138+
E então adicionar mais classes quando for utilizá-lo:
139139

140140
```html
141141
<div id="app">
142142
<my-component class="baz boo"></my-component>
143143
</div>
144144
```
145145

146-
The rendered HTML will be:
146+
O HTML renderizado será:
147147

148148
```html
149-
<p class="foo bar baz boo">Hi</p>
149+
<p class="foo bar baz boo">Oi!</p>
150150
```
151151

152-
The same is true for class bindings:
152+
O mesmo vale para a interligação de classe:
153153

154154
```html
155155
<my-component :class="{ active: isActive }"></my-component>
156156
```
157157

158-
When `isActive` is truthy, the rendered HTML will be:
158+
Quando `isActive` for verdadeiro, o HTML renderizado será:
159159

160160
```html
161-
<p class="foo bar active">Hi</p>
161+
<p class="foo bar active">Oi!</p>
162162
```
163163

164-
If your component has multiple root elements, you would need to define which component will receive this class. You can do this using `$attrs` component property:
164+
Se o seu componente tiver vários elementos raiz, você precisará definir qual componente receberá essa classe utilizando a propriedade do componente `$attrs`:
165165

166166
```html
167167
<div id="app">
@@ -174,19 +174,20 @@ const app = Vue.createApp({})
174174

175175
app.component('my-component', {
176176
template: `
177-
<p :class="$attrs.class">Hi!</p>
178-
<span>This is a child component</span>
177+
<p :class="$attrs.class">Oi!</p>
178+
<span>Este é um component filho</span>
179179
`
180180
})
181181
```
182182

183-
You can learn more about component attribute inheritance in [Non-Prop Attributes](component-attrs.html) section.
183+
Você pode aprender mais sobre herança de atributo de componente na seção [Atributos Não-Prop](component-attrs.html).
184184

185-
## Binding Inline Styles
185+
## Interligando Estilos Inline
186186

187187
### Object Syntax
188+
### Sintaxe de Objeto
188189

189-
The object syntax for `:style` is pretty straightforward - it looks almost like CSS, except it's a JavaScript object. You can use either camelCase or kebab-case (use quotes with kebab-case) for the CSS property names:
190+
A sintaxe de objeto para `:style` é bem direta - parece quase como CSS, mas é um objeto JavaScript. Você pode usar tanto _camelCase_ quanto _kebab-case_ (use aspas com _kebab-case_) para os nomes das propriedades CSS.
190191

191192
```html
192193
<div :style="{ color: activeColor, fontSize: fontSize + 'px' }"></div>
@@ -201,7 +202,7 @@ data() {
201202
}
202203
```
203204

204-
It is often a good idea to bind to a style object directly so that the template is cleaner:
205+
Muitas vezes é uma boa ideia vincular os estilos diretamente em um objeto para que assim o _template_ fique mais limpo:
205206

206207
```html
207208
<div :style="styleObject"></div>
@@ -218,26 +219,26 @@ data() {
218219
}
219220
```
220221

221-
Again, the object syntax is often used in conjunction with computed properties that return objects.
222+
Novamente, a sintaxe de objeto é frequentemente usada em conjunto com dados computados que retornam objetos.
222223

223-
### Array Syntax
224+
### Sintaxe de Array
224225

225-
The array syntax for `:style` allows you to apply multiple style objects to the same element:
226+
A sintaxe Array para `:style` permite que você aplique múltiplos objetos de estilo para o mesmo elemento:
226227

227228
```html
228229
<div :style="[baseStyles, overridingStyles]"></div>
229230
```
230231

231-
### Auto-prefixing
232+
### Auto-Prefixação
232233

233-
When you use a CSS property that requires [vendor prefixes](https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix) in `:style`, for example `transform`, Vue will automatically detect and add appropriate prefixes to the applied styles.
234+
Quando você usa uma propriedade CSS que requer [prefixos de fabricantes](https://developer.mozilla.org/pt-BR/docs/Glossary/Vendor_Prefix) em `:style`, por exemplo `transform`, Vue irá automaticamente detectar e adicionar os prefixos apropriados para os estilos aplicados.
234235

235-
### Multiple Values
236+
### Valores Múltiplos
236237

237-
You can provide an array of multiple (prefixed) values to a style property, for example:
238+
Você pode prover um Array com múltiplos valores (prefixados) para estilizar um atributo, por exemplo:
238239

239240
```html
240241
<div :style="{ display: ['-webkit-box', '-ms-flexbox', 'flex'] }"></div>
241242
```
242243

243-
This will only render the last value in the array which the browser supports. In this example, it will render `display: flex` for browsers that support the unprefixed version of flexbox.
244+
Isto irá renderizar apenas o último valor do Array que o navegador suportar. Neste exemplo, irá renderizar `display: flex` nos navegadores que suportam a versão sem prefixo do módulo Flexbox.

0 commit comments

Comments
 (0)