primer_view_components 0.0.33 → 0.0.38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +102 -0
  3. data/app/assets/javascripts/primer_view_components.js +1 -1
  4. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  5. data/app/components/primer/{auto_complete_component.rb → auto_complete.rb} +13 -11
  6. data/app/components/primer/{auto_complete_component.d.ts → auto_complete/auto_complete.d.ts} +0 -0
  7. data/app/components/primer/{auto_complete_component.html.erb → auto_complete/auto_complete.html.erb} +0 -0
  8. data/app/components/primer/{auto_complete_component.js → auto_complete/auto_complete.js} +0 -0
  9. data/app/components/primer/{auto_complete_component.ts → auto_complete/auto_complete.ts} +0 -0
  10. data/app/components/primer/auto_complete/auto_component.d.ts +1 -0
  11. data/app/components/primer/auto_complete/auto_component.js +1 -0
  12. data/app/components/primer/auto_complete/item.rb +42 -0
  13. data/app/components/primer/avatar_stack_component.rb +2 -0
  14. data/app/components/primer/base_button.rb +47 -0
  15. data/app/components/primer/base_component.rb +115 -85
  16. data/app/components/primer/button_component.rb +37 -32
  17. data/app/components/primer/button_component.rb.orig +138 -0
  18. data/app/components/primer/{button_group_component.html.erb → button_group.html.erb} +0 -0
  19. data/app/components/primer/button_group.rb +61 -0
  20. data/app/components/primer/button_marketing_component.rb +15 -20
  21. data/app/components/primer/clipboard_copy.html.erb +8 -0
  22. data/app/components/primer/clipboard_copy.rb +26 -0
  23. data/app/components/primer/clipboard_copy_component.d.ts +1 -0
  24. data/app/components/primer/clipboard_copy_component.js +25 -0
  25. data/app/components/primer/clipboard_copy_component.ts +28 -0
  26. data/app/components/primer/close_button.rb +37 -0
  27. data/app/components/primer/component.rb +1 -0
  28. data/app/components/primer/dropdown_component.rb +1 -1
  29. data/app/components/primer/dropdown_menu_component.rb +1 -1
  30. data/app/components/primer/flash_component.rb +10 -10
  31. data/app/components/primer/foo_bar.d.ts +1 -0
  32. data/app/components/primer/foo_bar.js +1 -0
  33. data/app/components/primer/heading_component.rb +32 -4
  34. data/app/components/primer/hidden_text_expander.rb +41 -0
  35. data/app/components/primer/link_component.rb +9 -9
  36. data/app/components/primer/navigation/tab_component.html.erb +9 -7
  37. data/app/components/primer/navigation/tab_component.rb +27 -3
  38. data/app/components/primer/octicon_component.rb +0 -4
  39. data/app/components/primer/primer.d.ts +2 -1
  40. data/app/components/primer/primer.js +2 -1
  41. data/app/components/primer/primer.ts +2 -1
  42. data/app/components/primer/state_component.rb +14 -14
  43. data/app/components/primer/subhead_component.rb +1 -1
  44. data/app/components/primer/tab_nav_component.html.erb +2 -2
  45. data/app/components/primer/tab_nav_component.rb +22 -8
  46. data/app/components/primer/{truncate_component.rb → truncate.rb} +8 -6
  47. data/app/components/primer/underline_nav_component.rb +46 -14
  48. data/app/lib/primer/classify.rb +4 -13
  49. data/app/lib/primer/classify/cache.rb +14 -4
  50. data/app/lib/primer/classify/spacing.rb +63 -0
  51. data/app/lib/primer/tabbed_component_helper.rb +4 -0
  52. data/lib/primer/view_components/version.rb +1 -1
  53. data/static/statuses.json +1 -1
  54. metadata +116 -32
  55. data/app/assets/javascripts/primer_view_components.js.map.orig +0 -5
  56. data/app/assets/javascripts/primer_view_components.js.orig +0 -6
  57. data/app/components/primer/auto_complete_item_component.rb +0 -38
  58. data/app/components/primer/button_group_component.rb +0 -35
@@ -0,0 +1,28 @@
1
+ import '@github/clipboard-copy-element'
2
+
3
+ function toggleSVG(svg: SVGElement) {
4
+ if (svg.style.display === '' || svg.style.display === 'block') {
5
+ svg.style.display = 'none'
6
+ } else {
7
+ svg.style.display = 'block'
8
+ }
9
+ }
10
+
11
+ // Toggle a copy button.
12
+ function toggleCopyButton(button: HTMLElement) {
13
+ const [clippyIcon, checkIcon] = button.querySelectorAll<SVGElement>('.octicon')
14
+
15
+ if (clippyIcon) {
16
+ toggleSVG(clippyIcon)
17
+ }
18
+ if (checkIcon) {
19
+ toggleSVG(checkIcon)
20
+ }
21
+ }
22
+
23
+ document.addEventListener('clipboard-copy', function ({target}) {
24
+ if (!(target instanceof HTMLElement)) return
25
+ toggleCopyButton(target)
26
+
27
+ setTimeout(toggleCopyButton, 2000, target)
28
+ })
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # Use CloseButton to render an `×` without default button styles.
5
+ #
6
+ # @accessibility
7
+ # CloseButton has a default `aria-label` of "Close" to provides assistive technologies with an accessible label.
8
+ # You may choose to override this label with something more descriptive via [system_arguments][0].
9
+ # [0]: https://primer.style/view-components/system-arguments#html-attributes
10
+ class CloseButton < Primer::Component
11
+ DEFAULT_TYPE = :button
12
+ TYPE_OPTIONS = [DEFAULT_TYPE, :submit].freeze
13
+
14
+ # @example Default
15
+ # <%= render(Primer::CloseButton.new) %>
16
+ #
17
+ # @param type [Symbol] <%= one_of(Primer::CloseButton::TYPE_OPTIONS) %>
18
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
19
+ def initialize(type: DEFAULT_TYPE, **system_arguments)
20
+ @system_arguments = system_arguments
21
+ @system_arguments[:tag] = :button
22
+ @system_arguments[:block] = false
23
+ @system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
24
+ @system_arguments[:classes] = class_names(
25
+ "close-button",
26
+ system_arguments[:classes]
27
+ )
28
+ @system_arguments[:"aria-label"] ||= "Close"
29
+ end
30
+
31
+ def call
32
+ render(Primer::BaseButton.new(**@system_arguments)) do
33
+ render(Primer::OcticonComponent.new("x"))
34
+ end
35
+ end
36
+ end
37
+ end
@@ -10,6 +10,7 @@ module Primer
10
10
  include ClassNameHelper
11
11
  include FetchOrFallbackHelper
12
12
  include OcticonsHelper
13
+ include TestSelectorHelper
13
14
  include JoinStyleArgumentsHelper
14
15
  include ViewHelper
15
16
  include Status::Dsl
@@ -11,7 +11,7 @@ module Primer
11
11
  # Required context menu for the dropdown
12
12
  #
13
13
  # @param direction [Symbol] <%= one_of(Primer::Dropdown::MenuComponent::DIRECTION_OPTIONS) %>
14
- # @param scheme [Symbol] Pass :dark for dark mode theming
14
+ # @param scheme [Symbol] Pass `:dark` for dark mode theming
15
15
  # @param header [String] Optional string to display as the header
16
16
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
17
17
  renders_one :menu, Primer::Dropdown::MenuComponent
@@ -36,7 +36,7 @@ module Primer
36
36
  # </div>
37
37
  #
38
38
  # @param direction [Symbol] <%= one_of(Primer::DropdownMenuComponent::DIRECTION_OPTIONS) %>
39
- # @param scheme [Symbol] Pass :dark for dark mode theming
39
+ # @param scheme [Symbol] Pass `:dark` for dark mode theming
40
40
  # @param header [String] Optional string to display as the header
41
41
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
42
42
  def initialize(direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments)
@@ -15,18 +15,18 @@ module Primer
15
15
  Primer::BaseComponent.new(**system_arguments)
16
16
  }
17
17
 
18
- DEFAULT_VARIANT = :default
19
- VARIANT_MAPPINGS = {
20
- DEFAULT_VARIANT => "",
18
+ DEFAULT_SCHEME = :default
19
+ SCHEME_MAPPINGS = {
20
+ DEFAULT_SCHEME => "",
21
21
  :warning => "flash-warn",
22
22
  :danger => "flash-error",
23
23
  :success => "flash-success"
24
24
  }.freeze
25
- # @example Variants
25
+ # @example Schemes
26
26
  # <%= render(Primer::FlashComponent.new) { "This is a flash message!" } %>
27
- # <%= render(Primer::FlashComponent.new(variant: :warning)) { "This is a warning flash message!" } %>
28
- # <%= render(Primer::FlashComponent.new(variant: :danger)) { "This is a danger flash message!" } %>
29
- # <%= render(Primer::FlashComponent.new(variant: :success)) { "This is a success flash message!" } %>
27
+ # <%= render(Primer::FlashComponent.new(scheme: :warning)) { "This is a warning flash message!" } %>
28
+ # <%= render(Primer::FlashComponent.new(scheme: :danger)) { "This is a danger flash message!" } %>
29
+ # <%= render(Primer::FlashComponent.new(scheme: :success)) { "This is a success flash message!" } %>
30
30
  #
31
31
  # @example Full width
32
32
  # <%= render(Primer::FlashComponent.new(full: true)) { "This is a full width flash message!" } %>
@@ -49,9 +49,9 @@ module Primer
49
49
  # @param spacious [Boolean] Whether to add margin to the bottom of the component.
50
50
  # @param dismissible [Boolean] Whether the component can be dismissed with an X button.
51
51
  # @param icon [String] Name of Octicon icon to use.
52
- # @param variant [Symbol] <%= one_of(Primer::FlashComponent::VARIANT_MAPPINGS.keys) %>
52
+ # @param scheme [Symbol] <%= one_of(Primer::FlashComponent::SCHEME_MAPPINGS.keys) %>
53
53
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
54
- def initialize(full: false, spacious: false, dismissible: false, icon: nil, variant: DEFAULT_VARIANT, **system_arguments)
54
+ def initialize(full: false, spacious: false, dismissible: false, icon: nil, scheme: DEFAULT_SCHEME, **system_arguments)
55
55
  @icon = icon
56
56
  @dismissible = dismissible
57
57
  @system_arguments = system_arguments
@@ -59,7 +59,7 @@ module Primer
59
59
  @system_arguments[:classes] = class_names(
60
60
  @system_arguments[:classes],
61
61
  "flash",
62
- VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_MAPPINGS.keys, variant, DEFAULT_VARIANT)],
62
+ SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)],
63
63
  "flash-full": full
64
64
  )
65
65
  @system_arguments[:mb] ||= spacious ? 4 : nil
@@ -0,0 +1 @@
1
+ import '@github/details-menu-element';
@@ -0,0 +1 @@
1
+ import '@github/details-menu-element';
@@ -1,19 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use the Heading component to wrap a component that will create a heading element
4
+ # Heading can be used to communicate page organization and hierarchy.
5
+ #
6
+ # - Set tag to one of `:h1`, `:h2`, `:h3`, `:h4`, `:h5`, `:h6` based on what is
7
+ # appropriate for the page context.
8
+ # - Use Heading as the title of a section or sub section.
9
+ # - Do not use Heading for styling alone. To style text without conveying heading semantics,
10
+ # consider using <%= link_to_component(Primer::TextComponent) %> with relevant <%= link_to_typography_docs %>.
11
+ # - Do not jump heading levels. For instance, do not follow a `<h1>` with an `<h3>`. Heading levels should
12
+ # increase by one in ascending order.
13
+ #
14
+ # @accessibility
15
+ # Headings convey semantic meaning. Assistive technology users rely on headings to quickly navigate and scan information on a page.
16
+ # Inappropriate use of headings can lead to a confusing experience.
17
+ # [Learn more about best heading practices (WAI Headings)](https://www.w3.org/WAI/tutorials/page-structure/headings/)
5
18
  class HeadingComponent < Primer::Component
6
19
  status :beta
7
20
 
21
+ TAG_FALLBACK = :h2
22
+ TAG_OPTIONS = [:h1, TAG_FALLBACK, :h3, :h4, :h5, :h6].freeze
23
+
8
24
  # @example Default
9
- # <%= render(Primer::HeadingComponent.new) { "H1 Text" } %>
25
+ # <%= render(Primer::HeadingComponent.new(tag: :h1)) { "H1 Text" } %>
10
26
  # <%= render(Primer::HeadingComponent.new(tag: :h2)) { "H2 Text" } %>
11
27
  # <%= render(Primer::HeadingComponent.new(tag: :h3)) { "H3 Text" } %>
28
+ # <%= render(Primer::HeadingComponent.new(tag: :h4)) { "H4 Text" } %>
29
+ # <%= render(Primer::HeadingComponent.new(tag: :h5)) { "H5 Text" } %>
30
+ # <%= render(Primer::HeadingComponent.new(tag: :h6)) { "H6 Text" } %>
31
+ #
32
+ # @example With `font_size`
33
+ # <%= render(Primer::HeadingComponent.new(tag: :h1, font_size: 6)) { "h1 tag, font_size 6" } %>
34
+ # <%= render(Primer::HeadingComponent.new(tag: :h2, font_size: 3)) { "h2 tag, font_size 3" } %>
35
+ # <%= render(Primer::HeadingComponent.new(tag: :h3, font_size: 2)) { "h3 tag, font_size 2" } %>
36
+ # <%= render(Primer::HeadingComponent.new(tag: :h4, font_size: 0)) { "h4 tag, font_size 0" } %>
37
+ # <%= render(Primer::HeadingComponent.new(tag: :h5, font_size: 1)) { "h5 tag, font_size 1" } %>
38
+ # <%= render(Primer::HeadingComponent.new(tag: :h6, font_size: 4)) { "h6 tag, font_size 4" } %>
12
39
  #
40
+ # @param tag [String] <%= one_of(Primer::HeadingComponent::TAG_OPTIONS) %>
13
41
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
14
- def initialize(**system_arguments)
42
+ def initialize(tag:, **system_arguments)
15
43
  @system_arguments = system_arguments
16
- @system_arguments[:tag] ||= :h1
44
+ @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, TAG_FALLBACK)
17
45
  end
18
46
 
19
47
  def call
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # Use HiddenTextExpander to indicate and toggle hidden text.
5
+ class HiddenTextExpander < Primer::Component
6
+ # @example Default
7
+ # <%= render(Primer::HiddenTextExpander.new) %>
8
+ #
9
+ # @example Inline
10
+ # <%= render(Primer::HiddenTextExpander.new(inline: true)) %>
11
+ #
12
+ # @example Styling the button
13
+ # <%= render(Primer::HiddenTextExpander.new(button_arguments: { p: 1, classes: "my-custom-class" })) %>
14
+ #
15
+ # @param inline [Boolean] Whether or not the expander is inline.
16
+ # @param button_arguments [Hash] <%= link_to_system_arguments_docs %> for the button element.
17
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
18
+ def initialize(inline: false, button_arguments: {}, **system_arguments)
19
+ @system_arguments = system_arguments
20
+ @system_arguments[:tag] ||= :span
21
+ @system_arguments[:classes] = class_names(
22
+ "hidden-text-expander",
23
+ @system_arguments[:classes],
24
+ "inline" => inline
25
+ )
26
+
27
+ @button_arguments = button_arguments
28
+ @button_arguments[:"aria-expanded"] = false
29
+ @button_arguments[:classes] = class_names(
30
+ "ellipsis-expander",
31
+ button_arguments[:classes]
32
+ )
33
+ end
34
+
35
+ def call
36
+ render(Primer::BaseComponent.new(**@system_arguments)) do
37
+ render(Primer::BaseButton.new(**@button_arguments)) { "&hellip;" }
38
+ end
39
+ end
40
+ end
41
+ end
@@ -5,9 +5,9 @@ module Primer
5
5
  class LinkComponent < Primer::Component
6
6
  status :beta
7
7
 
8
- DEFAULT_VARIANT = :default
9
- VARIANT_MAPPINGS = {
10
- DEFAULT_VARIANT => "",
8
+ DEFAULT_SCHEME = :default
9
+ SCHEME_MAPPINGS = {
10
+ DEFAULT_SCHEME => "",
11
11
  :primary => "Link--primary",
12
12
  :secondary => "Link--secondary"
13
13
  }.freeze
@@ -21,9 +21,9 @@ module Primer
21
21
  # @example Muted
22
22
  # <%= render(Primer::LinkComponent.new(href: "#", muted: true)) { "Link" } %>
23
23
  #
24
- # @example Variants
25
- # <%= render(Primer::LinkComponent.new(href: "#", variant: :primary)) { "Primary" } %>
26
- # <%= render(Primer::LinkComponent.new(href: "#", variant: :secondary)) { "Secondary" } %>
24
+ # @example Schemes
25
+ # <%= render(Primer::LinkComponent.new(href: "#", scheme: :primary)) { "Primary" } %>
26
+ # <%= render(Primer::LinkComponent.new(href: "#", scheme: :secondary)) { "Secondary" } %>
27
27
  #
28
28
  # @example Without underline
29
29
  # <%= render(Primer::LinkComponent.new(href: "#", underline: false)) { "Link" } %>
@@ -33,17 +33,17 @@ module Primer
33
33
  #
34
34
  # @param tag [String] <%= one_of(Primer::LinkComponent::TAG_OPTIONS) %>
35
35
  # @param href [String] URL to be used for the Link. Required if tag is `:a`. If the requirements are not met an error will be raised in non production environments. In production, an empty link element will be rendered.
36
- # @param variant [Symbol] <%= one_of(Primer::LinkComponent::VARIANT_MAPPINGS.keys) %>
36
+ # @param scheme [Symbol] <%= one_of(Primer::LinkComponent::SCHEME_MAPPINGS.keys) %>
37
37
  # @param muted [Boolean] Uses light gray for Link color, and blue on hover.
38
38
  # @param underline [Boolean] Whether or not to underline the link.
39
39
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
40
- def initialize(href: nil, tag: DEFAULT_TAG, variant: DEFAULT_VARIANT, muted: false, underline: true, **system_arguments)
40
+ def initialize(href: nil, tag: DEFAULT_TAG, scheme: DEFAULT_SCHEME, muted: false, underline: true, **system_arguments)
41
41
  @system_arguments = system_arguments
42
42
  @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
43
43
  @system_arguments[:href] = href
44
44
  @system_arguments[:classes] = class_names(
45
45
  @system_arguments[:classes],
46
- VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_MAPPINGS.keys, variant, DEFAULT_VARIANT)],
46
+ SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)],
47
47
  "Link" => tag == :span,
48
48
  "Link--muted" => muted,
49
49
  "no-underline" => !underline
@@ -1,9 +1,11 @@
1
- <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
- <%= icon %>
3
- <% if text.present? %>
4
- <%= text %>
5
- <% else %>
6
- <%= content %>
1
+ <%= wrapper do %>
2
+ <%= render Primer::BaseComponent.new(**@system_arguments) do %>
3
+ <%= icon %>
4
+ <% if text.present? %>
5
+ <%= text %>
6
+ <% else %>
7
+ <%= content %>
8
+ <% end %>
9
+ <%= counter %>
7
10
  <% end %>
8
- <%= counter %>
9
11
  <% end %>
@@ -65,30 +65,43 @@ module Primer
65
65
  # <% c.counter(count: 10) %>
66
66
  # <% end %>
67
67
  #
68
+ # @example Inside a list
69
+ # <%= render(Primer::Navigation::TabComponent.new(list: true)) do |c| %>
70
+ # <% c.text { "Tab" } %>
71
+ # <% end %>
72
+ #
68
73
  # @example With custom HTML
69
- # <%= render(Primer::Navigation::TabComponent.new) do |c| %>
74
+ # <%= render(Primer::Navigation::TabComponent.new) do %>
70
75
  # <div>
71
76
  # This is my <strong>custom HTML</strong>
72
77
  # </div>
73
78
  # <% end %>
74
79
  #
80
+ # @param list [Boolean] Whether the Tab is an item in a `<ul>` list.
75
81
  # @param selected [Boolean] Whether the Tab is selected or not.
76
82
  # @param with_panel [Boolean] Whether the Tab has an associated panel.
77
83
  # @param icon_classes [Boolean] Classes that must always be applied to icons.
84
+ # @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> to be used in the `<li>` wrapper when the tab is an item in a list.
78
85
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
79
- def initialize(selected: false, with_panel: false, icon_classes: "", **system_arguments)
86
+ def initialize(list: false, selected: false, with_panel: false, icon_classes: "", wrapper_arguments: {}, **system_arguments)
80
87
  @selected = selected
81
88
  @icon_classes = icon_classes
89
+ @list = list
90
+
82
91
  @system_arguments = system_arguments
83
- @system_arguments[:role] = :tab
84
92
 
85
93
  if with_panel
86
94
  @system_arguments[:tag] ||= :button
87
95
  @system_arguments[:type] = :button
96
+ @system_arguments[:role] = :tab
88
97
  else
89
98
  @system_arguments[:tag] ||= :a
90
99
  end
91
100
 
101
+ @wrapper_arguments = wrapper_arguments
102
+ @wrapper_arguments[:tag] = :li
103
+ @wrapper_arguments[:display] ||= :flex
104
+
92
105
  return unless @selected
93
106
 
94
107
  if @system_arguments[:tag] == :a
@@ -97,6 +110,17 @@ module Primer
97
110
  @system_arguments[:"aria-selected"] = true
98
111
  end
99
112
  end
113
+
114
+ def wrapper
115
+ unless @list
116
+ yield
117
+ return # returning `yield` caused a double render
118
+ end
119
+
120
+ render(Primer::BaseComponent.new(**@wrapper_arguments)) do
121
+ yield
122
+ end
123
+ end
100
124
  end
101
125
  end
102
126
  end
@@ -5,10 +5,6 @@ module Primer
5
5
  class OcticonComponent < Primer::Component
6
6
  status :beta
7
7
 
8
- include ClassNameHelper
9
- include TestSelectorHelper
10
- include OcticonsHelper
11
-
12
8
  SIZE_DEFAULT = :small
13
9
  SIZE_MAPPINGS = {
14
10
  SIZE_DEFAULT => 16,
@@ -1,3 +1,4 @@
1
- import './auto_complete_component';
1
+ import './auto_complete/auto_complete';
2
+ import './clipboard_copy_component';
2
3
  import './tab_container_component';
3
4
  import './time_ago_component';
@@ -1,3 +1,4 @@
1
- import './auto_complete_component';
1
+ import './auto_complete/auto_complete';
2
+ import './clipboard_copy_component';
2
3
  import './tab_container_component';
3
4
  import './time_ago_component';
@@ -1,3 +1,4 @@
1
- import './auto_complete_component'
1
+ import './auto_complete/auto_complete'
2
+ import './clipboard_copy_component'
2
3
  import './tab_container_component'
3
4
  import './time_ago_component'
@@ -5,21 +5,21 @@ module Primer
5
5
  class StateComponent < Primer::Component
6
6
  status :beta
7
7
 
8
- COLOR_DEFAULT = :default
9
- NEW_COLOR_MAPPINGS = {
8
+ SCHEME_DEFAULT = :default
9
+ NEW_SCHEME_MAPPINGS = {
10
10
  open: "State--open",
11
11
  closed: "State--closed",
12
12
  merged: "State--merged"
13
13
  }.freeze
14
14
 
15
- DEPRECATED_COLOR_MAPPINGS = {
16
- COLOR_DEFAULT => "",
15
+ DEPRECATED_SCHEME_MAPPINGS = {
16
+ SCHEME_DEFAULT => "",
17
17
  :green => "State--open",
18
18
  :red => "State--closed",
19
19
  :purple => "State--merged"
20
20
  }.freeze
21
- COLOR_MAPPINGS = NEW_COLOR_MAPPINGS.merge(DEPRECATED_COLOR_MAPPINGS)
22
- COLOR_OPTIONS = COLOR_MAPPINGS.keys
21
+ SCHEME_MAPPINGS = NEW_SCHEME_MAPPINGS.merge(DEPRECATED_SCHEME_MAPPINGS)
22
+ SCHEME_OPTIONS = SCHEME_MAPPINGS.keys
23
23
 
24
24
  SIZE_DEFAULT = :default
25
25
  SIZE_MAPPINGS = {
@@ -29,29 +29,29 @@ module Primer
29
29
  SIZE_OPTIONS = SIZE_MAPPINGS.keys
30
30
 
31
31
  TAG_DEFAULT = :span
32
- TAG_OPTIONS = [TAG_DEFAULT, :div, :a].freeze
32
+ TAG_OPTIONS = [TAG_DEFAULT, :div].freeze
33
33
 
34
34
  # @example Default
35
35
  # <%= render(Primer::StateComponent.new(title: "title")) { "State" } %>
36
36
  #
37
- # @example Colors
37
+ # @example Schemes
38
38
  # <%= render(Primer::StateComponent.new(title: "title")) { "Default" } %>
39
- # <%= render(Primer::StateComponent.new(title: "title", color: :open)) { "Open" } %>
40
- # <%= render(Primer::StateComponent.new(title: "title", color: :closed)) { "Closed" } %>
41
- # <%= render(Primer::StateComponent.new(title: "title", color: :merged)) { "Merged" } %>
39
+ # <%= render(Primer::StateComponent.new(title: "title", scheme: :open)) { "Open" } %>
40
+ # <%= render(Primer::StateComponent.new(title: "title", scheme: :closed)) { "Closed" } %>
41
+ # <%= render(Primer::StateComponent.new(title: "title", scheme: :merged)) { "Merged" } %>
42
42
  #
43
43
  # @example Sizes
44
44
  # <%= render(Primer::StateComponent.new(title: "title")) { "Default" } %>
45
45
  # <%= render(Primer::StateComponent.new(title: "title", size: :small)) { "Small" } %>
46
46
  #
47
47
  # @param title [String] `title` HTML attribute.
48
- # @param color [Symbol] Background color. <%= one_of(Primer::StateComponent::COLOR_OPTIONS) %>
48
+ # @param scheme [Symbol] Background color. <%= one_of(Primer::StateComponent::SCHEME_OPTIONS) %>
49
49
  # @param tag [Symbol] HTML tag for element. <%= one_of(Primer::StateComponent::TAG_OPTIONS) %>
50
50
  # @param size [Symbol] <%= one_of(Primer::StateComponent::SIZE_OPTIONS) %>
51
51
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
52
52
  def initialize(
53
53
  title:,
54
- color: COLOR_DEFAULT,
54
+ scheme: SCHEME_DEFAULT,
55
55
  tag: TAG_DEFAULT,
56
56
  size: SIZE_DEFAULT,
57
57
  **system_arguments
@@ -62,7 +62,7 @@ module Primer
62
62
  @system_arguments[:classes] = class_names(
63
63
  @system_arguments[:classes],
64
64
  "State",
65
- COLOR_MAPPINGS[fetch_or_fallback(COLOR_OPTIONS, color, COLOR_DEFAULT)],
65
+ SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, SCHEME_DEFAULT)],
66
66
  SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
67
67
  )
68
68
  end