primer_view_components 0.0.94 → 0.0.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/dialog.rb +3 -3
- data/app/components/primer/alpha/toggle_switch.js +3 -0
- data/app/components/primer/alpha/toggle_switch.ts +3 -0
- data/app/components/primer/alpha/tool_tip.js +17 -2
- data/app/components/primer/alpha/tool_tip.ts +14 -2
- data/app/components/primer/beta/button.pcss +27 -15
- data/app/components/primer/beta/button.rb +11 -16
- data/app/components/primer/beta/icon_button.html.erb +1 -1
- data/app/components/primer/beta/icon_button.rb +5 -3
- data/app/components/primer/button_component.rb +1 -1
- data/app/components/primer/experimental/action_bar.d.ts +14 -0
- data/app/components/primer/experimental/action_bar.js +141 -0
- data/app/components/primer/icon_button.rb +1 -1
- data/app/components/primer/octicon_component.rb +0 -4
- data/app/components/primer/octicon_symbols_component.rb +0 -4
- data/app/lib/primer/fetch_or_fallback_helper.rb +1 -1
- data/lib/primer/deprecations.rb +2 -2
- data/lib/primer/forms/builder.rb +2 -2
- data/lib/primer/forms/check_box.html.erb +5 -1
- data/lib/primer/forms/check_box.rb +11 -0
- data/lib/primer/forms/dsl/check_box_group_input.rb +17 -4
- data/lib/primer/forms/dsl/check_box_input.rb +21 -2
- data/lib/primer/view_components/engine.rb +2 -1
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/coverage.rake +1 -1
- data/lib/tasks/docs.rake +19 -15
- data/lib/tasks/static.rake +1 -1
- data/lib/tasks/test.rake +54 -0
- data/lib/tasks/utilities.rake +1 -0
- data/static/arguments.json +2042 -0
- data/static/audited_at.json +0 -2
- data/static/constants.json +1 -8
- data/static/statuses.json +2 -4
- metadata +6 -6
- data/app/components/primer/base_button.rb +0 -7
- data/app/components/primer/button_group.rb +0 -7
- data/lib/tasks/deprecated.rake +0 -27
- data/static/arguments.yml +0 -1358
data/lib/primer/forms/builder.rb
CHANGED
@@ -14,8 +14,8 @@ module Primer
|
|
14
14
|
super(*args, classify(options), &block)
|
15
15
|
end
|
16
16
|
|
17
|
-
def check_box(
|
18
|
-
super(
|
17
|
+
def check_box(method, options = {}, checked_value = 1, unchecked_value = 0, &block)
|
18
|
+
super(method, classify(options), checked_value, unchecked_value, &block)
|
19
19
|
end
|
20
20
|
|
21
21
|
def radio_button(*args, **options, &block)
|
@@ -1,5 +1,9 @@
|
|
1
1
|
<div class="FormControl-checkbox-wrap">
|
2
|
-
|
2
|
+
<% if @input.scheme == :array %>
|
3
|
+
<%= builder.check_box(@input.name, @input.input_arguments, checked_value, nil) %>
|
4
|
+
<% else %>
|
5
|
+
<%= builder.check_box(@input.name, @input.input_arguments) %>
|
6
|
+
<% end %>
|
3
7
|
<span class="FormControl-checkbox-labelWrap">
|
4
8
|
<%= builder.label(@input.name, **@input.label_arguments) do %>
|
5
9
|
<%= @input.label %>
|
@@ -10,6 +10,17 @@ module Primer
|
|
10
10
|
@input = input
|
11
11
|
@input.add_label_classes("FormControl-label")
|
12
12
|
@input.add_input_classes("FormControl-checkbox")
|
13
|
+
|
14
|
+
return unless @input.scheme == :array
|
15
|
+
|
16
|
+
@input.input_arguments[:multiple] = true
|
17
|
+
@input.label_arguments[:value] = checked_value
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def checked_value
|
23
|
+
@input.value || "1"
|
13
24
|
end
|
14
25
|
end
|
15
26
|
end
|
@@ -7,7 +7,8 @@ module Primer
|
|
7
7
|
class CheckBoxGroupInput < Input
|
8
8
|
attr_reader :label, :check_boxes
|
9
9
|
|
10
|
-
def initialize(label: nil, **system_arguments)
|
10
|
+
def initialize(name: nil, label: nil, **system_arguments)
|
11
|
+
@name = name
|
11
12
|
@label = label
|
12
13
|
@check_boxes = []
|
13
14
|
|
@@ -31,9 +32,21 @@ module Primer
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def check_box(**system_arguments)
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
args = {
|
36
|
+
name: @name,
|
37
|
+
**system_arguments,
|
38
|
+
builder: @builder,
|
39
|
+
form: @form,
|
40
|
+
scheme: scheme
|
41
|
+
}
|
42
|
+
|
43
|
+
@check_boxes << CheckBoxInput.new(**args)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def scheme
|
49
|
+
@name ? :array : :boolean
|
37
50
|
end
|
38
51
|
end
|
39
52
|
end
|
@@ -5,11 +5,20 @@ module Primer
|
|
5
5
|
module Dsl
|
6
6
|
# :nodoc:
|
7
7
|
class CheckBoxInput < Input
|
8
|
-
|
8
|
+
DEFAULT_SCHEME = :boolean
|
9
|
+
SCHEMES = [DEFAULT_SCHEME, :array].freeze
|
10
|
+
|
11
|
+
attr_reader :name, :label, :value, :scheme
|
12
|
+
|
13
|
+
def initialize(name:, label:, value: nil, scheme: DEFAULT_SCHEME, **system_arguments)
|
14
|
+
raise ArgumentError, "Check box scheme must be one of #{SCHEMES.join(', ')}" unless SCHEMES.include?(scheme)
|
15
|
+
|
16
|
+
raise ArgumentError, "Check box needs an explicit value if scheme is array" if scheme == :array && value.nil?
|
9
17
|
|
10
|
-
def initialize(name:, label:, **system_arguments)
|
11
18
|
@name = name
|
12
19
|
@label = label
|
20
|
+
@value = value
|
21
|
+
@scheme = scheme
|
13
22
|
|
14
23
|
super(**system_arguments)
|
15
24
|
end
|
@@ -21,6 +30,16 @@ module Primer
|
|
21
30
|
def type
|
22
31
|
:check_box
|
23
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def caption_template_name
|
37
|
+
@caption_template_name ||= if @scheme == :array
|
38
|
+
:"#{name}_#{value}"
|
39
|
+
else
|
40
|
+
name.to_sym
|
41
|
+
end
|
42
|
+
end
|
24
43
|
end
|
25
44
|
end
|
26
45
|
end
|
@@ -30,12 +30,13 @@ module Primer
|
|
30
30
|
app.config.assets.precompile += %w[primer_view_components] if app.config.respond_to?(:assets)
|
31
31
|
end
|
32
32
|
|
33
|
-
initializer "primer.
|
33
|
+
initializer "primer.eager_load_actions" do
|
34
34
|
ActiveSupport.on_load(:after_initialize) do
|
35
35
|
if Rails.application.config.eager_load
|
36
36
|
Primer::Forms::Base.compile!
|
37
37
|
Primer::Forms::Base.descendants.each(&:compile!)
|
38
38
|
Primer::Forms::BaseComponent.descendants.each(&:compile!)
|
39
|
+
Primer::Octicon::Cache.preload!
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
data/lib/tasks/coverage.rake
CHANGED
data/lib/tasks/docs.rake
CHANGED
@@ -131,7 +131,7 @@ namespace :docs do
|
|
131
131
|
f.puts("componentId: #{data[:component_id]}")
|
132
132
|
f.puts("status: #{data[:status]}")
|
133
133
|
f.puts("source: #{data[:source]}")
|
134
|
-
f.puts("
|
134
|
+
f.puts("lookbook: #{data[:lookbook]}") if preview_exists?(component)
|
135
135
|
f.puts("---")
|
136
136
|
f.puts
|
137
137
|
f.puts("import Example from '#{data[:example_path]}'")
|
@@ -276,8 +276,8 @@ namespace :docs do
|
|
276
276
|
raise
|
277
277
|
end
|
278
278
|
|
279
|
-
File.open("static/arguments.
|
280
|
-
f.puts
|
279
|
+
File.open("static/arguments.json", "w") do |f|
|
280
|
+
f.puts JSON.pretty_generate(args_for_components)
|
281
281
|
end
|
282
282
|
|
283
283
|
# Build system arguments docs from BaseComponent
|
@@ -371,27 +371,25 @@ namespace :docs do
|
|
371
371
|
|
372
372
|
yard_example_tags = initialize_method.tags(:example)
|
373
373
|
|
374
|
-
path = Pathname.new("test/previews/
|
374
|
+
path = Pathname.new("test/previews/docs/#{short_name.underscore}_preview.rb")
|
375
375
|
path.dirname.mkdir unless path.dirname.exist?
|
376
376
|
|
377
377
|
File.open(path, "w") do |f|
|
378
|
-
f.puts("module
|
379
|
-
f.puts("
|
380
|
-
f.puts(" class #{short_name}Preview < ViewComponent::Preview")
|
378
|
+
f.puts("module Docs")
|
379
|
+
f.puts(" class #{short_name}Preview < ViewComponent::Preview")
|
381
380
|
|
382
381
|
yard_example_tags.each_with_index do |tag, index|
|
383
382
|
name, _, code = parse_example_tag(tag)
|
384
383
|
method_name = name.split("|").first.downcase.parameterize.underscore
|
385
|
-
f.puts("
|
384
|
+
f.puts(" def #{method_name}; end")
|
386
385
|
f.puts unless index == yard_example_tags.size - 1
|
387
|
-
path = Pathname.new("test/previews/
|
386
|
+
path = Pathname.new("test/previews/docs/#{short_name.underscore}_preview/#{method_name}.html.erb")
|
388
387
|
path.dirname.mkdir unless path.dirname.exist?
|
389
388
|
File.open(path, "w") do |view_file|
|
390
389
|
view_file.puts(code.to_s)
|
391
390
|
end
|
392
391
|
end
|
393
392
|
|
394
|
-
f.puts(" end")
|
395
393
|
f.puts(" end")
|
396
394
|
f.puts("end")
|
397
395
|
end
|
@@ -399,7 +397,7 @@ namespace :docs do
|
|
399
397
|
end
|
400
398
|
|
401
399
|
def generate_yard_registry
|
402
|
-
ENV["
|
400
|
+
ENV["RAILS_ENV"] = "test"
|
403
401
|
require File.expand_path("./../../demo/config/environment.rb", __dir__)
|
404
402
|
require "primer/view_components"
|
405
403
|
require "yard/docs_helper"
|
@@ -465,7 +463,7 @@ namespace :docs do
|
|
465
463
|
component_id: short_name.underscore,
|
466
464
|
status: status.capitalize,
|
467
465
|
source: source_url(component),
|
468
|
-
|
466
|
+
lookbook: lookbook_url(component),
|
469
467
|
path: "docs/content/components/#{status_path}#{short_name.downcase}.md",
|
470
468
|
example_path: example_path(component),
|
471
469
|
require_js_path: require_js_path(component)
|
@@ -478,10 +476,16 @@ namespace :docs do
|
|
478
476
|
"https://github.com/primer/view_components/tree/main/app/components/#{path}.rb"
|
479
477
|
end
|
480
478
|
|
481
|
-
def
|
482
|
-
path = component.name.
|
479
|
+
def lookbook_url(component)
|
480
|
+
path = component.name.underscore.gsub("_component", "")
|
483
481
|
|
484
|
-
"https://primer.style/view-components/
|
482
|
+
"https://primer.style/view-components/lookbook/inspect/#{path}/default/"
|
483
|
+
end
|
484
|
+
|
485
|
+
def preview_exists?(component)
|
486
|
+
path = component.name.underscore
|
487
|
+
|
488
|
+
File.exist?("test/previews/#{path}_preview.rb")
|
485
489
|
end
|
486
490
|
|
487
491
|
def example_path(component)
|
data/lib/tasks/static.rake
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
namespace :static do
|
4
4
|
task :dump do
|
5
|
-
ENV["
|
5
|
+
ENV["RAILS_ENV"] = "test"
|
6
6
|
require File.expand_path("./../../demo/config/environment.rb", __dir__)
|
7
7
|
require "primer/view_components"
|
8
8
|
# Loads all components for `.descendants` to work properly
|
data/lib/tasks/test.rake
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rake/testtask"
|
4
|
+
|
5
|
+
namespace :test do
|
6
|
+
desc "Run all tests"
|
7
|
+
task all: [:fast, :system]
|
8
|
+
|
9
|
+
Rake::TestTask.new(:single) do |t|
|
10
|
+
ENV["TZ"] = "Asia/Taipei"
|
11
|
+
|
12
|
+
t.libs << "test"
|
13
|
+
t.libs << "lib"
|
14
|
+
t.test_files = FileList[ENV["TESTS"]]
|
15
|
+
end
|
16
|
+
|
17
|
+
Rake::TestTask.new(:fast) do |t|
|
18
|
+
ENV["TZ"] = "Asia/Taipei"
|
19
|
+
|
20
|
+
t.libs << "test"
|
21
|
+
t.libs << "lib"
|
22
|
+
t.test_files = FileList[
|
23
|
+
"test/components/**/*_test.rb",
|
24
|
+
"test/lib/**/*_test.rb",
|
25
|
+
"test/primer/**/*_test.rb",
|
26
|
+
"test/linters/**/*_test.rb",
|
27
|
+
"test/rubocop/**/*_test.rb"
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
Rake::TestTask.new(:system) do |t|
|
32
|
+
ENV["TZ"] = "Asia/Taipei"
|
33
|
+
|
34
|
+
t.libs << "test"
|
35
|
+
t.libs << "lib"
|
36
|
+
t.test_files = FileList["test/system/**/*_test.rb", "test/previews/**/*_test.rb"]
|
37
|
+
end
|
38
|
+
|
39
|
+
Rake::TestTask.new(:bench) do |t|
|
40
|
+
t.libs << "test"
|
41
|
+
t.test_files = FileList["test/benchmarks/**/bench_*.rb"]
|
42
|
+
t.verbose = true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
task :test do
|
47
|
+
if ENV["TESTS"]
|
48
|
+
Rake::Task["test:single"].invoke
|
49
|
+
else
|
50
|
+
Rake::Task["test:all"].invoke
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
task bench: "test:bench"
|