Skip to content

Commit 1ddf3f1

Browse files
committed
Give extra info in table documentation
1 parent e503b59 commit 1ddf3f1

File tree

1 file changed

+72
-3
lines changed

1 file changed

+72
-3
lines changed

docs/components/table.md

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
Show [specs](../../spec/usage/components/table_spec.rb)
44

5-
Use tables to implement `<table>`, `<tr>`, `<th>` and `<td>`-tags.
5+
Use tables to implement `<table>`, `<tr>`, `<th>`, `<td>`, `<thead>`, `<tbody>` and `<tfoot>` tags.
66

77
## Parameters
88

9-
`<table>`, `<tr>`, can take 2 optional configuration params.
10-
`<th>` and `<td>`-tags can also take a third param, text input.
9+
`<table>`, `<tr>`, `<thead>`, `<tbody>` and `<tfoot>` can take 2 optional configuration params.
10+
`<th>` and `<td>` tags can also take a third param, text input.
1111

1212
#### # id (optional)
1313
Expects a string with all ids the element should have.
@@ -139,3 +139,72 @@ returns
139139
</tr>
140140
</table>
141141
```
142+
143+
## Example 3
144+
145+
`thead`, `tbody` and `tfoot` are optional containers for any number of `tr`s. If none are specified, `tbody` will be used to contain all `tr` components. `thead` is typically used for the head of the table, and `tfoot` for any table footer, where applicable, such as a sum or count.
146+
147+
```ruby
148+
table do
149+
thead do
150+
tr do
151+
th text: "Product"
152+
th text: "Price"
153+
end
154+
end
155+
# tbody is unnecessary, since it has no class or id and will be added automatically
156+
# tbody do
157+
tr do
158+
td text: "Apples"
159+
td text: "3.50"
160+
end
161+
tr do
162+
td text: "Oranges"
163+
td text: "2.75"
164+
end
165+
tr do
166+
td text: "Bananas"
167+
td text: "4.99"
168+
end
169+
# end
170+
tfoot do
171+
tr do
172+
td text: "Total:"
173+
td text: "11.24"
174+
end
175+
end
176+
end
177+
```
178+
179+
returns
180+
181+
```html
182+
<table>
183+
<thead>
184+
<tr>
185+
<th>Product</th>
186+
<th>Price</th>
187+
</tr>
188+
</thead>
189+
<tbody>
190+
<tr>
191+
<td>Apples</td>
192+
<td>3.50</td>
193+
</tr>
194+
<tr>
195+
<td>Oranges</td>
196+
<td>2.75</td>
197+
</tr>
198+
<tr>
199+
<td>Bananas</td>
200+
<td>4.99</td>
201+
</tr>
202+
</tbody>
203+
<tfoot>
204+
<tr>
205+
<td>Total:</td>
206+
<td>11.24</td>
207+
</tr>
208+
</tfoot>
209+
</table>
210+
```

0 commit comments

Comments
 (0)