Skip to content

Commit

Permalink
Document TextField's auto_check_src argument (#1788)
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron authored Feb 1, 2023
1 parent 3a23cfa commit 7ad7006
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-students-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': patch
---

Document TextField's auto_check_src argument
1 change: 1 addition & 0 deletions app/components/primer/alpha/text_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class TextField < Primer::Component
# @param leading_visual [Hash] Renders a leading visual icon before the text field's cursor. The hash will be passed to Primer's [Octicon component](https://primer.style/view-components/components/octicon).
# @param validation_message [String] A validation message to display beneath the input. Implicitly sets `invalid` to `true`.
# @param label_arguments [Hash] System arugments passed to the Rails builder's `#label` method. These arguments will appear as HTML attributes on the `<label>` tag.
# @param auto_check_src [String] When provided, makes a request to the given URL whenever the contents of the text field changes. If the server responds with a non-2xx status code, the response body is used as the validation message.
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
# @param block [Proc] Unused.
end
Expand Down
14 changes: 14 additions & 0 deletions previews/primer/alpha/text_field_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ def with_validation_message
end
#
# @!endgroup

# @!group Auto check
#
# @label Auto check request ok
def with_auto_check_ok
render(Primer::Alpha::TextField.new(auto_check_src: URLHelpers.example_check_ok_path, name: "my-text-field", label: "My text field"))
end

# @label Auto check request error
def with_auto_check_error
render(Primer::Alpha::TextField.new(auto_check_src: URLHelpers.example_check_error_path, name: "my-text-field", label: "My text field"))
end
#
# @!endgroup
end
end
end

0 comments on commit 7ad7006

Please sign in to comment.