Skip to content

Commit

Permalink
Add links to hints
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Oct 26, 2023
1 parent 5f24869 commit c17a300
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 7 additions & 3 deletions app/lib/form_builders/tailwind.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ def error(method, options = {})
template.content_tag(:p, m, options.merge(class: "text-2xl text-error-red #{options[:class]}"))
end

sig { params(text: String, options: T::Hash[Symbol, String]).returns(String) }
def hint(text, options = {})
template.content_tag(:p, text, options.merge(class: "text-base italic text-warm-grey #{options[:class]}"))
sig { params(text_or_options: T.untyped, options: T::Hash[Symbol, String], block: T.untyped).returns(String) }
def hint(text_or_options = nil, options = {}, &block)
if block_given?
template.content_tag(:p, (text_or_options || {}).merge(class: "text-base italic text-warm-grey #{options[:class]}"), &block)
else
template.content_tag(:p, text_or_options, options.merge(class: "text-base italic text-warm-grey #{options[:class]}"))
end
end

sig { params(method: Symbol, options: T::Hash[Symbol, String]).returns(String) }
Expand Down
9 changes: 6 additions & 3 deletions app/views/_tailwind/contact_messages/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<%= f.label :name, "Your name", class: "block mb-3" %>
<%= f.text_field :name, class: "block w-full" %>
<%= f.error :name, class: "mt-2" %>
<%= f.hint "Or #{pa_link_to 'sign in', new_user_session_path}".html_safe %>
<%= f.hint do %>
Or <%= pa_link_to "sign in", new_user_session_path %>
<% end %>
</div>
<div class="mt-8">
<%= f.label :email, "Your email", class: "block mb-3" %>
Expand Down Expand Up @@ -40,8 +42,9 @@
<%= recaptcha_tags %>
<%# TODO: Make sure recaptcha errors are shown here %>
<%= f.error :base, class: "mt-2" %>
<%# TODO: Add link to hint %>
<%= f.hint "Or sign in to remove this annoying reCaptcha", class: "mt-2" %>
<%= f.hint class: "mt-2" do %>
Or <%= pa_link_to "sign in", new_user_session_path %> to remove this annoying reCaptcha
<% end %>
</div>
<div class="mt-8">
<%= f.button "Send message to the Planning Alerts team" %>
Expand Down

0 comments on commit c17a300

Please sign in to comment.