Skip to content

Commit

Permalink
feat: adiciona block para label e submit component (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnAnon9771 authored Nov 6, 2024
1 parent afc989c commit 742fbff
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/spec/dummy/storage/
/spec/dummy/tmp/
/spec/dummy/node_modules
/spec/dummy/app/assets/builds
/spec/app/assets/builds
/node_modules
spec/dummy/ink_components.tailwind.config.js
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ruby 3.3.4
nodejs 20.11.0
2 changes: 1 addition & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
web: rails s -p 3000 -b 0.0.0.0
web: bin/rails s -p 3000 -b 0.0.0.0
dummy_css: yarn --cwd ./spec/dummy run build:css --watch
dummy_js: yarn --cwd ./spec/dummy run build --watch
2 changes: 1 addition & 1 deletion app/components/ink_components/forms/label/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Forms
module Label
class Component < ApplicationComponent
style do
base { %w[ block mb-2 text-sm font-medium ] }
base { %w[ block text-sm font-medium ] }
variants {
state {
default { "text-gray-900 dark:text-white" }
Expand Down
7 changes: 5 additions & 2 deletions app/helpers/ink_components/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class FormBuilder < ActionView::Helpers::FormBuilder

delegate :render, to: :template

def label(attribute, content = nil, **opts)
def label(attribute, content = nil, **opts, &)
content ||= label_text(attribute)
content = template.capture(&) if block_given?

label_component(for: format_id(attribute, objectify_options(opts)), **sanitize_options(opts)) { content }
end
Expand Down Expand Up @@ -80,8 +81,10 @@ def error_message(attribute, **)
helper_text_component(state:, **) { error_messages(attribute) }
end

def submit(content = nil, **options)
def submit(content = nil, **options, &)
content ||= submit_default_value
content = template.capture(&) if block_given?

options[:data] = { disable_with: content }.merge(options[:data] || {})
button_component(builder: :button_tag, value: content, **options) { content }
end
Expand Down
14 changes: 14 additions & 0 deletions app/views/users/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,24 @@

<br><br>

<%= f.label :full_name do %>
Nome completo
<%= f.text_field :full_name %>
<% end %>

<br><br>

<div class="flex mb-4">
<%= f.check_box :paid %>
<%= f.label :paid, class: "mb-0" %>
</div>

<%= f.submit %>

<br><br>

<%= f.submit class: "flex items-center gap-2" do %>
<%= icon_component(name: :github, class: "size-3") %>
Salvar
<% end %>
<% end %>

0 comments on commit 742fbff

Please sign in to comment.