Skip to content

Commit f122aa5

Browse files
authored
Merge branch 'main' into copilot/fix-performance-benchmark-tests
2 parents ba33153 + 69aefda commit f122aa5

34 files changed

Lines changed: 883 additions & 36 deletions

.changeset/plenty-regions-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/view-components': minor
3+
---
4+
5+
Adds character_limit option to TextArea and TextField components

.github/workflows/demo-production-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
with:
7373
ruby-version: '3.3'
7474
bundler-cache: true
75-
- uses: actions/cache@v4.3.0
75+
- uses: actions/cache@v5.0.1
7676
with:
7777
path: demo/gemfiles/vendor/bundle
7878
key: gems-build-kuby-main-ruby-3.3.x-${{ hashFiles('demo/gemfiles/kuby.gemfile.lock') }}

.github/workflows/static-files.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Generate static files
22

33
on:
44
push:
5+
branches-ignore:
6+
- 'dependabot/**'
57

68
jobs:
79
static:

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ GEM
5757
parser (>= 2.4)
5858
smart_properties
5959
bigdecimal (3.2.3)
60-
bootsnap (1.18.6)
60+
bootsnap (1.19.0)
6161
msgpack (~> 1.2)
6262
builder (3.3.0)
6363
capybara (3.40.0)

app/components/primer/alpha/text_area.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class TextArea < Primer::Component
1818
# @!method initialize
1919
#
2020
# @macro form_full_width_arguments
21+
# @macro form_input_character_limit_arguments
2122
# @macro form_input_arguments
2223
end
2324
end

app/components/primer/alpha/text_field.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class TextField < Primer::Component
1919
#
2020
# @macro form_size_arguments
2121
# @macro form_full_width_arguments
22+
# @macro form_input_character_limit_arguments
2223
# @macro form_input_arguments
2324
#
2425
# @param placeholder [String] Placeholder text.

app/components/primer/primer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import './beta/relative_time'
2222
import './alpha/tab_container'
2323
import '../../lib/primer/forms/primer_multi_input'
2424
import '../../lib/primer/forms/primer_text_field'
25+
import '../../lib/primer/forms/primer_text_area'
2526
import '../../lib/primer/forms/toggle_switch_input'
2627
import './alpha/action_menu/action_menu_element'
2728
import './alpha/select_panel_element'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
# :nodoc:
4+
class TextAreaWithCharacterLimitForm < ApplicationForm
5+
form do |my_form|
6+
my_form.text_area(
7+
name: :bio,
8+
label: "Bio",
9+
caption: "Tell us about yourself",
10+
character_limit: 100
11+
)
12+
end
13+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
# :nodoc:
4+
class TextFieldWithCharacterLimitForm < ApplicationForm
5+
form do |my_form|
6+
my_form.text_field(
7+
name: :username,
8+
label: "Username",
9+
caption: "Choose a unique username",
10+
character_limit: 20
11+
)
12+
end
13+
end
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
<% if @input.caption? && !@input.caption.blank? %>
2-
<span class="FormControl-caption" id="<%= @input.caption_id %>"><%= @input.caption %></span>
3-
<% elsif caption_template? %>
4-
<% caption_template = render_caption_template %>
5-
<% unless caption_template.blank? %>
6-
<span class="FormControl-caption" id="<%= @input.caption_id %>">
7-
<%= caption_template %>
8-
</span>
9-
<% end %>
1+
<% if @input.character_limit? %>
2+
<span class="sr-only" data-target="<%= @input.character_limit_target_prefix %>.characterLimitSrElement" aria-live="polite" role="status"></span>
3+
<span class="sr-only" id="<%= @input.character_limit_id %>">You can enter up to <%= @input.character_limit %> <%= @input.character_limit == 1 ? 'character' : 'characters' %></span>
4+
<span class="FormControl-caption" data-target="<%= @input.character_limit_target_prefix %>.characterLimitElement" data-max-length="<%= @input.character_limit %>" aria-hidden="true">
5+
<span class="FormControl-caption-icon" hidden><%= render(Primer::Beta::Octicon.new(icon: :"alert-fill", size: :xsmall, aria: { hidden: true })) %></span>
6+
<span class="FormControl-caption-text"><%= @input.character_limit %> <%= @input.character_limit == 1 ? 'character' : 'characters' %> remaining</span>
7+
</span>
8+
<% end %>
9+
<% if @input.caption? || caption_template? %>
10+
<span class="FormControl-caption" id="<%= @input.caption_id %>">
11+
<% if @input.caption? && !@input.caption.blank? %>
12+
<%= @input.caption %>
13+
<% elsif caption_template? %>
14+
<%= render_caption_template %>
15+
<% end %>
16+
</span>
1017
<% end %>

0 commit comments

Comments
 (0)