Skip to content

Commit d0326d3

Browse files
committed
Add Surface formatter plugin and format
1 parent 7aade00 commit d0326d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+139
-144
lines changed

.formatter.exs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Used by "mix format"
22
[
33
import_deps: [:phoenix, :surface],
4-
plugins: [Phoenix.LiveView.HTMLFormatter],
4+
plugins: [
5+
Phoenix.LiveView.HTMLFormatter,
6+
Surface.Formatter.Plugin
7+
],
58
line_length: 115,
69
inputs: [
710
"{mix,.formatter}.exs",

lib/surface/components/form.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ defmodule Surface.Components.Form do
101101
~F"""
102102
<!-- XXX -->
103103
<.form :let={form} for={@for} action={@action} {...@opts}>
104-
<#slot {@default, form: form} context_put={__MODULE__, form: form}/>
104+
<#slot {@default, form: form} context_put={__MODULE__, form: form} />
105105
</.form>
106106
"""
107107
end

lib/surface/components/form/field.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Surface.Components.Form.Field do
2323
def render(assigns) do
2424
~F"""
2525
<div class={class_value(@class)}>
26-
<#slot context_put={__MODULE__, field: @name}/>
26+
<#slot context_put={__MODULE__, field: @name} />
2727
</div>
2828
"""
2929
end

lib/surface/components/form/field_context.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ defmodule Surface.Components.Form.FieldContext do
2020
slot default, required: true
2121

2222
def render(assigns) do
23-
~F[<#slot context_put={Field, field: @name}/>]
23+
~F[<#slot context_put={Field, field: @name} />]
2424
end
2525
end

lib/surface/components/form/input.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ defmodule Surface.Components.Form.Input do
8484
field = Context.get(assigns, Surface.Components.Form.Field, :field)
8585

8686
~F"""
87-
<#slot {@default, form: @assigns[:form] || form, field: @assigns[:field] || field}/>
87+
<#slot {@default, form: @assigns[:form] || form, field: @assigns[:field] || field} />
8888
"""
8989
end
9090
end

lib/surface/components/form/inputs.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ defmodule Surface.Components.Form.Inputs do
3838
def render(assigns) do
3939
~F"""
4040
<.inputs_for :let={nested_form} field={@form[@for || @field]} {...@opts}>
41-
<#slot {@default, form: nested_form, index: nested_form.index } context_put={Form, form: nested_form} />
41+
<#slot {@default, form: nested_form, index: nested_form.index} context_put={Form, form: nested_form} />
4242
</.inputs_for>
4343
"""
4444
end

lib/surface/components/form/label.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ defmodule Surface.Components.Form.Label do
5454
assigns = assign(assigns, opts: opts)
5555

5656
~F"""
57-
<label :attrs={input_id(@form, @field) ++ @opts}>
57+
<label {...input_id(@form, @field) ++ @opts}>
5858
<#slot>{@text || Phoenix.Naming.humanize(@field)}</#slot>
5959
</label>
6060
"""

lib/surface/components/form/telephone_input.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ defmodule Surface.Components.Form.TelephoneInput do
3737

3838
assigns = assign(assigns, opts: opts)
3939

40-
~F[{telephone_input(@form, @field, @opts)}]
40+
~F[{telephone_input(@form, @field, @opts)}]
4141
end
4242
end

lib/surface/components/link/button.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ defmodule Surface.Components.Link.Button do
7272
assigns = assign(assigns, to: to, opts: events ++ opts)
7373

7474
~F"""
75-
<button id={@id} class={@class} :attrs={@opts}><#slot>{@label}</#slot></button>
75+
<button id={@id} class={@class} {...@opts}><#slot>{@label}</#slot></button>
7676
"""
7777
end
7878

priv/catalogue/surface/components/form/example01.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ defmodule Surface.Components.Form.Example01 do
1313
~F"""
1414
<Form for={%{}} as={:user} change="change" submit="submit" opts={autocomplete: "off"}>
1515
<Field class="field" name="name">
16-
<Label class="label"/>
16+
<Label class="label" />
1717
<div class="control">
18-
<TextInput class="input" value={@user["name"]}/>
18+
<TextInput class="input" value={@user["name"]} />
1919
</div>
2020
</Field>
2121
<Field class="field" name="email">
2222
<Label class="label">E-mail</Label>
2323
<div class="control">
24-
<TextInput class="input" value={@user["email"]}/>
24+
<TextInput class="input" value={@user["email"]} />
2525
</div>
2626
</Field>
2727
</Form>

0 commit comments

Comments
 (0)