primer_view_components 0.0.111 → 0.0.113
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +68 -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 +3 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_list.css +1 -1
- data/app/components/primer/alpha/action_list.css.json +1 -1
- data/app/components/primer/alpha/action_list.css.map +1 -1
- data/app/components/primer/alpha/action_list.pcss +0 -15
- data/app/components/primer/alpha/auto_complete.css +1 -0
- data/app/components/primer/alpha/auto_complete.css.json +1 -0
- data/app/components/primer/alpha/auto_complete.css.map +1 -0
- data/app/components/primer/alpha/auto_complete.pcss +118 -0
- data/app/components/primer/alpha/banner.css +1 -1
- data/app/components/primer/alpha/banner.css.map +1 -1
- data/app/components/primer/alpha/banner.pcss +0 -1
- data/app/components/primer/alpha/button_marketing.css +1 -0
- data/app/components/primer/alpha/button_marketing.css.json +1 -0
- data/app/components/primer/alpha/button_marketing.css.map +1 -0
- data/app/components/primer/alpha/button_marketing.pcss +175 -0
- data/app/components/primer/alpha/dialog/body.rb +3 -0
- data/app/components/primer/alpha/dialog/footer.rb +3 -0
- data/app/components/primer/alpha/dialog/header.rb +3 -0
- data/app/components/primer/alpha/dialog.css +1 -0
- data/app/components/primer/alpha/dialog.css.json +1 -0
- data/app/components/primer/alpha/dialog.css.map +1 -0
- data/app/components/primer/alpha/dialog.pcss +484 -0
- data/app/components/primer/alpha/dialog.rb +3 -0
- data/app/components/primer/{dropdown → alpha/dropdown}/menu.d.ts +0 -0
- data/app/components/primer/{dropdown → alpha/dropdown}/menu.html.erb +0 -0
- data/app/components/primer/{dropdown → alpha/dropdown}/menu.js +0 -0
- data/app/components/primer/alpha/dropdown/menu.rb +105 -0
- data/app/components/primer/{dropdown → alpha/dropdown}/menu.ts +0 -0
- data/app/components/primer/alpha/dropdown.css +1 -0
- data/app/components/primer/alpha/dropdown.css.json +1 -0
- data/app/components/primer/{dropdown.css.map → alpha/dropdown.css.map} +1 -1
- data/app/components/primer/{dropdown.d.ts → alpha/dropdown.d.ts} +0 -0
- data/app/components/primer/{dropdown.html.erb → alpha/dropdown.html.erb} +0 -0
- data/app/components/primer/{dropdown.js → alpha/dropdown.js} +0 -0
- data/app/components/primer/{dropdown.pcss → alpha/dropdown.pcss} +1 -1
- data/app/components/primer/alpha/dropdown.rb +154 -0
- data/app/components/primer/{dropdown.ts → alpha/dropdown.ts} +0 -0
- data/app/components/primer/alpha/segmented_control.css +1 -1
- data/app/components/primer/alpha/segmented_control.css.map +1 -1
- data/app/components/primer/alpha/tab_nav.css +1 -0
- data/app/components/primer/alpha/tab_nav.css.json +1 -0
- data/app/components/primer/alpha/tab_nav.css.map +1 -0
- data/app/components/primer/alpha/tab_nav.pcss +100 -0
- data/app/components/primer/alpha/text_field.css +3 -0
- data/app/components/primer/alpha/text_field.css.json +1 -0
- data/app/components/primer/alpha/text_field.css.map +1 -0
- data/app/components/primer/alpha/text_field.pcss +683 -0
- data/app/components/primer/alpha/toggle_switch.d.ts +1 -1
- data/app/components/primer/alpha/toggle_switch.js +7 -4
- data/app/components/primer/alpha/toggle_switch.ts +7 -3
- data/app/components/primer/alpha/underline_nav.css +1 -0
- data/app/components/primer/alpha/underline_nav.css.json +1 -0
- data/app/components/primer/alpha/underline_nav.css.map +1 -0
- data/app/components/primer/alpha/underline_nav.pcss +133 -0
- data/app/components/primer/beta/border_box.css +1 -0
- data/app/components/primer/beta/border_box.css.json +1 -0
- data/app/components/primer/beta/border_box.css.map +1 -0
- data/app/components/primer/beta/border_box.pcss +284 -0
- data/app/components/primer/beta/button_group.css +1 -0
- data/app/components/primer/beta/button_group.css.json +1 -0
- data/app/components/primer/beta/button_group.css.map +1 -0
- data/app/components/primer/beta/button_group.pcss +92 -0
- data/app/components/primer/{clipboard_copy.d.ts → beta/clipboard_copy.d.ts} +0 -0
- data/app/components/primer/{clipboard_copy.html.erb → beta/clipboard_copy.html.erb} +0 -0
- data/app/components/primer/{clipboard_copy.js → beta/clipboard_copy.js} +0 -0
- data/app/components/primer/beta/clipboard_copy.rb +50 -0
- data/app/components/primer/{clipboard_copy.ts → beta/clipboard_copy.ts} +0 -0
- data/app/components/primer/beta/link.css +1 -0
- data/app/components/primer/beta/link.css.json +1 -0
- data/app/components/primer/beta/link.css.map +1 -0
- data/app/components/primer/beta/link.pcss +60 -0
- data/app/components/primer/{popover_component.css → beta/popover.css} +0 -0
- data/app/components/primer/beta/popover.css.json +1 -0
- data/app/components/primer/beta/popover.css.map +1 -0
- data/app/components/primer/{popover_component.html.erb → beta/popover.html.erb} +0 -0
- data/app/components/primer/{popover_component.pcss → beta/popover.pcss} +5 -5
- data/app/components/primer/beta/popover.rb +127 -0
- data/app/components/primer/beta/relative_time.rb +160 -0
- data/app/components/primer/button_component.css +1 -0
- data/app/components/primer/button_component.css.json +1 -0
- data/app/components/primer/button_component.css.map +1 -0
- data/app/components/primer/button_component.pcss +557 -0
- data/app/components/primer/button_component.rb +1 -1
- data/app/components/primer/clipboard_copy.rb +2 -43
- data/app/components/primer/component.rb +6 -2
- data/app/components/primer/dropdown/menu.rb +5 -90
- data/app/components/primer/dropdown.rb +2 -145
- data/app/components/primer/local_time.d.ts +1 -1
- data/app/components/primer/local_time.js +1 -1
- data/app/components/primer/local_time.rb +3 -1
- data/app/components/primer/local_time.ts +1 -1
- data/app/components/primer/menu_component.css +1 -0
- data/app/components/primer/menu_component.css.json +1 -0
- data/app/components/primer/menu_component.css.map +1 -0
- data/app/components/primer/menu_component.pcss +119 -0
- data/app/components/primer/popover_component.rb +3 -120
- data/app/components/primer/primer.d.ts +2 -2
- data/app/components/primer/primer.js +2 -2
- data/app/components/primer/primer.pcss +20 -3
- data/app/components/primer/primer.ts +2 -2
- data/app/components/primer/time_ago_component.d.ts +1 -1
- data/app/components/primer/time_ago_component.js +1 -1
- data/app/components/primer/time_ago_component.rb +2 -1
- data/app/components/primer/time_ago_component.ts +1 -1
- data/app/forms/submit_button_form.rb +8 -2
- data/app/helpers/primer/form_helper.rb +12 -0
- data/lib/postcss_mixins/clearfix.pcss +12 -0
- data/lib/primer/deprecations.rb +96 -24
- data/lib/primer/deprecations.yml +68 -0
- data/lib/primer/forms/base.rb +7 -20
- data/lib/primer/forms/base_component.rb +15 -1
- data/lib/primer/forms/button.html.erb +4 -0
- data/lib/primer/forms/button.rb +68 -0
- data/lib/primer/forms/check_box.html.erb +2 -2
- data/lib/primer/forms/check_box.rb +1 -1
- data/lib/primer/forms/check_box_group.html.erb +2 -2
- data/lib/primer/forms/dsl/button_input.rb +29 -0
- data/lib/primer/forms/dsl/input_methods.rb +7 -2
- data/lib/primer/forms/dsl/submit_button_input.rb +1 -0
- data/lib/primer/forms/dsl/text_field_input.rb +0 -7
- data/lib/primer/forms/radio_button.html.erb +2 -2
- data/lib/primer/forms/radio_button.rb +1 -1
- data/lib/primer/forms/radio_button_group.html.erb +2 -2
- data/lib/primer/forms/select_list.html.erb +1 -1
- data/lib/primer/forms/select_list.rb +4 -1
- data/lib/primer/forms/submit_button.html.erb +1 -4
- data/lib/primer/forms/submit_button.rb +1 -37
- data/lib/primer/forms/text_area.html.erb +1 -1
- data/lib/primer/forms/text_area.rb +5 -1
- data/lib/primer/forms/text_field.html.erb +1 -1
- data/lib/primer/forms/text_field.rb +11 -0
- data/lib/primer/forms/utils.rb +28 -0
- data/lib/primer/view_components/audited.rb +14 -0
- data/lib/primer/view_components/engine.rb +1 -0
- data/lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb +2 -2
- data/lib/primer/view_components/linters/deprecated_components_counter.rb +15 -4
- data/lib/primer/view_components/linters/helpers/deprecated_components_helpers.rb +3 -18
- data/lib/primer/view_components/linters/severity_schema.rb +14 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/rubocop/cop/primer/component_name_migration.rb +2 -2
- data/lib/tasks/docs.rake +6 -5
- data/previews/primer/alpha/auto_complete_preview.rb +12 -0
- data/previews/primer/alpha/button_marketing_preview.rb +36 -0
- data/previews/primer/alpha/dropdown_preview.rb +210 -0
- data/previews/primer/alpha/segmented_control_preview.rb +9 -6
- data/previews/primer/alpha/tab_nav_preview.rb +55 -0
- data/previews/primer/alpha/text_field_preview.rb +77 -52
- data/previews/primer/beta/border_box_preview.rb +65 -13
- data/previews/primer/beta/clipboard_copy_preview/element.html.erb +2 -0
- data/previews/primer/beta/clipboard_copy_preview.rb +39 -0
- data/previews/primer/beta/link_preview.rb +28 -0
- data/previews/primer/beta/popover_preview.rb +79 -0
- data/previews/primer/beta/relative_time_preview.rb +271 -0
- data/previews/primer/forms/forms_preview.rb +1 -0
- data/static/arguments.json +183 -73
- data/static/audited_at.json +10 -6
- data/static/constants.json +180 -50
- data/static/statuses.json +12 -8
- metadata +86 -29
- data/app/components/primer/dropdown.css +0 -1
- data/app/components/primer/dropdown.css.json +0 -1
- data/app/components/primer/image.rb +0 -7
- data/app/components/primer/popover_component.css.json +0 -1
- data/app/components/primer/popover_component.css.map +0 -1
- data/app/components/primer/progress_bar_component.rb +0 -7
- data/previews/primer/clipboard_copy_preview/element.html.erb +0 -2
- data/previews/primer/clipboard_copy_preview.rb +0 -37
- data/previews/primer/dropdown_preview.rb +0 -208
- data/previews/primer/popover_component_preview.rb +0 -34
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= render(FormControl.new(input: @input)) do %>
|
2
2
|
<% if @input.leading_visual || @input.show_clear_button? %>
|
3
|
-
<%= content_tag(:div,
|
3
|
+
<%= content_tag(:div, **@field_wrap_arguments) do %>
|
4
4
|
<% if @input.leading_visual %>
|
5
5
|
<span class="FormControl-input-leadingVisualWrap">
|
6
6
|
<%= render(Primer::OcticonComponent.new(**@input.leading_visual)) %>
|
@@ -8,6 +8,17 @@ module Primer
|
|
8
8
|
|
9
9
|
def initialize(input:)
|
10
10
|
@input = input
|
11
|
+
|
12
|
+
@field_wrap_arguments = {
|
13
|
+
class: class_names(
|
14
|
+
"FormControl-input-wrap",
|
15
|
+
Primer::Forms::Dsl::Input::SIZE_MAPPINGS[@input.size],
|
16
|
+
"FormControl-input-wrap--trailingAction": @input.show_clear_button?,
|
17
|
+
"FormControl-input-wrap--leadingVisual": @input.leading_visual?
|
18
|
+
),
|
19
|
+
|
20
|
+
hidden: @input.hidden?
|
21
|
+
}
|
11
22
|
end
|
12
23
|
end
|
13
24
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
# :nodoc:
|
5
|
+
module Forms
|
6
|
+
# :nodoc:
|
7
|
+
module Utils
|
8
|
+
# Unfortunately this bug (https://github.com/ruby/ruby/pull/5646) prevents us from using
|
9
|
+
# Ruby's native Module.const_source_location. Instead we have to fudge it by searching
|
10
|
+
# for the file in the configured autoload paths. Doing so relies on Rails' autoloading
|
11
|
+
# conventions, so it should work ok. Zeitwerk also has this information but lacks a
|
12
|
+
# public API to map constants to source files.
|
13
|
+
def const_source_location(class_name)
|
14
|
+
# NOTE: underscore respects namespacing, i.e. will convert Foo::Bar to foo/bar.
|
15
|
+
class_path = "#{class_name.underscore}.rb"
|
16
|
+
|
17
|
+
ActiveSupport::Dependencies.autoload_paths.each do |autoload_path|
|
18
|
+
absolute_path = File.join(autoload_path, class_path)
|
19
|
+
return absolute_path if File.exist?(absolute_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Utils.extend(Utils)
|
27
|
+
end
|
28
|
+
end
|
@@ -57,6 +57,7 @@ module Primer
|
|
57
57
|
autoloader.ignore(Engine.root.join("lib", "primer", "view_components", "linters.rb"))
|
58
58
|
autoloader.ignore(Engine.root.join("lib", "primer", "view_components", "linters", "**", "*.rb"))
|
59
59
|
autoloader.ignore(Engine.root.join("lib", "primer", "view_components", "statuses.rb"))
|
60
|
+
autoloader.ignore(Engine.root.join("lib", "primer", "view_components", "audited.rb"))
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
@@ -12,9 +12,9 @@ module ERBLint
|
|
12
12
|
|
13
13
|
TAGS = %w[clipboard-copy].freeze
|
14
14
|
REQUIRED_ARGUMENTS = [/for|value/, "aria-label"].freeze
|
15
|
-
MESSAGE = "We are migrating clipboard-copy to use [Primer::ClipboardCopy](https://primer.style/view-components/components/clipboardcopy), please try to use that instead of raw HTML."
|
15
|
+
MESSAGE = "We are migrating clipboard-copy to use [Primer::Beta::ClipboardCopy](https://primer.style/view-components/components/clipboardcopy), please try to use that instead of raw HTML."
|
16
16
|
ARGUMENT_MAPPER = ArgumentMappers::ClipboardCopy
|
17
|
-
COMPONENT = "Primer::ClipboardCopy"
|
17
|
+
COMPONENT = "Primer::Beta::ClipboardCopy"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "helpers/deprecated_components_helpers"
|
4
|
+
require_relative "severity_schema"
|
5
|
+
|
4
6
|
require "erblint-github/linters/custom_helpers"
|
5
7
|
|
6
8
|
module ERBLint
|
@@ -11,6 +13,8 @@ module ERBLint
|
|
11
13
|
include ERBLint::LinterRegistry
|
12
14
|
include Helpers::DeprecatedComponentsHelpers
|
13
15
|
|
16
|
+
self.config_schema = SeveritySchema
|
17
|
+
|
14
18
|
def run(processed_source)
|
15
19
|
processed_source.ast.descendants(:erb).each do |erb_node|
|
16
20
|
_, _, code_node = *erb_node
|
@@ -21,10 +25,7 @@ module ERBLint
|
|
21
25
|
deprecated_components.each do |component|
|
22
26
|
next unless code.include?(component)
|
23
27
|
|
24
|
-
add_offense(
|
25
|
-
erb_node.loc,
|
26
|
-
message(component)
|
27
|
-
)
|
28
|
+
add_offense(erb_node.loc, message(component))
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
@@ -44,6 +45,16 @@ module ERBLint
|
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
48
|
+
|
49
|
+
# this override is necessary because of the github/erblint-github `CustomHelpers`
|
50
|
+
# module. `counter_correct?` is provided by this module, and calls `add_offense`
|
51
|
+
# directly. there is no simple way to modify this without updating the gem and
|
52
|
+
# creating what would likely be an API that is non-standard and/or difficult to use
|
53
|
+
#
|
54
|
+
# https://github.com/github/erblint-github/blob/main/lib/erblint-github/linters/custom_helpers.rb
|
55
|
+
def add_offense(source_range, message, context = nil, severity = nil)
|
56
|
+
super(source_range, message, context, severity || @config.severity)
|
57
|
+
end
|
47
58
|
end
|
48
59
|
end
|
49
60
|
end
|
@@ -7,27 +7,12 @@ module ERBLint
|
|
7
7
|
module Helpers
|
8
8
|
# Helpers to share between DeprecatedComponents ERB lint and Rubocop cop
|
9
9
|
module DeprecatedComponentsHelpers
|
10
|
-
def message(
|
11
|
-
|
12
|
-
|
13
|
-
if Primer::Deprecations.correctable?(component)
|
14
|
-
suggested_component = Primer::Deprecations.suggested_component(component)
|
15
|
-
message += " Try #{suggested_component} instead."
|
16
|
-
end
|
17
|
-
|
18
|
-
message
|
19
|
-
end
|
20
|
-
|
21
|
-
def statuses_json
|
22
|
-
JSON.parse(
|
23
|
-
File.read(
|
24
|
-
File.join(File.dirname(__FILE__), "../../../../../static/statuses.json")
|
25
|
-
)
|
26
|
-
).freeze
|
10
|
+
def message(component_name)
|
11
|
+
Primer::Deprecations.deprecation_message(component_name)
|
27
12
|
end
|
28
13
|
|
29
14
|
def deprecated_components
|
30
|
-
|
15
|
+
Primer::Deprecations.deprecated_components
|
31
16
|
end
|
32
17
|
end
|
33
18
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "erb_lint/utils/severity_levels"
|
4
|
+
|
5
|
+
module ERBLint
|
6
|
+
module Linters
|
7
|
+
class SeveritySchema < LinterConfig
|
8
|
+
# SEVERITY_NAMES :info, :refactor, :convention, :warning, :error, :fatal
|
9
|
+
# see https://github.com/Shopify/erb-lint/blob/main/lib/erb_lint/utils/severity_levels.rb
|
10
|
+
|
11
|
+
property :severity, accepts: ERBLint::Utils::SeverityLevels::SEVERITY_NAMES, default: nil, reader: :severity
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -26,8 +26,8 @@ module RuboCop
|
|
26
26
|
component_name = node.const_name
|
27
27
|
return unless ::Primer::Deprecations.correctable?(component_name)
|
28
28
|
|
29
|
-
|
30
|
-
corrector.replace(node,
|
29
|
+
replacement = ::Primer::Deprecations.replacement(component_name)
|
30
|
+
corrector.replace(node, replacement) if replacement.present?
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/tasks/docs.rake
CHANGED
@@ -29,6 +29,7 @@ namespace :docs do
|
|
29
29
|
# Rails controller for rendering arbitrary ERB
|
30
30
|
view_context = ApplicationController.new.tap { |c| c.request = ActionDispatch::TestRequest.create }.view_context
|
31
31
|
components = [
|
32
|
+
Primer::Beta::RelativeTime,
|
32
33
|
Primer::Beta::IconButton,
|
33
34
|
Primer::Beta::Button,
|
34
35
|
Primer::Alpha::SegmentedControl,
|
@@ -53,12 +54,12 @@ namespace :docs do
|
|
53
54
|
Primer::ButtonComponent,
|
54
55
|
Primer::Beta::ButtonGroup,
|
55
56
|
Primer::Alpha::ButtonMarketing,
|
56
|
-
Primer::ClipboardCopy,
|
57
|
+
Primer::Beta::ClipboardCopy,
|
57
58
|
Primer::Beta::CloseButton,
|
58
59
|
Primer::Beta::Counter,
|
59
60
|
Primer::Beta::Details,
|
60
61
|
Primer::Alpha::Dialog,
|
61
|
-
Primer::Dropdown,
|
62
|
+
Primer::Alpha::Dropdown,
|
62
63
|
Primer::DropdownMenuComponent,
|
63
64
|
Primer::Beta::Flash,
|
64
65
|
Primer::Beta::Heading,
|
@@ -70,7 +71,7 @@ namespace :docs do
|
|
70
71
|
Primer::MenuComponent,
|
71
72
|
Primer::Navigation::TabComponent,
|
72
73
|
Primer::OcticonComponent,
|
73
|
-
Primer::
|
74
|
+
Primer::Beta::Popover,
|
74
75
|
Primer::Beta::ProgressBar,
|
75
76
|
Primer::StateComponent,
|
76
77
|
Primer::SpinnerComponent,
|
@@ -99,12 +100,12 @@ namespace :docs do
|
|
99
100
|
]
|
100
101
|
|
101
102
|
js_components = [
|
102
|
-
Primer::Dropdown,
|
103
|
+
Primer::Alpha::Dropdown,
|
103
104
|
Primer::LocalTime,
|
104
105
|
Primer::Alpha::ImageCrop,
|
105
106
|
Primer::Beta::AutoComplete,
|
106
107
|
Primer::Alpha::Banner,
|
107
|
-
Primer::ClipboardCopy,
|
108
|
+
Primer::Beta::ClipboardCopy,
|
108
109
|
Primer::TabContainerComponent,
|
109
110
|
Primer::TimeAgoComponent,
|
110
111
|
Primer::Alpha::UnderlinePanels,
|
@@ -11,7 +11,9 @@ module Primer
|
|
11
11
|
# @param with_icon toggle
|
12
12
|
# @param is_clearable toggle
|
13
13
|
def playground(label_text: "Select a fruit", is_label_visible: true, is_label_inline: false, with_icon: false, is_clearable: false)
|
14
|
+
# rubocop:disable Primer/ComponentNameMigration
|
14
15
|
render(Primer::Alpha::AutoComplete.new(label_text: label_text, input_id: "input-id", list_id: "test-id", src: "/auto_complete?version=alpha", is_label_visible: is_label_visible, is_label_inline: is_label_inline, with_icon: with_icon, is_clearable: is_clearable))
|
16
|
+
# rubocop:enable Primer/ComponentNameMigration
|
15
17
|
end
|
16
18
|
|
17
19
|
# @label Default Options
|
@@ -21,29 +23,39 @@ module Primer
|
|
21
23
|
# @param with_icon toggle
|
22
24
|
# @param is_clearable toggle
|
23
25
|
def default(label_text: "Select a fruit", is_label_visible: true, is_label_inline: false, with_icon: false, is_clearable: false)
|
26
|
+
# rubocop:disable Primer/ComponentNameMigration
|
24
27
|
render(Primer::Alpha::AutoComplete.new(label_text: label_text, input_id: "input-id", list_id: "test-id", src: "/auto_complete?version=alpha", is_label_visible: is_label_visible, is_label_inline: is_label_inline, with_icon: with_icon, is_clearable: is_clearable))
|
28
|
+
# rubocop:enable Primer/ComponentNameMigration
|
25
29
|
end
|
26
30
|
|
27
31
|
# @!group More examples
|
28
32
|
|
29
33
|
# @label AutoComplete with non-visible label
|
30
34
|
def with_non_visible_label
|
35
|
+
# rubocop:disable Primer/ComponentNameMigration
|
31
36
|
render(Primer::Alpha::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id-1", list_id: "test-id-1", src: "/auto_complete?version=alpha", is_label_visible: false))
|
37
|
+
# rubocop:enable Primer/ComponentNameMigration
|
32
38
|
end
|
33
39
|
|
34
40
|
# @label AutoComplete with inline label
|
35
41
|
def with_inline_label
|
42
|
+
# rubocop:disable Primer/ComponentNameMigration
|
36
43
|
render(Primer::Alpha::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id-2", list_id: "test-id-2", src: "/auto_complete?version=alpha", is_label_inline: true))
|
44
|
+
# rubocop:enable Primer/ComponentNameMigration
|
37
45
|
end
|
38
46
|
|
39
47
|
# @label AutoComplete with search icon
|
40
48
|
def with_icon
|
49
|
+
# rubocop:disable Primer/ComponentNameMigration
|
41
50
|
render(Primer::Alpha::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id-3", list_id: "test-id-3", src: "/auto_complete?version=alpha", with_icon: true))
|
51
|
+
# rubocop:enable Primer/ComponentNameMigration
|
42
52
|
end
|
43
53
|
|
44
54
|
# @label AutoComplete with clear button
|
45
55
|
def with_clear_button
|
56
|
+
# rubocop:disable Primer/ComponentNameMigration
|
46
57
|
render(Primer::Alpha::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id-4", list_id: "test-id-4", src: "/auto_complete?version=alpha", is_clearable: true))
|
58
|
+
# rubocop:enable Primer/ComponentNameMigration
|
47
59
|
end
|
48
60
|
|
49
61
|
# @!endgroup
|
@@ -21,6 +21,42 @@ module Primer
|
|
21
21
|
def default(tag: :button, type: :button, scheme: :default, variant: :default)
|
22
22
|
render(Primer::Alpha::ButtonMarketing.new(tag: tag, type: type, scheme: scheme, variant: variant)) { "Default" }
|
23
23
|
end
|
24
|
+
|
25
|
+
# @!group Size Variants
|
26
|
+
#
|
27
|
+
# @label Default
|
28
|
+
def sizes_default
|
29
|
+
render(Primer::Alpha::ButtonMarketing.new) { "Default" }
|
30
|
+
end
|
31
|
+
|
32
|
+
# @label Large
|
33
|
+
def sizes_large
|
34
|
+
render(Primer::Alpha::ButtonMarketing.new(variant: :large)) { "Large" }
|
35
|
+
end
|
36
|
+
# @!endgroup
|
37
|
+
|
38
|
+
# @!group Schemes
|
39
|
+
#
|
40
|
+
# @label Default
|
41
|
+
def scheme_default
|
42
|
+
render(Primer::Alpha::ButtonMarketing.new) { "Default" }
|
43
|
+
end
|
44
|
+
|
45
|
+
# @label Primary
|
46
|
+
def scheme_primary
|
47
|
+
render(Primer::Alpha::ButtonMarketing.new(scheme: :primary)) { "Primary" }
|
48
|
+
end
|
49
|
+
|
50
|
+
# @label Outline
|
51
|
+
def scheme_outline
|
52
|
+
render(Primer::Alpha::ButtonMarketing.new(scheme: :outline)) { "Outline" }
|
53
|
+
end
|
54
|
+
|
55
|
+
# @label Transparent
|
56
|
+
def scheme_transparent
|
57
|
+
render(Primer::Alpha::ButtonMarketing.new(scheme: :transparent)) { "Transparent" }
|
58
|
+
end
|
59
|
+
# @!endgroup
|
24
60
|
end
|
25
61
|
end
|
26
62
|
end
|
@@ -0,0 +1,210 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label Dropdown
|
6
|
+
class DropdownPreview < ViewComponent::Preview
|
7
|
+
# @label Playground
|
8
|
+
#
|
9
|
+
# @param with_caret [Boolean] toggle
|
10
|
+
# @param overlay [Symbol] select [none, default, dark]
|
11
|
+
def playground(overlay: :default, with_caret: false)
|
12
|
+
render(Primer::Alpha::Dropdown.new(overlay: overlay, with_caret: with_caret)) do |c|
|
13
|
+
c.with_button { "Dropdown" }
|
14
|
+
|
15
|
+
c.with_menu(header: "Header") do |m|
|
16
|
+
m.with_item { "Item 1" }
|
17
|
+
m.with_item { "Item 2" }
|
18
|
+
m.with_item(divider: true)
|
19
|
+
m.with_item { "Item 3" }
|
20
|
+
m.with_item { "Item 4" }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @label Default
|
26
|
+
#
|
27
|
+
def default
|
28
|
+
render(Primer::Alpha::Dropdown.new) do |c|
|
29
|
+
c.with_button { "Dropdown" }
|
30
|
+
c.with_menu do |m|
|
31
|
+
m.with_item { "Item 1" }
|
32
|
+
m.with_item { "Item 2" }
|
33
|
+
m.with_item { "Item 3" }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# @label Menu
|
39
|
+
#
|
40
|
+
# @param as [Symbol] select [list, default]
|
41
|
+
# @param direction [Symbol] select [se, sw, w, e, ne, s]
|
42
|
+
# @param scheme [Symbol] select [default, dark]
|
43
|
+
def menu(as: :default, direction: :se, scheme: :default)
|
44
|
+
render(Primer::Alpha::Dropdown::Menu.new(as: as, direction: direction, scheme: scheme, header: "Header")) do |m|
|
45
|
+
m.with_item { "Item 1" }
|
46
|
+
m.with_item { "Item 2" }
|
47
|
+
m.with_item(divider: true)
|
48
|
+
m.with_item { "Item 3" }
|
49
|
+
m.with_item { "Item 4" }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# @!group Direction
|
54
|
+
#
|
55
|
+
# @label Direction e
|
56
|
+
def direction_e
|
57
|
+
render(Primer::Alpha::Dropdown.new(display: :inline_block)) do |c|
|
58
|
+
c.with_button { "Dropdown" }
|
59
|
+
c.with_menu(direction: :e) do |m|
|
60
|
+
m.with_item { "Item 1" }
|
61
|
+
m.with_item { "Item 2" }
|
62
|
+
m.with_item { "Item 3" }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# @label Direction ne
|
68
|
+
def direction_ne
|
69
|
+
render(Primer::Alpha::Dropdown.new(display: :inline_block)) do |c|
|
70
|
+
c.with_button { "Dropdown" }
|
71
|
+
c.with_menu(direction: :ne) do |m|
|
72
|
+
m.with_item { "Item 1" }
|
73
|
+
m.with_item { "Item 2" }
|
74
|
+
m.with_item { "Item 3" }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# @label Direction s
|
80
|
+
def direction_s
|
81
|
+
render(Primer::Alpha::Dropdown.new(display: :inline_block)) do |c|
|
82
|
+
c.with_button { "Dropdown" }
|
83
|
+
c.with_menu(direction: :s) do |m|
|
84
|
+
m.with_item { "Item 1" }
|
85
|
+
m.with_item { "Item 2" }
|
86
|
+
m.with_item { "Item 3" }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# @label Direction se
|
92
|
+
def direction_se
|
93
|
+
render(Primer::Alpha::Dropdown.new(display: :inline_block)) do |c|
|
94
|
+
c.with_button { "Dropdown" }
|
95
|
+
c.with_menu(direction: :se) do |m|
|
96
|
+
m.with_item { "Item 1" }
|
97
|
+
m.with_item { "Item 2" }
|
98
|
+
m.with_item { "Item 3" }
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# @label Direction sw
|
104
|
+
def direction_sw
|
105
|
+
render(Primer::Alpha::Dropdown.new(display: :inline_block)) do |c|
|
106
|
+
c.with_button { "Dropdown" }
|
107
|
+
c.with_menu(direction: :sw) do |m|
|
108
|
+
m.with_item { "Item 1" }
|
109
|
+
m.with_item { "Item 2" }
|
110
|
+
m.with_item { "Item 3" }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# @label Direction w
|
116
|
+
def direction_w
|
117
|
+
render(Primer::Alpha::Dropdown.new(display: :inline_block)) do |c|
|
118
|
+
c.with_button { "Dropdown" }
|
119
|
+
c.with_menu(direction: :w) do |m|
|
120
|
+
m.with_item { "Item 1" }
|
121
|
+
m.with_item { "Item 2" }
|
122
|
+
m.with_item { "Item 3" }
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
#
|
127
|
+
# @!endgroup
|
128
|
+
|
129
|
+
# @!group Options
|
130
|
+
#
|
131
|
+
# @label With caret
|
132
|
+
def options_with_caret
|
133
|
+
render(Primer::Alpha::Dropdown.new(with_caret: true)) do |c|
|
134
|
+
c.with_button { "Dropdown" }
|
135
|
+
c.with_menu do |m|
|
136
|
+
m.with_item { "Item 1" }
|
137
|
+
m.with_item { "Item 2" }
|
138
|
+
m.with_item { "Item 3" }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# @label With header
|
144
|
+
def options_with_header
|
145
|
+
render(Primer::Alpha::Dropdown.new) do |c|
|
146
|
+
c.with_button { "Dropdown" }
|
147
|
+
c.with_menu(header: "Header") do |m|
|
148
|
+
m.with_item { "Item 1" }
|
149
|
+
m.with_item { "Item 2" }
|
150
|
+
m.with_item { "Item 3" }
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# @label With dividers
|
156
|
+
def options_with_dividers
|
157
|
+
render(Primer::Alpha::Dropdown.new) do |c|
|
158
|
+
c.with_button { "Dropdown" }
|
159
|
+
c.with_menu do |m|
|
160
|
+
m.with_item { "Item 1" }
|
161
|
+
m.with_item { "Item 2" }
|
162
|
+
m.with_item(divider: true)
|
163
|
+
m.with_item { "Item 3" }
|
164
|
+
m.with_item { "Item 4" }
|
165
|
+
m.with_item(divider: true)
|
166
|
+
m.with_item { "Item 5" }
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# @label As list
|
172
|
+
def options_as_list
|
173
|
+
render(Primer::Alpha::Dropdown.new) do |c|
|
174
|
+
c.with_button { "Dropdown" }
|
175
|
+
c.with_menu(as: :list) do |m|
|
176
|
+
m.with_item { "Item 1" }
|
177
|
+
m.with_item { "Item 2" }
|
178
|
+
m.with_item { "Item 3" }
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# @label Overlay none
|
184
|
+
def options_overlay_none
|
185
|
+
render(Primer::Alpha::Dropdown.new(overlay: :none)) do |c|
|
186
|
+
c.with_button { "Dropdown" }
|
187
|
+
c.with_menu do |m|
|
188
|
+
m.with_item { "Item 1" }
|
189
|
+
m.with_item { "Item 2" }
|
190
|
+
m.with_item { "Item 3" }
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# @label Overlay dark
|
196
|
+
def options_overlay_dark
|
197
|
+
render(Primer::Alpha::Dropdown.new(overlay: :dark)) do |c|
|
198
|
+
c.with_button { "Dropdown" }
|
199
|
+
c.with_menu do |m|
|
200
|
+
m.with_item { "Item 1" }
|
201
|
+
m.with_item { "Item 2" }
|
202
|
+
m.with_item { "Item 3" }
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
#
|
207
|
+
# @!endgroup
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
@@ -34,8 +34,9 @@ module Primer
|
|
34
34
|
|
35
35
|
# @!group Full width
|
36
36
|
# @label Size small
|
37
|
-
|
38
|
-
|
37
|
+
# @param hide_labels [Boolean] toggle
|
38
|
+
def full_width_small(hide_labels: false)
|
39
|
+
render(Primer::Alpha::SegmentedControl.new("aria-label": "File view", hide_labels: hide_labels, full_width: true, size: :small)) do |c|
|
39
40
|
c.with_item(label: "Preview", selected: true)
|
40
41
|
c.with_item(label: "Raw")
|
41
42
|
c.with_item(label: "Blame")
|
@@ -43,8 +44,9 @@ module Primer
|
|
43
44
|
end
|
44
45
|
|
45
46
|
# @label Size medium
|
46
|
-
|
47
|
-
|
47
|
+
# @param hide_labels [Boolean] toggle
|
48
|
+
def full_width_medium(hide_labels: false)
|
49
|
+
render(Primer::Alpha::SegmentedControl.new("aria-label": "File view", hide_labels: hide_labels, full_width: true, size: :medium)) do |c|
|
48
50
|
c.with_item(label: "Preview", selected: true)
|
49
51
|
c.with_item(label: "Raw")
|
50
52
|
c.with_item(label: "Blame")
|
@@ -52,8 +54,9 @@ module Primer
|
|
52
54
|
end
|
53
55
|
|
54
56
|
# @label Size large
|
55
|
-
|
56
|
-
|
57
|
+
# @param hide_labels [Boolean] toggle
|
58
|
+
def full_width_large(hide_labels: false)
|
59
|
+
render(Primer::Alpha::SegmentedControl.new("aria-label": "File view", hide_labels: hide_labels, full_width: true, size: :large)) do |c|
|
57
60
|
c.with_item(label: "Preview", selected: true)
|
58
61
|
c.with_item(label: "Raw")
|
59
62
|
c.with_item(label: "Blame")
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label TabNav
|
6
|
+
class TabNavPreview < ViewComponent::Preview
|
7
|
+
# @label Playground
|
8
|
+
#
|
9
|
+
# @param number_of_tabs [Integer] number
|
10
|
+
# @param with_icons [Boolean] toggle
|
11
|
+
# @param with_counters [Boolean] toggle
|
12
|
+
def playground(number_of_tabs: 3, with_icons: false, with_counters: false)
|
13
|
+
render(Primer::Alpha::TabNav.new(label: "label")) do |c|
|
14
|
+
Array.new(number_of_tabs || 3) do |i|
|
15
|
+
c.with_tab(selected: i.zero?, href: "##{i + 1}") do |t|
|
16
|
+
t.icon(icon: :star) if with_icons
|
17
|
+
t.text { "Tab #{i + 1}" }
|
18
|
+
t.counter(count: 10) if with_counters
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# @label Default
|
25
|
+
def default
|
26
|
+
render(Primer::Alpha::TabNav.new(label: "Default")) do |c|
|
27
|
+
c.with_tab(selected: true, href: "#") { "Tab 1" }
|
28
|
+
c.with_tab(href: "#") { "Tab 2" }
|
29
|
+
c.with_tab(href: "#") { "Tab 3" }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# @label With icons and counters
|
34
|
+
def with_icons_and_counters
|
35
|
+
render(Primer::Alpha::TabNav.new(label: "With icons and counters")) do |c|
|
36
|
+
c.with_tab(href: "#1", selected: true) do |t|
|
37
|
+
t.icon(icon: :star)
|
38
|
+
t.text { "Stars" }
|
39
|
+
t.counter(count: 10)
|
40
|
+
end
|
41
|
+
c.with_tab(href: "#2") do |t|
|
42
|
+
t.icon(icon: :heart)
|
43
|
+
t.text { "Sponsors" }
|
44
|
+
t.counter(count: 14)
|
45
|
+
end
|
46
|
+
c.with_tab(href: "#3") do |t|
|
47
|
+
t.icon(icon: :bookmark)
|
48
|
+
t.text { "Bookmarks" }
|
49
|
+
t.counter(count: 7)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|