primer_view_components 0.0.38 → 0.0.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +65 -27
  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.rb +1 -1
  6. data/app/components/primer/auto_complete/item.rb +1 -1
  7. data/app/components/primer/avatar_component.rb +22 -3
  8. data/app/components/primer/avatar_stack_component.rb +1 -1
  9. data/app/components/primer/base_button.rb +1 -1
  10. data/app/components/primer/base_component.rb +7 -6
  11. data/app/components/primer/blankslate_component.rb +4 -1
  12. data/app/components/primer/border_box_component.rb +1 -1
  13. data/app/components/primer/box_component.rb +1 -1
  14. data/app/components/primer/breadcrumb_component.rb +1 -1
  15. data/app/components/primer/button_component.html.erb +9 -0
  16. data/app/components/primer/button_component.rb +39 -5
  17. data/app/components/primer/button_group.rb +1 -1
  18. data/app/components/primer/button_marketing_component.rb +1 -1
  19. data/app/components/primer/clipboard_copy.rb +1 -1
  20. data/app/components/primer/clipboard_copy_component.js +4 -6
  21. data/app/components/primer/clipboard_copy_component.ts +4 -6
  22. data/app/components/primer/close_button.rb +4 -2
  23. data/app/components/primer/component.rb +16 -2
  24. data/app/components/primer/counter_component.rb +1 -1
  25. data/app/components/primer/details_component.rb +1 -1
  26. data/app/components/primer/dropdown/menu_component.rb +1 -1
  27. data/app/components/primer/dropdown_component.rb +1 -1
  28. data/app/components/primer/flash_component.rb +1 -1
  29. data/app/components/primer/flex_component.rb +1 -1
  30. data/app/components/primer/flex_item_component.rb +20 -1
  31. data/app/components/primer/heading_component.rb +3 -3
  32. data/app/components/primer/hidden_text_expander.rb +1 -1
  33. data/app/components/primer/icon_button.rb +48 -0
  34. data/app/components/primer/label_component.rb +1 -1
  35. data/app/components/primer/layout_component.rb +1 -1
  36. data/app/components/primer/link_component.rb +1 -1
  37. data/app/components/primer/markdown_component.rb +1 -1
  38. data/app/components/primer/menu_component.rb +1 -1
  39. data/app/components/primer/octicon_component.rb +35 -10
  40. data/app/components/primer/popover_component.rb +1 -1
  41. data/app/components/primer/progress_bar_component.rb +1 -1
  42. data/app/components/primer/spinner_component.rb +1 -1
  43. data/app/components/primer/state_component.rb +1 -1
  44. data/app/components/primer/subhead_component.rb +1 -1
  45. data/app/components/primer/tab_container_component.rb +1 -1
  46. data/app/components/primer/tab_nav_component.rb +1 -1
  47. data/app/components/primer/text_component.rb +1 -1
  48. data/app/components/primer/time_ago_component.rb +1 -1
  49. data/app/components/primer/timeline_item_component.rb +1 -1
  50. data/app/components/primer/tooltip_component.rb +1 -1
  51. data/app/components/primer/truncate.rb +1 -1
  52. data/app/components/primer/underline_nav_component.rb +1 -1
  53. data/app/lib/primer/classify.rb +7 -32
  54. data/app/lib/primer/classify/cache.rb +19 -14
  55. data/app/lib/primer/classify/flex.rb +111 -0
  56. data/app/lib/primer/classify/functional_border_colors.rb +1 -2
  57. data/app/lib/primer/fetch_or_fallback_helper.rb +2 -2
  58. data/app/lib/primer/octicon/cache.rb +38 -0
  59. data/lib/primer/view_components/version.rb +1 -1
  60. data/static/statuses.json +1 -1
  61. metadata +7 -6
  62. data/app/components/primer/button_component.rb.orig +0 -138
  63. data/app/components/primer/foo_bar.d.ts +0 -1
  64. data/app/components/primer/foo_bar.js +0 -1
@@ -1,138 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Primer
4
- # Use buttons for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
5
- class ButtonComponent < Primer::Component
6
- status :beta
7
-
8
- DEFAULT_SCHEME = :default
9
- LINK_SCHEME = :link
10
- SCHEME_MAPPINGS = {
11
- DEFAULT_SCHEME => "",
12
- :primary => "btn-primary",
13
- :danger => "btn-danger",
14
- :outline => "btn-outline",
15
- :invisible => "btn-invisible",
16
- LINK_SCHEME => "btn-link"
17
- }.freeze
18
- SCHEME_OPTIONS = SCHEME_MAPPINGS.keys
19
-
20
- DEFAULT_VARIANT = :medium
21
- VARIANT_MAPPINGS = {
22
- :small => "btn-sm",
23
- DEFAULT_VARIANT => "",
24
- :large => "btn-large"
25
- }.freeze
26
- VARIANT_OPTIONS = VARIANT_MAPPINGS.keys
27
-
28
- <<<<<<< HEAD
29
- =======
30
- DEFAULT_TAG = :button
31
- TAG_OPTIONS = [DEFAULT_TAG, :a, :summary].freeze
32
-
33
- DEFAULT_TYPE = :button
34
- TYPE_OPTIONS = [DEFAULT_TYPE, :reset, :submit].freeze
35
-
36
- DEFAULT_ICON_ALIGN = :left
37
- ICON_ALIGN_OPTIONS = [DEFAULT_ICON_ALIGN, :right].freeze
38
-
39
- # Icon to be rendered in the button.
40
- #
41
- # @param align [Symbol] <%= one_of(Primer::ButtonComponent::ICON_ALIGN_OPTIONS) %>
42
- # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::OcticonComponent) %>.
43
- renders_one :icon, lambda { |align: DEFAULT_ICON_ALIGN, **system_arguments|
44
- @icon_align = fetch_or_fallback(ICON_ALIGN_OPTIONS, align, DEFAULT_ICON_ALIGN)
45
-
46
- Primer::OcticonComponent.new(**system_arguments)
47
- }
48
-
49
- # Counter to be rendered in the button.
50
- #
51
- # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::CounterComponent) %>.
52
- renders_one :counter, Primer::CounterComponent
53
-
54
- >>>>>>> 05bacd3 (add icon and counter slots to button)
55
- # @example Schemes
56
- # <%= render(Primer::ButtonComponent.new) { "Default" } %>
57
- # <%= render(Primer::ButtonComponent.new(scheme: :primary)) { "Primary" } %>
58
- # <%= render(Primer::ButtonComponent.new(scheme: :danger)) { "Danger" } %>
59
- # <%= render(Primer::ButtonComponent.new(scheme: :outline)) { "Outline" } %>
60
- # <%= render(Primer::ButtonComponent.new(scheme: :invisible)) { "Invisible" } %>
61
- # <%= render(Primer::ButtonComponent.new(scheme: :link)) { "Link" } %>
62
- #
63
- # @example Variants
64
- # <%= render(Primer::ButtonComponent.new(variant: :small)) { "Small" } %>
65
- # <%= render(Primer::ButtonComponent.new(variant: :medium)) { "Medium" } %>
66
- # <%= render(Primer::ButtonComponent.new(variant: :large)) { "Large" } %>
67
- #
68
- # @example Block
69
- # <%= render(Primer::ButtonComponent.new(block: :true)) { "Block" } %>
70
- # <%= render(Primer::ButtonComponent.new(block: :true, scheme: :primary)) { "Primary block" } %>
71
- #
72
- # @example With icons
73
- # <%= render(Primer::ButtonComponent.new) do |c| %>
74
- # <% c.icon(icon: :star) %>
75
- # Button
76
- # <% end %>
77
- # <%= render(Primer::ButtonComponent.new) do |c| %>
78
- # <% c.icon(icon: :star, align: :right) %>
79
- # Button
80
- # <% end %>
81
- #
82
- # @example With counter
83
- # <%= render(Primer::ButtonComponent.new) do |c| %>
84
- # <% c.counter(count: 15) %>
85
- # Button
86
- # <% end %>
87
- #
88
- # @example With icons and counter
89
- # <%= render(Primer::ButtonComponent.new) do |c| %>
90
- # <% c.icon(icon: :star) %>
91
- # <% c.counter(count: 15) %>
92
- # Button
93
- # <% end %>
94
- # <%= render(Primer::ButtonComponent.new) do |c| %>
95
- # <% c.icon(icon: :star, align: :right) %>
96
- # <% c.counter(count: 15) %>
97
- # Button
98
- # <% end %>
99
- #
100
- # @param scheme [Symbol] <%= one_of(Primer::ButtonComponent::SCHEME_OPTIONS) %>
101
- # @param variant [Symbol] <%= one_of(Primer::ButtonComponent::VARIANT_OPTIONS) %>
102
- # @param tag [Symbol] <%= one_of(Primer::BaseButton::TAG_OPTIONS) %>
103
- # @param type [Symbol] <%= one_of(Primer::BaseButton::TYPE_OPTIONS) %>
104
- # @param group_item [Boolean] Whether button is part of a ButtonGroup.
105
- # @param block [Boolean] Whether button is full-width with `display: block`.
106
- def initialize(
107
- scheme: DEFAULT_SCHEME,
108
- variant: DEFAULT_VARIANT,
109
- group_item: false,
110
- block: false,
111
- **system_arguments
112
- )
113
- @scheme = scheme
114
- @system_arguments = system_arguments
115
- @system_arguments[:classes] = class_names(
116
- system_arguments[:classes],
117
- SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)],
118
- VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)],
119
- "btn" => !link?,
120
- "btn-block" => block,
121
- "BtnGroup-item" => group_item
122
- )
123
- end
124
-
125
- <<<<<<< HEAD
126
- def call
127
- render(Primer::BaseButton.new(**@system_arguments)) { content }
128
- end
129
-
130
- =======
131
- >>>>>>> 05bacd3 (add icon and counter slots to button)
132
- private
133
-
134
- def link?
135
- @scheme == LINK_SCHEME
136
- end
137
- end
138
- end
@@ -1 +0,0 @@
1
- import '@github/details-menu-element';
@@ -1 +0,0 @@
1
- import '@github/details-menu-element';