primer_view_components 0.0.1 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +92 -2
  3. data/README.md +149 -0
  4. data/app/components/primer/avatar_component.rb +28 -0
  5. data/app/components/primer/base_component.rb +42 -0
  6. data/app/components/primer/blankslate_component.html.erb +27 -0
  7. data/app/components/primer/blankslate_component.rb +164 -0
  8. data/app/components/primer/border_box_component.html.erb +26 -0
  9. data/app/components/primer/border_box_component.rb +77 -0
  10. data/app/components/primer/box_component.rb +14 -0
  11. data/app/components/primer/breadcrumb_component.html.erb +8 -0
  12. data/app/components/primer/breadcrumb_component.rb +52 -0
  13. data/app/components/primer/button_component.rb +58 -0
  14. data/app/components/primer/component.rb +9 -0
  15. data/app/components/primer/counter_component.rb +85 -0
  16. data/app/components/primer/details_component.html.erb +8 -0
  17. data/app/components/primer/details_component.rb +63 -0
  18. data/app/components/primer/dropdown_menu_component.html.erb +8 -0
  19. data/app/components/primer/dropdown_menu_component.rb +28 -0
  20. data/app/components/primer/flex_component.rb +81 -0
  21. data/app/components/primer/flex_item_component.rb +21 -0
  22. data/app/components/primer/heading_component.rb +14 -0
  23. data/app/components/primer/label_component.rb +48 -0
  24. data/app/components/primer/layout_component.html.erb +17 -0
  25. data/app/components/primer/layout_component.rb +28 -0
  26. data/app/components/primer/link_component.rb +19 -0
  27. data/app/components/primer/popover_component.html.erb +10 -0
  28. data/app/components/primer/popover_component.rb +75 -0
  29. data/app/components/primer/progress_bar_component.html.erb +5 -0
  30. data/app/components/primer/progress_bar_component.rb +66 -0
  31. data/app/components/primer/slot.rb +8 -0
  32. data/app/components/primer/state_component.rb +53 -0
  33. data/app/components/primer/subhead_component.html.erb +17 -0
  34. data/app/components/primer/subhead_component.rb +89 -0
  35. data/app/components/primer/text_component.rb +14 -0
  36. data/app/components/primer/timeline_item_component.html.erb +17 -0
  37. data/app/components/primer/timeline_item_component.rb +69 -0
  38. data/app/components/primer/underline_nav_component.html.erb +11 -0
  39. data/app/components/primer/underline_nav_component.rb +22 -0
  40. data/app/components/primer/view_components.rb +48 -0
  41. data/lib/primer/class_name_helper.rb +27 -0
  42. data/lib/primer/classify.rb +245 -0
  43. data/lib/primer/fetch_or_fallback_helper.rb +41 -0
  44. data/lib/primer/view_components.rb +3 -0
  45. data/lib/primer/view_components/engine.rb +11 -0
  46. data/lib/primer/view_components/version.rb +1 -1
  47. metadata +203 -4
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Primer::FetchOrFallbackHelper
4
+ # A little helper to enable graceful fallbacks
5
+ #
6
+ # Use this helper to quietly ensure a value is
7
+ # one that you expect:
8
+ #
9
+ # allowed_values - allowed options for *value*
10
+ # given_value - input being coerced
11
+ # fallback - returned if *given_value* is not included in *allowed_values*
12
+ #
13
+ # fetch_or_fallback([1,2,3], 5, 2) => 2
14
+ # fetch_or_fallback([1,2,3], 1, 2) => 1
15
+ # fetch_or_fallback([1,2,3], nil, 2) => 2
16
+ module Primer
17
+ module FetchOrFallbackHelper
18
+ mattr_accessor :fallback_raises, default: true
19
+
20
+ InvalidValueError = Class.new(StandardError)
21
+
22
+ def fetch_or_fallback(allowed_values, given_value, fallback = nil)
23
+ if allowed_values.include?(given_value)
24
+ given_value
25
+ else
26
+ if fallback_raises && ENV["RAILS_ENV"] != "production" && ENV["STORYBOOK"] != "true"
27
+ raise InvalidValueError, <<~MSG
28
+ fetch_or_fallback was called with an invalid value.
29
+
30
+ Expected one of: #{allowed_values.inspect}
31
+ Got: #{given_value.inspect}
32
+
33
+ This will not raise in production, but will instead fallback to: #{fallback.inspect}
34
+ MSG
35
+ end
36
+
37
+ fallback
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "primer/view_components/version"
4
+ require "primer/view_components/engine"
2
5
 
3
6
  module Primer
4
7
  module ViewComponents
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module ViewComponents
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace Primer::ViewComponents
7
+ end
8
+ end
9
+ end
10
+
11
+ require "#{Primer::ViewComponents::Engine.root}/app/components/primer/view_components.rb"
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 1
8
+ PATCH = 7
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
metadata CHANGED
@@ -1,15 +1,173 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primer_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-03 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2020-09-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 5.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: view_component
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 2.0.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '3.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 2.0.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '3.0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: octicons_helper
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 9.0.0
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: 12.0.0
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 9.0.0
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: 12.0.0
73
+ - !ruby/object:Gem::Dependency
74
+ name: minitest
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '='
78
+ - !ruby/object:Gem::Version
79
+ version: 5.6.0
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '='
85
+ - !ruby/object:Gem::Version
86
+ version: 5.6.0
87
+ - !ruby/object:Gem::Dependency
88
+ name: pry
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ - !ruby/object:Gem::Dependency
102
+ name: rubocop
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - '='
106
+ - !ruby/object:Gem::Version
107
+ version: '0.74'
108
+ type: :development
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '='
113
+ - !ruby/object:Gem::Version
114
+ version: '0.74'
115
+ - !ruby/object:Gem::Dependency
116
+ name: rubocop-github
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: 0.13.0
122
+ type: :development
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - "~>"
127
+ - !ruby/object:Gem::Version
128
+ version: 0.13.0
129
+ - !ruby/object:Gem::Dependency
130
+ name: simplecov
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - "~>"
134
+ - !ruby/object:Gem::Version
135
+ version: 0.18.0
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - "~>"
141
+ - !ruby/object:Gem::Version
142
+ version: 0.18.0
143
+ - !ruby/object:Gem::Dependency
144
+ name: simplecov-console
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: 0.7.2
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - "~>"
155
+ - !ruby/object:Gem::Version
156
+ version: 0.7.2
157
+ - !ruby/object:Gem::Dependency
158
+ name: yard
159
+ requirement: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - "~>"
162
+ - !ruby/object:Gem::Version
163
+ version: 0.9.25
164
+ type: :development
165
+ prerelease: false
166
+ version_requirements: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - "~>"
169
+ - !ruby/object:Gem::Version
170
+ version: 0.9.25
13
171
  description:
14
172
  email:
15
173
  - opensource+primer_view_components@github.com
@@ -20,7 +178,48 @@ files:
20
178
  - CHANGELOG.md
21
179
  - LICENSE.txt
22
180
  - README.md
181
+ - app/components/primer/avatar_component.rb
182
+ - app/components/primer/base_component.rb
183
+ - app/components/primer/blankslate_component.html.erb
184
+ - app/components/primer/blankslate_component.rb
185
+ - app/components/primer/border_box_component.html.erb
186
+ - app/components/primer/border_box_component.rb
187
+ - app/components/primer/box_component.rb
188
+ - app/components/primer/breadcrumb_component.html.erb
189
+ - app/components/primer/breadcrumb_component.rb
190
+ - app/components/primer/button_component.rb
191
+ - app/components/primer/component.rb
192
+ - app/components/primer/counter_component.rb
193
+ - app/components/primer/details_component.html.erb
194
+ - app/components/primer/details_component.rb
195
+ - app/components/primer/dropdown_menu_component.html.erb
196
+ - app/components/primer/dropdown_menu_component.rb
197
+ - app/components/primer/flex_component.rb
198
+ - app/components/primer/flex_item_component.rb
199
+ - app/components/primer/heading_component.rb
200
+ - app/components/primer/label_component.rb
201
+ - app/components/primer/layout_component.html.erb
202
+ - app/components/primer/layout_component.rb
203
+ - app/components/primer/link_component.rb
204
+ - app/components/primer/popover_component.html.erb
205
+ - app/components/primer/popover_component.rb
206
+ - app/components/primer/progress_bar_component.html.erb
207
+ - app/components/primer/progress_bar_component.rb
208
+ - app/components/primer/slot.rb
209
+ - app/components/primer/state_component.rb
210
+ - app/components/primer/subhead_component.html.erb
211
+ - app/components/primer/subhead_component.rb
212
+ - app/components/primer/text_component.rb
213
+ - app/components/primer/timeline_item_component.html.erb
214
+ - app/components/primer/timeline_item_component.rb
215
+ - app/components/primer/underline_nav_component.html.erb
216
+ - app/components/primer/underline_nav_component.rb
217
+ - app/components/primer/view_components.rb
218
+ - lib/primer/class_name_helper.rb
219
+ - lib/primer/classify.rb
220
+ - lib/primer/fetch_or_fallback_helper.rb
23
221
  - lib/primer/view_components.rb
222
+ - lib/primer/view_components/engine.rb
24
223
  - lib/primer/view_components/version.rb
25
224
  homepage: https://github.com/primer/view_components
26
225
  licenses:
@@ -42,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
241
  - !ruby/object:Gem::Version
43
242
  version: '0'
44
243
  requirements: []
45
- rubygems_version: 3.0.3
244
+ rubygems_version: 3.1.2
46
245
  signing_key:
47
246
  specification_version: 4
48
247
  summary: ViewComponents for the Primer Design System