Skip to content

Commit a5235be

Browse files
authored
Merge pull request #1323 from naymspace/feature/improve-alignment
Improve alignment documentation
2 parents 4fa7d0b + cecd80b commit a5235be

File tree

7 files changed

+24
-26
lines changed

7 files changed

+24
-26
lines changed

demo/lib/demo_web/live/invoice_live.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ defmodule DemoWeb.InvoiceLive do
3333
},
3434
amount: %{
3535
module: Backpex.Fields.Currency,
36-
label: "Amount",
37-
align: :right
36+
label: "Amount"
3837
}
3938
]
4039
end

demo/lib/demo_web/live/post_live.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ defmodule DemoWeb.PostLive do
110110
module: Backpex.Fields.Textarea,
111111
label: "Body",
112112
rows: 10,
113-
except: [:index]
113+
except: [:index, :resource_action],
114+
align_label: :center
114115
},
115116
published: %{
116117
module: Backpex.Fields.Boolean,
@@ -122,8 +123,7 @@ defmodule DemoWeb.PostLive do
122123
module: Backpex.Fields.Boolean,
123124
label: "Show likes",
124125
select: dynamic([post: p], fragment("? > 0", p.likes)),
125-
align: :center,
126-
except: [:index, :show]
126+
except: [:index, :resource_action, :show]
127127
},
128128
likes: %{
129129
module: Backpex.Fields.Number,

demo/lib/demo_web/live/product_live.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ defmodule DemoWeb.ProductLive do
5151
assigns ->
5252
~H"<p>{Backpex.HTML.pretty_value(@value)}</p>"
5353
end,
54-
except: [:index, :resource_action],
55-
align: :center
54+
except: [:index, :resource_action]
5655
},
5756
name: %{
5857
module: Backpex.Fields.Text,

demo/lib/demo_web/live/user_live.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ defmodule DemoWeb.UserLive do
7777
assigns ->
7878
~H'<img class="h-10 w-auto" src={file_url(@value)} />'
7979
end,
80-
align: :center
80+
align_label: :center
8181
},
8282
username: %{
8383
module: Backpex.Fields.Text,

guides/fields/alignment.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Alignment
22

3-
It is possible to align the fields of a resource in the index view and the labels of the fields in the edit view.
3+
It is possible to align the field values of a resource on index views and the labels of the fields on edit views.
44

5-
## Field Alignment (Index View)
5+
## Field Alignment (Index Views)
66

7-
You can align the fields of a resource in the index view by setting the `align` option in the field configuration.
7+
You can align the field values of a resource on index views by setting the `align` option in the field configuration.
88

99
The following alignments are supported: `:left`, `:center` and `:right`
1010

@@ -14,19 +14,19 @@ The following alignments are supported: `:left`, `:center` and `:right`
1414
@impl Backpex.LiveResource
1515
def fields do
1616
[
17-
%{
18-
...,
19-
align: :center
20-
}
17+
%{
18+
...,
19+
align: :center
20+
}
2121
]
2222
end
2323
```
2424

25-
The example above will align the field to the center in the index view.
25+
The example above will center the field value on the index view.
2626

27-
## Label Alignment (Edit View)
27+
## Label Alignment (Form Views)
2828

29-
You can align the labels of the fields in the edit view by setting the `label_align` option in the field configuration.
29+
You can align the labels of the fields on form views by setting the `label_align` option in the field configuration.
3030

3131
The following label orientations are supported: `:top`, `:center` and `:bottom`.
3232

@@ -35,12 +35,12 @@ The following label orientations are supported: `:top`, `:center` and `:bottom`.
3535
@impl Backpex.LiveResource
3636
def fields do
3737
[
38-
%{
39-
...,
40-
align_label: :top
41-
}
38+
%{
39+
...,
40+
align_label: :top
41+
}
4242
]
4343
end
4444
```
4545

46-
The example above will align the label to the top in the edit view.
46+
The example above will align the label to the top on the form view.

lib/backpex/field.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ defmodule Backpex.Field do
3434
type: :atom
3535
],
3636
align: [
37-
doc: "Align the fields of a resource in the index view.",
37+
doc: "Align the field value on index views.",
3838
type: {:in, [:left, :center, :right]}
3939
],
4040
align_label: [
41-
doc: "Align the labels of the fields in the edit view.",
41+
doc: "Align the label of the field on form views.",
4242
type: {:or, [{:in, [:top, :center, :bottom]}, {:fun, 1}]}
4343
],
4444
searchable: [

lib/backpex/fields/upload.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ defmodule Backpex.Fields.Upload do
379379
~H'<p><%= Backpex.HTML.pretty_value(@value) %></p>'
380380
end,
381381
except: [:index, :resource_action],
382-
align: :center
382+
align_label: :center
383383
},
384384
...
385385
]

0 commit comments

Comments
 (0)