primer_view_components 0.0.119 → 0.0.120
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/components/primer/alpha/modal_dialog.js +2 -0
- data/app/components/primer/alpha/modal_dialog.ts +2 -0
- data/lib/primer/deprecations.yml +0 -13
- data/lib/primer/view_components/linters/button_component_migration_counter.rb +2 -2
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/primer/view_components.rb +5 -0
- data/lib/primer/yard/backend.rb +38 -0
- data/lib/primer/yard/component_manifest.rb +123 -0
- data/lib/primer/yard/docs_helper.rb +81 -0
- data/lib/primer/yard/legacy_gatsby_backend.rb +271 -0
- data/lib/primer/yard/registry.rb +146 -0
- data/lib/primer/yard/renders_many_handler.rb +23 -0
- data/lib/primer/yard/renders_one_handler.rb +23 -0
- data/lib/rubocop/config/default.yml +3 -0
- data/lib/rubocop/cop/primer/test_selector.rb +48 -0
- data/lib/tasks/docs.rake +37 -405
- data/previews/primer/alpha/dialog_preview/body_has_scrollbar_overflow.html.erb +9 -0
- data/previews/primer/alpha/dialog_preview.rb +15 -0
- data/static/arguments.json +0 -32
- data/static/audited_at.json +0 -3
- data/static/constants.json +0 -20
- data/static/statuses.json +0 -3
- metadata +17 -15
- data/app/components/primer/box_component.rb +0 -7
- data/app/components/primer/clipboard_copy.rb +0 -7
- data/app/components/primer/dropdown_menu_component.html.erb +0 -8
- data/app/components/primer/dropdown_menu_component.rb +0 -58
- data/lib/yard/docs_helper.rb +0 -79
- data/lib/yard/renders_many_handler.rb +0 -19
- data/lib/yard/renders_one_handler.rb +0 -19
data/lib/tasks/docs.rake
CHANGED
@@ -21,282 +21,21 @@ namespace :docs do
|
|
21
21
|
sleep
|
22
22
|
end
|
23
23
|
|
24
|
-
task :
|
25
|
-
registry = generate_yard_registry
|
24
|
+
task build: [:build_gatsby, :build_gatsby_adrs]
|
26
25
|
|
27
|
-
|
26
|
+
task build_gatsby: :build_yard_registry do
|
27
|
+
registry = Primer::YARD::Registry.make
|
28
|
+
|
29
|
+
require "primer/yard/legacy_gatsby_backend"
|
28
30
|
|
29
|
-
|
30
|
-
view_context = ApplicationController.new.tap { |c| c.request = ActionDispatch::TestRequest.create }.view_context
|
31
|
-
components = [
|
32
|
-
Primer::Beta::RelativeTime,
|
33
|
-
Primer::Beta::IconButton,
|
34
|
-
Primer::Beta::Button,
|
35
|
-
Primer::Alpha::SegmentedControl,
|
36
|
-
Primer::Alpha::Layout,
|
37
|
-
Primer::Alpha::HellipButton,
|
38
|
-
Primer::Alpha::Image,
|
39
|
-
Primer::LocalTime,
|
40
|
-
Primer::Alpha::OcticonSymbols,
|
41
|
-
Primer::Alpha::ImageCrop,
|
42
|
-
Primer::IconButton,
|
43
|
-
Primer::Beta::AutoComplete,
|
44
|
-
Primer::Beta::AutoComplete::Item,
|
45
|
-
Primer::Beta::Avatar,
|
46
|
-
Primer::Beta::AvatarStack,
|
47
|
-
Primer::Beta::BaseButton,
|
48
|
-
Primer::Alpha::Banner,
|
49
|
-
Primer::Beta::Blankslate,
|
50
|
-
Primer::Beta::BorderBox,
|
51
|
-
Primer::Beta::BorderBox::Header,
|
52
|
-
Primer::Box,
|
53
|
-
Primer::Beta::Breadcrumbs,
|
54
|
-
Primer::ButtonComponent,
|
55
|
-
Primer::Beta::ButtonGroup,
|
56
|
-
Primer::Alpha::ButtonMarketing,
|
57
|
-
Primer::Beta::ClipboardCopy,
|
58
|
-
Primer::Beta::CloseButton,
|
59
|
-
Primer::Beta::Counter,
|
60
|
-
Primer::Beta::Details,
|
61
|
-
Primer::Alpha::Dialog,
|
62
|
-
Primer::Alpha::Dropdown,
|
63
|
-
Primer::DropdownMenuComponent,
|
64
|
-
Primer::Beta::Flash,
|
65
|
-
Primer::Beta::Heading,
|
66
|
-
Primer::Alpha::HiddenTextExpander,
|
67
|
-
Primer::Beta::Label,
|
68
|
-
Primer::LayoutComponent,
|
69
|
-
Primer::Beta::Link,
|
70
|
-
Primer::Beta::Markdown,
|
71
|
-
Primer::Alpha::Menu,
|
72
|
-
Primer::Navigation::TabComponent,
|
73
|
-
Primer::Beta::Octicon,
|
74
|
-
Primer::Beta::Popover,
|
75
|
-
Primer::Beta::ProgressBar,
|
76
|
-
Primer::Beta::State,
|
77
|
-
Primer::Beta::Spinner,
|
78
|
-
Primer::Beta::Subhead,
|
79
|
-
Primer::Alpha::TabContainer,
|
80
|
-
Primer::Beta::Text,
|
81
|
-
Primer::Alpha::TextField,
|
82
|
-
Primer::TimeAgoComponent,
|
83
|
-
Primer::Beta::TimelineItem,
|
84
|
-
Primer::Tooltip,
|
85
|
-
Primer::Truncate,
|
86
|
-
Primer::Beta::Truncate,
|
87
|
-
Primer::Alpha::UnderlineNav,
|
88
|
-
Primer::Alpha::UnderlinePanels,
|
89
|
-
Primer::Alpha::TabNav,
|
90
|
-
Primer::Alpha::TabPanels,
|
91
|
-
Primer::Alpha::Tooltip,
|
92
|
-
Primer::Alpha::ToggleSwitch,
|
93
|
-
Primer::Alpha::ActionList,
|
94
|
-
Primer::Alpha::NavList,
|
95
|
-
Primer::Alpha::NavList::Item,
|
96
|
-
Primer::Alpha::NavList::Section,
|
97
|
-
Primer::Alpha::ActionList::Divider,
|
98
|
-
Primer::Alpha::ActionList::Heading,
|
99
|
-
Primer::Alpha::ActionList::Item
|
100
|
-
]
|
101
|
-
|
102
|
-
js_components = [
|
103
|
-
Primer::Alpha::Dropdown,
|
104
|
-
Primer::LocalTime,
|
105
|
-
Primer::Alpha::ImageCrop,
|
106
|
-
Primer::Beta::AutoComplete,
|
107
|
-
Primer::Alpha::Banner,
|
108
|
-
Primer::Beta::ClipboardCopy,
|
109
|
-
Primer::Alpha::TabContainer,
|
110
|
-
Primer::TimeAgoComponent,
|
111
|
-
Primer::Alpha::UnderlinePanels,
|
112
|
-
Primer::Alpha::TabPanels,
|
113
|
-
Primer::Alpha::Tooltip,
|
114
|
-
Primer::ButtonComponent,
|
115
|
-
Primer::IconButton,
|
116
|
-
Primer::Beta::Link,
|
117
|
-
Primer::Alpha::ToggleSwitch,
|
118
|
-
Primer::Alpha::ActionList,
|
119
|
-
Primer::Alpha::NavList,
|
120
|
-
Primer::Alpha::NavList::Section
|
121
|
-
]
|
122
|
-
|
123
|
-
components_without_examples = [
|
124
|
-
# ActionList is a base component that should not be used by itself
|
125
|
-
Primer::Alpha::ActionList,
|
126
|
-
Primer::Alpha::ActionList::Divider,
|
127
|
-
Primer::Alpha::ActionList::Heading,
|
128
|
-
Primer::Alpha::ActionList::Item,
|
129
|
-
|
130
|
-
# Examples can be seen in the NavList docs
|
131
|
-
Primer::Alpha::NavList::Item,
|
132
|
-
Primer::Alpha::NavList::Section
|
133
|
-
]
|
134
|
-
|
135
|
-
all_components = Primer::Component.descendants - [Primer::BaseComponent]
|
136
|
-
components_needing_docs = all_components - components
|
137
|
-
|
138
|
-
args_for_components = []
|
139
|
-
|
140
|
-
errors = []
|
31
|
+
puts "Converting YARD documentation to Markdown files."
|
141
32
|
|
142
33
|
# Deletes docs before regenerating them, guaranteeing that we don't keep stale docs.
|
143
34
|
components_content_glob = File.join(*%w[docs content components ** *.md])
|
144
35
|
FileUtils.rm_rf(components_content_glob)
|
145
36
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
data = docs_metadata(component)
|
150
|
-
|
151
|
-
path = Pathname.new(data[:path])
|
152
|
-
path.dirname.mkpath unless path.dirname.exist?
|
153
|
-
File.open(path, "w") do |f|
|
154
|
-
f.puts("---")
|
155
|
-
f.puts("title: #{data[:title]}")
|
156
|
-
f.puts("componentId: #{data[:component_id]}")
|
157
|
-
f.puts("status: #{data[:status]}")
|
158
|
-
f.puts("source: #{data[:source]}")
|
159
|
-
f.puts("a11yReviewed: #{data[:a11y_reviewed]}")
|
160
|
-
f.puts("lookbook: #{data[:lookbook]}") if preview_exists?(component)
|
161
|
-
f.puts("---")
|
162
|
-
f.puts
|
163
|
-
f.puts("import Example from '#{data[:example_path]}'")
|
164
|
-
|
165
|
-
initialize_method = documentation.meths.find(&:constructor?)
|
166
|
-
|
167
|
-
if js_components.include?(component)
|
168
|
-
f.puts("import RequiresJSFlash from '#{data[:require_js_path]}'")
|
169
|
-
f.puts
|
170
|
-
f.puts("<RequiresJSFlash />")
|
171
|
-
end
|
172
|
-
|
173
|
-
f.puts
|
174
|
-
f.puts("<!-- Warning: AUTO-GENERATED file, do not edit. Add code comments to your Ruby instead <3 -->")
|
175
|
-
f.puts
|
176
|
-
f.puts(view_context.render(inline: documentation.base_docstring))
|
177
|
-
|
178
|
-
if documentation.tags(:deprecated).any?
|
179
|
-
f.puts
|
180
|
-
f.puts("## Deprecation")
|
181
|
-
documentation.tags(:deprecated).each do |tag|
|
182
|
-
f.puts
|
183
|
-
f.puts view_context.render(inline: tag.text)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
if documentation.tags(:accessibility).any?
|
188
|
-
f.puts
|
189
|
-
f.puts("## Accessibility")
|
190
|
-
documentation.tags(:accessibility).each do |tag|
|
191
|
-
f.puts
|
192
|
-
f.puts view_context.render(inline: tag.text)
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
params = initialize_method.tags(:param)
|
197
|
-
|
198
|
-
errors << { component.name => { arguments: "No argument documentation found" } } unless params.any?
|
199
|
-
|
200
|
-
f.puts
|
201
|
-
f.puts("## Arguments")
|
202
|
-
f.puts
|
203
|
-
f.puts("| Name | Type | Default | Description |")
|
204
|
-
f.puts("| :- | :- | :- | :- |")
|
205
|
-
|
206
|
-
documented_params = params.map(&:name)
|
207
|
-
component_params = component.instance_method(:initialize).parameters.map { |p| p.last.to_s }
|
208
|
-
|
209
|
-
if (documented_params & component_params).size != component_params.size
|
210
|
-
err = { arguments: {} }
|
211
|
-
(component_params - documented_params).each do |arg|
|
212
|
-
err[:arguments][arg] = "Not documented"
|
213
|
-
end
|
214
|
-
|
215
|
-
errors << { component.name => err }
|
216
|
-
end
|
217
|
-
|
218
|
-
args = []
|
219
|
-
params.each do |tag|
|
220
|
-
default_value = pretty_default_value(tag, component)
|
221
|
-
|
222
|
-
args << {
|
223
|
-
"name" => tag.name,
|
224
|
-
"type" => tag.types.join(", "),
|
225
|
-
"default" => default_value,
|
226
|
-
"description" => view_context.render(inline: tag.text.squish)
|
227
|
-
}
|
228
|
-
|
229
|
-
f.puts("| `#{tag.name}` | `#{tag.types.join(', ')}` | #{default_value} | #{view_context.render(inline: tag.text.squish)} |")
|
230
|
-
end
|
231
|
-
|
232
|
-
component_args = {
|
233
|
-
"component" => data[:title],
|
234
|
-
"status" => component.status.to_s,
|
235
|
-
"source" => data[:source],
|
236
|
-
"lookbook" => data[:lookbook],
|
237
|
-
"parameters" => args
|
238
|
-
}
|
239
|
-
|
240
|
-
args_for_components << component_args
|
241
|
-
|
242
|
-
# Slots V2 docs
|
243
|
-
slot_v2_methods = documentation.meths.select do |mtd|
|
244
|
-
(mtd[:renders_one] || mtd[:renders_many]) && mtd.tag(:private).nil?
|
245
|
-
end
|
246
|
-
|
247
|
-
if slot_v2_methods.any?
|
248
|
-
f.puts
|
249
|
-
f.puts("## Slots")
|
250
|
-
|
251
|
-
slot_v2_methods.each do |slot_documentation|
|
252
|
-
f.puts
|
253
|
-
f.puts("### `#{slot_documentation.name}`")
|
254
|
-
|
255
|
-
if slot_documentation.base_docstring.to_s.present?
|
256
|
-
f.puts
|
257
|
-
f.puts(view_context.render(inline: slot_documentation.base_docstring))
|
258
|
-
end
|
259
|
-
|
260
|
-
param_tags = slot_documentation.tags(:param)
|
261
|
-
if param_tags.any?
|
262
|
-
f.puts
|
263
|
-
f.puts("| Name | Type | Default | Description |")
|
264
|
-
f.puts("| :- | :- | :- | :- |")
|
265
|
-
end
|
266
|
-
|
267
|
-
param_tags.each do |tag|
|
268
|
-
f.puts("| `#{tag.name}` | `#{tag.types.join(', ')}` | #{pretty_default_value(tag, component)} | #{view_context.render(inline: tag.text)} |")
|
269
|
-
end
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
example_tags = initialize_method.tags(:example)
|
274
|
-
|
275
|
-
if example_tags.any?
|
276
|
-
f.puts
|
277
|
-
f.puts("## Examples")
|
278
|
-
|
279
|
-
example_tags.each do |tag|
|
280
|
-
name, description, code = parse_example_tag(tag)
|
281
|
-
f.puts
|
282
|
-
f.puts("### #{name}")
|
283
|
-
if description
|
284
|
-
f.puts
|
285
|
-
f.puts(view_context.render(inline: description.squish))
|
286
|
-
end
|
287
|
-
f.puts
|
288
|
-
html = view_context.render(inline: code)
|
289
|
-
f.puts("<Example src=\"#{html.tr('"', "\'").delete("\n")}\" />")
|
290
|
-
f.puts
|
291
|
-
f.puts("```erb")
|
292
|
-
f.puts(code.to_s)
|
293
|
-
f.puts("```")
|
294
|
-
end
|
295
|
-
else
|
296
|
-
errors << { component.name => { example: "No examples found" } } unless components_without_examples.include?(component)
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end
|
37
|
+
backend = Primer::YARD::LegacyGatsbyBackend.new(registry)
|
38
|
+
args_for_components, errors = backend.generate
|
300
39
|
|
301
40
|
unless errors.empty?
|
302
41
|
puts "==============================================="
|
@@ -307,43 +46,24 @@ namespace :docs do
|
|
307
46
|
puts "==============================================="
|
308
47
|
puts "==============================================="
|
309
48
|
|
310
|
-
|
49
|
+
raise
|
311
50
|
end
|
312
51
|
|
313
52
|
File.open("static/arguments.json", "w") do |f|
|
314
53
|
f.puts JSON.pretty_generate(args_for_components)
|
315
54
|
end
|
316
55
|
|
317
|
-
# Build system arguments docs from BaseComponent
|
318
|
-
documentation = registry.get(Primer::BaseComponent.name)
|
319
|
-
File.open("docs/content/system-arguments.md", "w") do |f|
|
320
|
-
f.puts("---")
|
321
|
-
f.puts("title: System arguments")
|
322
|
-
f.puts("---")
|
323
|
-
f.puts
|
324
|
-
f.puts("<!-- Warning: AUTO-GENERATED file, do not edit. Add code comments to your Ruby instead <3 -->")
|
325
|
-
f.puts
|
326
|
-
f.puts(documentation.base_docstring)
|
327
|
-
f.puts
|
328
|
-
|
329
|
-
initialize_method = documentation.meths.find(&:constructor?)
|
330
|
-
|
331
|
-
f.puts(view_context.render(inline: initialize_method.base_docstring))
|
332
|
-
end
|
333
|
-
|
334
|
-
# Copy over ADR docs and insert them into the nav
|
335
|
-
puts "Copying ADRs..."
|
336
|
-
Rake::Task["docs:build_adrs"].invoke
|
337
|
-
|
338
56
|
puts "Markdown compiled."
|
339
57
|
|
58
|
+
components_needing_docs = Primer::YARD::ComponentManifest.components_without_docs
|
59
|
+
|
340
60
|
if components_needing_docs.any?
|
341
61
|
puts
|
342
62
|
puts "The following components needs docs. Care to contribute them? #{components_needing_docs.map(&:name).join(', ')}"
|
343
63
|
end
|
344
64
|
end
|
345
65
|
|
346
|
-
task :
|
66
|
+
task :build_gatsby_adrs do
|
347
67
|
adr_content_dir = File.join(*%w[docs content adr])
|
348
68
|
|
349
69
|
FileUtils.rm_rf(File.join(adr_content_dir))
|
@@ -388,36 +108,35 @@ namespace :docs do
|
|
388
108
|
File.write(nav_yaml_file, YAML.dump(nav_yaml))
|
389
109
|
end
|
390
110
|
|
391
|
-
task :
|
392
|
-
registry =
|
111
|
+
task preview: :build_yard_registry do
|
112
|
+
registry = Primer::YARD::Registry.make
|
113
|
+
|
114
|
+
require "primer/yard/legacy_gatsby_backend"
|
393
115
|
|
394
116
|
FileUtils.rm_rf("previews/primer/docs/")
|
395
117
|
|
396
|
-
|
118
|
+
manifest = Primer::YARD::ComponentManifest
|
397
119
|
|
398
120
|
# Generate previews from documentation examples
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
initialize_method = documentation.meths.find(&:constructor?)
|
121
|
+
manifest.all_components.each do |component|
|
122
|
+
docs = registry.find(component)
|
123
|
+
next unless docs.constructor&.tags(:example)&.any?
|
403
124
|
|
404
|
-
|
125
|
+
yard_example_tags = docs.constructor.tags(:example)
|
405
126
|
|
406
|
-
|
407
|
-
|
408
|
-
path = Pathname.new("previews/docs/#{short_name.underscore}_preview.rb")
|
127
|
+
path = Pathname.new("previews/docs/#{docs.short_name.underscore}_preview.rb")
|
409
128
|
path.dirname.mkdir unless path.dirname.exist?
|
410
129
|
|
411
130
|
File.open(path, "w") do |f|
|
412
131
|
f.puts("module Docs")
|
413
|
-
f.puts(" class #{short_name}Preview < ViewComponent::Preview")
|
132
|
+
f.puts(" class #{docs.short_name}Preview < ViewComponent::Preview")
|
414
133
|
|
415
134
|
yard_example_tags.each_with_index do |tag, index|
|
416
|
-
name, _, code = parse_example_tag(tag)
|
135
|
+
name, _, code = Primer::YARD::LegacyGatsbyBackend.parse_example_tag(tag)
|
417
136
|
method_name = name.split("|").first.downcase.parameterize.underscore
|
418
137
|
f.puts(" def #{method_name}; end")
|
419
138
|
f.puts unless index == yard_example_tags.size - 1
|
420
|
-
path = Pathname.new("previews/docs/#{short_name.underscore}_preview/#{method_name}.html.erb")
|
139
|
+
path = Pathname.new("previews/docs/#{docs.short_name.underscore}_preview/#{method_name}.html.erb")
|
421
140
|
path.dirname.mkdir unless path.dirname.exist?
|
422
141
|
File.open(path, "w") do |view_file|
|
423
142
|
view_file.puts(code.to_s)
|
@@ -430,113 +149,26 @@ namespace :docs do
|
|
430
149
|
end
|
431
150
|
end
|
432
151
|
|
433
|
-
|
152
|
+
task :init_pvc do
|
434
153
|
ENV["RAILS_ENV"] = "test"
|
435
154
|
require File.expand_path("./../../demo/config/environment.rb", __dir__)
|
436
|
-
require "primer/view_components"
|
437
|
-
require "yard/docs_helper"
|
438
|
-
require "view_component/test_helpers"
|
439
|
-
include ViewComponent::TestHelpers
|
440
|
-
include Primer::ViewHelper
|
441
|
-
include YARD::DocsHelper
|
442
|
-
|
443
155
|
Dir["./app/components/primer/**/*.rb"].sort.each { |file| require file }
|
444
|
-
|
445
|
-
YARD::Rake::YardocTask.new
|
446
|
-
|
447
|
-
# Custom tags for yard
|
448
|
-
YARD::Tags::Library.define_tag("Accessibility", :accessibility)
|
449
|
-
YARD::Tags::Library.define_tag("Deprecation", :deprecation)
|
450
|
-
YARD::Tags::Library.define_tag("Parameter", :param, :with_types_name_and_default)
|
451
|
-
|
452
|
-
puts "Building YARD documentation."
|
453
|
-
Rake::Task["yard"].execute
|
454
|
-
|
455
|
-
registry = YARD::RegistryStore.new
|
456
|
-
registry.load!(".yardoc")
|
457
|
-
registry
|
458
156
|
end
|
459
157
|
|
460
|
-
|
461
|
-
|
462
|
-
description = nil
|
463
|
-
code = nil
|
158
|
+
task build_yard_registry: :init_pvc do
|
159
|
+
require "primer/yard/registry"
|
464
160
|
|
465
|
-
|
466
|
-
|
467
|
-
description = splitted.second.gsub(/^[ \t]{2}/, "").strip
|
468
|
-
code = splitted.last.gsub(/^[ \t]{2}/, "").strip
|
469
|
-
else
|
470
|
-
code = tag.text
|
161
|
+
::YARD::Rake::YardocTask.new do |task|
|
162
|
+
task.options << "--no-output"
|
471
163
|
end
|
472
164
|
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
default = tag.defaults&.first || params&.second
|
479
|
-
|
480
|
-
return "N/A" unless default
|
481
|
-
|
482
|
-
constant_name = "#{component.name}::#{default}"
|
483
|
-
constant_value = default.safe_constantize || constant_name.safe_constantize
|
484
|
-
|
485
|
-
return pretty_value(default) if constant_value.nil?
|
486
|
-
|
487
|
-
pretty_value(constant_value)
|
488
|
-
end
|
489
|
-
|
490
|
-
def docs_metadata(component)
|
491
|
-
status_module, short_name, class_name = status_module_and_short_name(component)
|
492
|
-
status_path = status_module.nil? ? "" : "#{status_module}/"
|
493
|
-
status = component.status.to_s
|
494
|
-
a11y_reviewed = component.audited_at.nil? ? "false" : "true"
|
495
|
-
|
496
|
-
{
|
497
|
-
title: class_name,
|
498
|
-
component_id: short_name.underscore,
|
499
|
-
status: status.capitalize,
|
500
|
-
a11y_reviewed: a11y_reviewed,
|
501
|
-
source: source_url(component),
|
502
|
-
lookbook: lookbook_url(component),
|
503
|
-
path: "docs/content/components/#{status_path}#{short_name.downcase}.md",
|
504
|
-
example_path: example_path(component),
|
505
|
-
require_js_path: require_js_path(component)
|
506
|
-
}
|
507
|
-
end
|
508
|
-
|
509
|
-
def source_url(component)
|
510
|
-
path = component.name.split("::").map(&:underscore).join("/")
|
511
|
-
|
512
|
-
"https://github.com/primer/view_components/tree/main/app/components/#{path}.rb"
|
513
|
-
end
|
514
|
-
|
515
|
-
def lookbook_url(component)
|
516
|
-
path = component.name.underscore.gsub("_component", "")
|
517
|
-
|
518
|
-
"https://primer.style/view-components/lookbook/inspect/#{path}/default/"
|
519
|
-
end
|
520
|
-
|
521
|
-
def preview_exists?(component)
|
522
|
-
path = component.name.underscore
|
523
|
-
|
524
|
-
File.exist?("previews/#{path}_preview.rb")
|
525
|
-
end
|
526
|
-
|
527
|
-
def example_path(component)
|
528
|
-
example_path = "../../src/@primer/gatsby-theme-doctocat/components/example"
|
529
|
-
example_path = "../#{example_path}" if status_module?(component)
|
530
|
-
example_path
|
531
|
-
end
|
532
|
-
|
533
|
-
def require_js_path(component)
|
534
|
-
require_js_path = "../../src/@primer/gatsby-theme-doctocat/components/requires-js-flash"
|
535
|
-
require_js_path = "../#{require_js_path}" if status_module?(component)
|
536
|
-
require_js_path
|
537
|
-
end
|
165
|
+
# Custom tags for yard
|
166
|
+
::YARD::Tags::Library.define_tag("Accessibility", :accessibility)
|
167
|
+
::YARD::Tags::Library.define_tag("Deprecation", :deprecation)
|
168
|
+
::YARD::Tags::Library.define_tag("Parameter", :param, :with_types_name_and_default)
|
169
|
+
::YARD::Tags::Library.define_tag("Form Usage", :form_usage)
|
538
170
|
|
539
|
-
|
540
|
-
|
171
|
+
puts "Building YARD documentation."
|
172
|
+
Rake::Task["yard"].execute
|
541
173
|
end
|
542
174
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<div>
|
2
|
+
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p>
|
3
|
+
<%= render(Primer::Alpha::Dialog.new(id: "dialog-one", title: title, subtitle: subtitle, visually_hide_title: false)) do |d| %>
|
4
|
+
<% d.show_button { button_text } %>
|
5
|
+
<% d.body do %>
|
6
|
+
<p>Dialog</p>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
</div>
|
@@ -127,6 +127,21 @@ module Primer
|
|
127
127
|
show_divider: show_divider
|
128
128
|
})
|
129
129
|
end
|
130
|
+
|
131
|
+
# @label Page with scrollbar and dialog
|
132
|
+
#
|
133
|
+
# @param title [String] text
|
134
|
+
# @param subtitle [String] text
|
135
|
+
# @param button_text [String] text
|
136
|
+
# @param show_divider [Boolean] toggle
|
137
|
+
def body_has_scrollbar_overflow(title: "Test Dialog", subtitle: nil, button_text: "Show Dialog", show_divider: true)
|
138
|
+
render_with_template(locals: {
|
139
|
+
title: title,
|
140
|
+
subtitle: subtitle,
|
141
|
+
button_text: button_text,
|
142
|
+
show_divider: show_divider
|
143
|
+
})
|
144
|
+
end
|
130
145
|
end
|
131
146
|
end
|
132
147
|
end
|
data/static/arguments.json
CHANGED
@@ -2231,38 +2231,6 @@
|
|
2231
2231
|
}
|
2232
2232
|
]
|
2233
2233
|
},
|
2234
|
-
{
|
2235
|
-
"component": "DropdownMenu",
|
2236
|
-
"status": "deprecated",
|
2237
|
-
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/dropdown_menu_component.rb",
|
2238
|
-
"lookbook": "https://primer.style/view-components/lookbook/inspect/primer/dropdown_menu/default/",
|
2239
|
-
"parameters": [
|
2240
|
-
{
|
2241
|
-
"name": "direction",
|
2242
|
-
"type": "Symbol",
|
2243
|
-
"default": "`:se`",
|
2244
|
-
"description": "One of `:e`, `:ne`, `:s`, `:se`, `:sw`, or `:w`."
|
2245
|
-
},
|
2246
|
-
{
|
2247
|
-
"name": "scheme",
|
2248
|
-
"type": "Symbol",
|
2249
|
-
"default": "`:default`",
|
2250
|
-
"description": "Pass `:dark` for dark mode theming"
|
2251
|
-
},
|
2252
|
-
{
|
2253
|
-
"name": "header",
|
2254
|
-
"type": "String",
|
2255
|
-
"default": "`nil`",
|
2256
|
-
"description": "Optional string to display as the header"
|
2257
|
-
},
|
2258
|
-
{
|
2259
|
-
"name": "system_arguments",
|
2260
|
-
"type": "Hash",
|
2261
|
-
"default": "N/A",
|
2262
|
-
"description": "[System arguments](/system-arguments)"
|
2263
|
-
}
|
2264
|
-
]
|
2265
|
-
},
|
2266
2234
|
{
|
2267
2235
|
"component": "IconButton",
|
2268
2236
|
"status": "deprecated",
|
data/static/audited_at.json
CHANGED
@@ -73,15 +73,12 @@
|
|
73
73
|
"Primer::Beta::Truncate::TruncateText": "",
|
74
74
|
"Primer::BlankslateComponent": "",
|
75
75
|
"Primer::Box": "",
|
76
|
-
"Primer::BoxComponent": "",
|
77
76
|
"Primer::ButtonComponent": "",
|
78
|
-
"Primer::ClipboardCopy": "",
|
79
77
|
"Primer::ConditionalWrapper": "",
|
80
78
|
"Primer::Content": "",
|
81
79
|
"Primer::Dropdown": "",
|
82
80
|
"Primer::Dropdown::Menu": "",
|
83
81
|
"Primer::Dropdown::Menu::Item": "",
|
84
|
-
"Primer::DropdownMenuComponent": "",
|
85
82
|
"Primer::HellipButton": "",
|
86
83
|
"Primer::IconButton": "",
|
87
84
|
"Primer::LabelComponent": "",
|
data/static/constants.json
CHANGED
@@ -1000,8 +1000,6 @@
|
|
1000
1000
|
},
|
1001
1001
|
"Primer::Box": {
|
1002
1002
|
},
|
1003
|
-
"Primer::BoxComponent": {
|
1004
|
-
},
|
1005
1003
|
"Primer::ButtonComponent": {
|
1006
1004
|
"DEFAULT_SCHEME": "default",
|
1007
1005
|
"DEFAULT_SIZE": "medium",
|
@@ -1031,8 +1029,6 @@
|
|
1031
1029
|
"medium"
|
1032
1030
|
]
|
1033
1031
|
},
|
1034
|
-
"Primer::ClipboardCopy": {
|
1035
|
-
},
|
1036
1032
|
"Primer::ConditionalWrapper": {
|
1037
1033
|
},
|
1038
1034
|
"Primer::Content": {
|
@@ -1045,22 +1041,6 @@
|
|
1045
1041
|
},
|
1046
1042
|
"Primer::Dropdown::Menu::Item": {
|
1047
1043
|
},
|
1048
|
-
"Primer::DropdownMenuComponent": {
|
1049
|
-
"DIRECTION_DEFAULT": "se",
|
1050
|
-
"DIRECTION_OPTIONS": [
|
1051
|
-
"se",
|
1052
|
-
"sw",
|
1053
|
-
"w",
|
1054
|
-
"e",
|
1055
|
-
"ne",
|
1056
|
-
"s"
|
1057
|
-
],
|
1058
|
-
"SCHEME_DEFAULT": "default",
|
1059
|
-
"SCHEME_MAPPINGS": {
|
1060
|
-
"default": "",
|
1061
|
-
"dark": "dropdown-menu-dark"
|
1062
|
-
}
|
1063
|
-
},
|
1064
1044
|
"Primer::HellipButton": {
|
1065
1045
|
},
|
1066
1046
|
"Primer::IconButton": {
|
data/static/statuses.json
CHANGED
@@ -73,15 +73,12 @@
|
|
73
73
|
"Primer::Beta::Truncate::TruncateText": "alpha",
|
74
74
|
"Primer::BlankslateComponent": "deprecated",
|
75
75
|
"Primer::Box": "stable",
|
76
|
-
"Primer::BoxComponent": "deprecated",
|
77
76
|
"Primer::ButtonComponent": "deprecated",
|
78
|
-
"Primer::ClipboardCopy": "deprecated",
|
79
77
|
"Primer::ConditionalWrapper": "alpha",
|
80
78
|
"Primer::Content": "stable",
|
81
79
|
"Primer::Dropdown": "deprecated",
|
82
80
|
"Primer::Dropdown::Menu": "deprecated",
|
83
81
|
"Primer::Dropdown::Menu::Item": "deprecated",
|
84
|
-
"Primer::DropdownMenuComponent": "deprecated",
|
85
82
|
"Primer::HellipButton": "deprecated",
|
86
83
|
"Primer::IconButton": "deprecated",
|
87
84
|
"Primer::LabelComponent": "deprecated",
|