primer_view_components 0.0.112 → 0.0.114

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -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/assets/styles/primer_view_components.css +3 -1
  6. data/app/assets/styles/primer_view_components.css.map +1 -1
  7. data/app/components/primer/alpha/action_list.css +1 -1
  8. data/app/components/primer/alpha/action_list.css.json +1 -1
  9. data/app/components/primer/alpha/action_list.css.map +1 -1
  10. data/app/components/primer/alpha/action_list.pcss +0 -15
  11. data/app/components/primer/alpha/auto_complete.css +1 -1
  12. data/app/components/primer/alpha/auto_complete.css.map +1 -1
  13. data/app/components/primer/alpha/auto_complete.pcss +1 -1
  14. data/app/components/primer/alpha/banner.css +1 -1
  15. data/app/components/primer/alpha/banner.css.map +1 -1
  16. data/app/components/primer/alpha/banner.pcss +2 -2
  17. data/app/components/primer/alpha/dialog/body.rb +3 -0
  18. data/app/components/primer/alpha/dialog/footer.rb +3 -0
  19. data/app/components/primer/alpha/dialog/header.rb +3 -0
  20. data/app/components/primer/alpha/dialog.css +1 -0
  21. data/app/components/primer/alpha/dialog.css.json +1 -0
  22. data/app/components/primer/alpha/dialog.css.map +1 -0
  23. data/app/components/primer/alpha/dialog.pcss +484 -0
  24. data/app/components/primer/alpha/dialog.rb +3 -0
  25. data/app/components/primer/alpha/segmented_control.css +1 -1
  26. data/app/components/primer/alpha/segmented_control.css.map +1 -1
  27. data/app/components/primer/alpha/text_field.css +3 -0
  28. data/app/components/primer/alpha/text_field.css.json +1 -0
  29. data/app/components/primer/alpha/text_field.css.map +1 -0
  30. data/app/components/primer/alpha/text_field.pcss +683 -0
  31. data/app/components/primer/alpha/toggle_switch.d.ts +1 -1
  32. data/app/components/primer/alpha/toggle_switch.js +7 -4
  33. data/app/components/primer/alpha/toggle_switch.ts +7 -3
  34. data/app/components/primer/{clipboard_copy.d.ts → beta/clipboard_copy.d.ts} +0 -0
  35. data/app/components/primer/{clipboard_copy.html.erb → beta/clipboard_copy.html.erb} +0 -0
  36. data/app/components/primer/{clipboard_copy.js → beta/clipboard_copy.js} +0 -0
  37. data/app/components/primer/beta/clipboard_copy.rb +50 -0
  38. data/app/components/primer/{clipboard_copy.ts → beta/clipboard_copy.ts} +0 -0
  39. data/app/components/primer/beta/markdown.rb +290 -0
  40. data/app/components/primer/beta/popover.css.map +1 -1
  41. data/app/components/primer/beta/popover.pcss +5 -5
  42. data/app/components/primer/beta/relative_time.rb +160 -0
  43. data/app/components/primer/button_component.rb +1 -1
  44. data/app/components/primer/clipboard_copy.rb +2 -43
  45. data/app/components/primer/component.rb +4 -0
  46. data/app/components/primer/local_time.d.ts +1 -1
  47. data/app/components/primer/local_time.js +1 -1
  48. data/app/components/primer/local_time.rb +3 -1
  49. data/app/components/primer/local_time.ts +1 -1
  50. data/app/components/primer/markdown.rb +2 -283
  51. data/app/components/primer/primer.d.ts +1 -1
  52. data/app/components/primer/primer.js +1 -1
  53. data/app/components/primer/primer.pcss +8 -0
  54. data/app/components/primer/primer.ts +1 -1
  55. data/app/components/primer/time_ago_component.d.ts +1 -1
  56. data/app/components/primer/time_ago_component.js +1 -1
  57. data/app/components/primer/time_ago_component.rb +2 -1
  58. data/app/components/primer/time_ago_component.ts +1 -1
  59. data/app/forms/submit_button_form.rb +8 -2
  60. data/app/helpers/primer/form_helper.rb +12 -0
  61. data/lib/postcss_mixins/clearfix.pcss +12 -0
  62. data/lib/primer/deprecations.rb +96 -26
  63. data/lib/primer/deprecations.yml +72 -0
  64. data/lib/primer/forms/base.rb +7 -20
  65. data/lib/primer/forms/base_component.rb +15 -1
  66. data/lib/primer/forms/button.html.erb +4 -0
  67. data/lib/primer/forms/button.rb +68 -0
  68. data/lib/primer/forms/check_box.html.erb +2 -2
  69. data/lib/primer/forms/check_box.rb +1 -1
  70. data/lib/primer/forms/check_box_group.html.erb +2 -2
  71. data/lib/primer/forms/dsl/button_input.rb +29 -0
  72. data/lib/primer/forms/dsl/input_methods.rb +7 -2
  73. data/lib/primer/forms/dsl/submit_button_input.rb +1 -0
  74. data/lib/primer/forms/dsl/text_field_input.rb +0 -7
  75. data/lib/primer/forms/radio_button.html.erb +2 -2
  76. data/lib/primer/forms/radio_button.rb +1 -1
  77. data/lib/primer/forms/radio_button_group.html.erb +2 -2
  78. data/lib/primer/forms/select_list.html.erb +1 -1
  79. data/lib/primer/forms/select_list.rb +4 -1
  80. data/lib/primer/forms/submit_button.html.erb +1 -4
  81. data/lib/primer/forms/submit_button.rb +1 -37
  82. data/lib/primer/forms/text_area.html.erb +1 -1
  83. data/lib/primer/forms/text_area.rb +5 -1
  84. data/lib/primer/forms/text_field.html.erb +1 -1
  85. data/lib/primer/forms/text_field.rb +11 -0
  86. data/lib/primer/forms/utils.rb +28 -0
  87. data/lib/primer/view_components/audited.rb +14 -0
  88. data/lib/primer/view_components/engine.rb +1 -0
  89. data/lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb +2 -2
  90. data/lib/primer/view_components/linters/helpers/deprecated_components_helpers.rb +3 -18
  91. data/lib/primer/view_components/version.rb +1 -1
  92. data/lib/rubocop/cop/primer/component_name_migration.rb +2 -2
  93. data/lib/tasks/docs.rake +4 -3
  94. data/previews/primer/alpha/auto_complete_preview.rb +12 -0
  95. data/previews/primer/alpha/segmented_control_preview.rb +9 -6
  96. data/previews/primer/alpha/text_field_preview.rb +77 -52
  97. data/previews/primer/beta/clipboard_copy_preview/element.html.erb +2 -0
  98. data/previews/primer/beta/clipboard_copy_preview.rb +39 -0
  99. data/previews/primer/{markdown_preview.rb → beta/markdown_preview.rb} +14 -12
  100. data/previews/primer/beta/relative_time_preview.rb +271 -0
  101. data/previews/primer/forms/forms_preview.rb +1 -0
  102. data/static/arguments.json +163 -53
  103. data/static/audited_at.json +7 -4
  104. data/static/constants.json +132 -6
  105. data/static/statuses.json +6 -3
  106. metadata +28 -9
  107. data/previews/primer/clipboard_copy_preview/element.html.erb +0 -2
  108. data/previews/primer/clipboard_copy_preview.rb +0 -37
@@ -1,48 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use `ClipboardCopy` to copy element text content or input values to the clipboard.
5
- #
6
- # @accessibility
7
- # Always set an accessible label to help the user interact with the component.
8
- class ClipboardCopy < Primer::Component
9
- status :beta
10
-
11
- # @example Default
12
- # <%= render(Primer::ClipboardCopy.new(value: "Text to copy", "aria-label": "Copy text to the system clipboard")) %>
13
- #
14
- # @example With text instead of icons
15
- # <%= render(Primer::ClipboardCopy.new(value: "Text to copy")) do %>
16
- # Click to copy!
17
- # <% end %>
18
- #
19
- # @example Copying from an element
20
- # <%= render(Primer::ClipboardCopy.new(for: "blob-path", "aria-label": "Copy text to the system clipboard")) %>
21
- # <div id="blob-path">src/index.js</div>
22
- #
23
- # @param aria-label [String] String that will be read to screenreaders when the component is focused
24
- # @param value [String] Text to copy into the users clipboard when they click the component.
25
- # @param for [String] Element id from where to get the copied value.
26
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
27
- def initialize(value: nil, **system_arguments)
28
- @system_arguments = deny_tag_argument(**system_arguments)
29
- @value = value
30
-
31
- validate!
32
-
33
- @system_arguments[:tag] = "clipboard-copy"
34
- @system_arguments[:value] = value if value.present?
35
- end
36
-
37
- # :nodoc:
38
- def before_render
39
- validate_aria_label if content.blank?
40
- end
41
-
42
- private
43
-
44
- def validate!
45
- raise ArgumentError, "Must provide either `value` or `for`" if @value.nil? && @system_arguments[:for].nil?
46
- end
4
+ class ClipboardCopy < Primer::Beta::ClipboardCopy
5
+ status :deprecated
47
6
  end
48
7
  end
@@ -18,6 +18,10 @@ module Primer
18
18
 
19
19
  INVALID_ARIA_LABEL_TAGS = [:div, :span, :p].freeze
20
20
 
21
+ def self.deprecated?
22
+ status == :deprecated
23
+ end
24
+
21
25
  private
22
26
 
23
27
  def raise_on_invalid_options?
@@ -1 +1 @@
1
- import '@github/time-elements';
1
+ import '@github/relative-time-element';
@@ -1 +1 @@
1
- import '@github/time-elements';
1
+ import '@github/relative-time-element';
@@ -37,7 +37,9 @@ module Primer
37
37
 
38
38
  @datetime = datetime
39
39
 
40
- @system_arguments[:tag] = "local-time"
40
+ @system_arguments[:tag] = "relative-time"
41
+ @system_arguments[:threshold] = "PT0S"
42
+ @system_arguments[:prefix] = ""
41
43
  @system_arguments[:datetime] = datetime
42
44
 
43
45
  @initial_text = initial_text
@@ -1 +1 @@
1
- import '@github/time-elements'
1
+ import '@github/relative-time-element'
@@ -1,288 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use `Markdown` to wrap markdown content.
5
- class Markdown < Primer::Component
6
- status :beta
7
-
8
- DEFAULT_TAG = :div
9
- TAG_OPTIONS = [DEFAULT_TAG, :article, :td].freeze
10
- # @example Default
11
- # <%= render(Primer::Markdown.new) do %>
12
- # <p>Text can be <b>bold</b>, <i>italic</i>, or <s>strikethrough</s>. <a href="https://github.com">Links </a> should be blue with no underlines (unless hovered over).</p>
13
- #
14
- # <p>There should be whitespace between paragraphs. There should be whitespace between paragraphs. There should be whitespace between paragraphs. There should be whitespace between paragraphs.</p>
15
- #
16
- # <p>There should be whitespace between paragraphs. There should be whitespace between paragraphs. There should be whitespace between paragraphs. There should be whitespace between paragraphs.</p>
17
- #
18
- # <blockquote>
19
- # <p>There should be no margin above this first sentence.</p>
20
- # <p>Blockquotes should be a lighter gray with a gray border along the left side.</p>
21
- # <p>There should be no margin below this final sentence.</p>
22
- # </blockquote>
23
- #
24
- # <h1>Header 1</h1>
25
- #
26
- # <p>This is a normal paragraph following a header. Bacon ipsum dolor sit amet t-bone doner shank drumstick, pork belly porchetta chuck sausage brisket ham hock rump pig. Chuck kielbasa leberkas, pork bresaola ham hock filet mignon cow shoulder short ribs biltong.</p>
27
- #
28
- # <h2>Header 2</h2>
29
- #
30
- # <blockquote>This is a blockquote following a header. Bacon ipsum dolor sit amet t-bone doner shank drumstick, pork belly porchetta chuck sausage brisket ham hock rump pig. Chuck kielbasa leberkas, pork bresaola ham hock filet mignon cow shoulder short ribs biltong.</blockquote>
31
- #
32
- # <h3>Header 3</h3>
33
- #
34
- # <pre><code>This is a code block following a header.</code></pre>
35
- #
36
- # <h4>Header 4</h4>
37
- #
38
- # <ul>
39
- # <li>This is an unordered list following a header.</li>
40
- # <li>This is an unordered list following a header.</li>
41
- # <li>This is an unordered list following a header.</li>
42
- # </ul>
43
- #
44
- # <h5>Header 5</h5>
45
- #
46
- # <ol>
47
- # <li>This is an ordered list following a header.</li>
48
- # <li>This is an ordered list following a header.</li>
49
- # <li>This is an ordered list following a header.</li>
50
- # </ol>
51
- #
52
- # <h6>Header 6</h6>
53
- #
54
- # <table>
55
- # <thead>
56
- # <tr>
57
- # <th>What</th>
58
- # <th>Follows</th>
59
- # </tr>
60
- # </thead>
61
- # <tbody>
62
- # <tr>
63
- # <td>A table</td>
64
- # <td>A header</td>
65
- # </tr>
66
- # <tr>
67
- # <td>A table</td>
68
- # <td>A header</td>
69
- # </tr>
70
- # <tr>
71
- # <td>A table</td>
72
- # <td>A header</td>
73
- # </tr>
74
- # </tbody>
75
- # </table>
76
- #
77
- # <hr />
78
- #
79
- # <p>There's a horizontal rule above and below this.</p>
80
- #
81
- # <hr />
82
- #
83
- # <p>Here is an unordered list:</p>
84
- #
85
- # <ul>
86
- # <li>Salt-n-Pepa</li>
87
- # <li>Bel Biv DeVoe</li>
88
- # <li>Kid 'N Play</li>
89
- # </ul>
90
- #
91
- # <p>And an ordered list:</p>
92
- #
93
- # <ol>
94
- # <li>Michael Jackson</li>
95
- # <li>Michael Bolton</li>
96
- # <li>Michael Bublé</li>
97
- # </ol>
98
- #
99
- # <p>And an unordered task list:</p>
100
- #
101
- # <ul>
102
- # <li><input type="checkbox" id="create-markdown" checked /><label for="create-markdown">Create a sample markdown document</label><br></li>
103
- # <li><input type="checkbox" id="tasks-list" checked /><label for="tasks-list">Add tasks list to it</label><br></li>
104
- # <li><input type="checkbox" id="take-vacation" checked /><label for="take-vacation">Take a vacation</label><br></li>
105
- # </ul>
106
- #
107
- # <p>And a "mixed" task list:</p>
108
- #
109
- # <ul>
110
- # <li><input type="checkbox"id="steal-underpants"/><label for="steal-underpants">Steal underpants</label></li>
111
- # <li>?</li>
112
- # <li><input type="checkbox"id="profit"/><label for="profit">Profit!</label></li>
113
- # </ul>
114
- #
115
- # And a nested list:
116
- #
117
- # <ul>
118
- # <li>Jackson 5
119
- # <ul>
120
- # <li>Michael</li>
121
- # <li>Tito</li>
122
- # <li>Jackie</li>
123
- # <li>Marlon</li>
124
- # <li>Jermaine</li>
125
- # </ul>
126
- # </li>
127
- # <li>TMNT
128
- # <ul>
129
- # <li>Leonardo</li>
130
- # <li>Michelangelo</li>
131
- # <li>Donatello</li>
132
- # <li>Raphael</li>
133
- # </ul>
134
- # </li>
135
- # </ul>
136
- #
137
- # <p>Definition lists can be used with HTML syntax. Definition terms are bold and italic.</p>
138
- #
139
- # <dl>
140
- # <dt>Name</dt>
141
- # <dd>Godzilla</dd>
142
- # <dt>Born</dt>
143
- # <dd>1952</dd>
144
- # <dt>Birthplace</dt>
145
- # <dd>Japan</dd>
146
- # <dt>Color</dt>
147
- # <dd>Green</dd>
148
- # </dl>
149
- #
150
- # <hr />
151
- #
152
- # <p>Tables should have bold headings and alternating shaded rows.</p>
153
- #
154
- # <table>
155
- # <thead>
156
- # <tr>
157
- # <th>Artist</th>
158
- # <th>Album</th>
159
- # <th>Year</th>
160
- # </tr>
161
- # </thead>
162
- # <tbody>
163
- # <tr>
164
- # <td>David Bowie</td>
165
- # <td>Scary Monsters</td>
166
- # <td>1980</td>
167
- # </tr>
168
- # <tr>
169
- # <td>Prince</td>
170
- # <td>Purple Rain</td>
171
- # <td>1982</td>
172
- # </tr>
173
- # <tr>
174
- # <td>Beastie Boys</td>
175
- # <td>License to Ill</td>
176
- # <td>1986</td>
177
- # </tr>
178
- # <tr>
179
- # <td>Janet Jackson</td>
180
- # <td>Rhythm Nation 1814</td>
181
- # <td>1989</td>
182
- # </tr>
183
- # </tbody>
184
- # </table>
185
- #
186
- # <p>If a table is too wide, it should condense down and/or scroll horizontally.</p>
187
- #
188
- # <table>
189
- # <thead>
190
- # <tr>
191
- # <th>Artist</th>
192
- # <th>Album</th>
193
- # <th>Year</th>
194
- # <th>Label</th>
195
- # <th>Songs</th>
196
- # </tr>
197
- # </thead>
198
- # <tbody>
199
- # <tr>
200
- # <td>David Bowie</td>
201
- # <td>Scary Monsters</td>
202
- # <td>1980</td>
203
- # <td>RCA Records</td>
204
- # <td>It's No Game (No. 1), Up the Hill Backwards, Scary Monsters (And Super Creeps), Ashes to Ashes, Fashion, Teenage Wildlife, Scream Like a Baby, Kingdom Come, Because You're Young, It's No Game (No. 2)</td>
205
- # </tr>
206
- # <tr>
207
- # <td>Prince</td>
208
- # <td>Purple Rain</td>
209
- # <td>1982</td>
210
- # <td>Warner Brothers Records</td>
211
- # <td>Let's Go Crazy, Take Me With U, The Beautiful Ones, Computer Blue, Darling Nikki, When Doves Cry, I Would Die 4 U, Baby I'm a Star, Purple Rain</td>
212
- # </tr>
213
- # <tr>
214
- # <td>Beastie Boys</td>
215
- # <td>License to Ill</td>
216
- # <td>1986</td>
217
- # <td>Def Jam</td>
218
- # <td>Rhymin &amp; Stealin, The New Style, She's Crafty, Posse in Effect, Slow Ride, Girls, Fight for Your Right, No Sleep till Brooklyn, Paul Revere, "Hold It Now, Hit It", Brass Monkey, Slow and Low, Time to Get Ill</td>
219
- # </tr>
220
- # <tr>
221
- # <td>Janet Jackson</td>
222
- # <td>Rhythm Nation 1814</td>
223
- # <td>1989</td>
224
- # <td>A&amp;M</td>
225
- # <td>Interlude: Pledge, Rhythm Nation, Interlude: T.V., State of the World, Interlude: Race, The Knowledge, Interlude: Let's Dance, Miss You Much, Interlude: Come Back, Love Will Never Do (Without You), Livin' in a World (They Didn't Make), Alright, Interlude: Hey Baby, Escapade, Interlude: No Acid, Black Cat, Lonely, Come Back to Me, Someday Is Tonight, Interlude: Livin'...In Complete Darkness</td>
226
- # </tr>
227
- # </tbody>
228
- # </table>
229
- #
230
- # <hr />
231
- #
232
- # <p>Code snippets like <code>var foo = "bar";</code> can be shown inline.</p>
233
- #
234
- # <p>Also, <code>this should vertically align</code> <s><code>with this</code></s> <s>and this</s>.</p>
235
- #
236
- # <p>Code can also be shown in a block element.</p>
237
- #
238
- # <pre><code>var foo = "bar";</code></pre>
239
- #
240
- # <p>Code can also use syntax highlighting.</p>
241
- #
242
- # <pre><code>var foo = "bar";</code></pre>
243
- #
244
- # <pre tabindex="0"><code>Long, single-line code blocks should not wrap. They should horizontally scroll if they are too long. This line should be long enough to demonstrate this.</code></pre>
245
- #
246
- # <pre tabindex="0"><code>var foo = "The same thing is true for code with syntax highlighting. A single line of code should horizontally scroll if it is really long.";</code></pre>
247
- #
248
- # <p>Inline code inside table cells should still be distinguishable.</p>
249
- #
250
- # <table>
251
- # <thead>
252
- # <tr>
253
- # <th>Language</th>
254
- # <th>Code</th>
255
- # </tr>
256
- # </thead>
257
- # <tbody>
258
- # <tr>
259
- # <td>JavasScript</td>
260
- # <td><code>var foo = "bar";</code></td>
261
- # </tr>
262
- # <tr>
263
- # <td>Ruby</td>
264
- # <td><code>foo = "bar"</code></td>
265
- # </tr>
266
- # </tbody>
267
- # </table>
268
- #
269
- # <pre><code>This is the final element on the page and there should be no margin below this.</code></pre>
270
- # <% end %>
271
- #
272
- # @param tag [Symbol] <%= one_of(Primer::Markdown::TAG_OPTIONS) %>
273
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
274
- def initialize(tag: DEFAULT_TAG, **system_arguments)
275
- @system_arguments = system_arguments
276
- @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
277
-
278
- @system_arguments[:classes] = class_names(
279
- "markdown-body",
280
- system_arguments[:classes]
281
- )
282
- end
283
-
284
- def call
285
- render(Primer::BaseComponent.new(**@system_arguments)) { content }
286
- end
4
+ class Markdown < Primer::Beta::Markdown
5
+ status :deprecated
287
6
  end
288
7
  end
@@ -7,7 +7,7 @@ import './alpha/toggle_switch';
7
7
  import './alpha/tool_tip';
8
8
  import './alpha/x_banner';
9
9
  import './beta/auto_complete/auto_complete';
10
- import './clipboard_copy';
10
+ import './beta/clipboard_copy';
11
11
  import './local_time';
12
12
  import './tab_container_component';
13
13
  import './time_ago_component';
@@ -7,7 +7,7 @@ import './alpha/toggle_switch';
7
7
  import './alpha/tool_tip';
8
8
  import './alpha/x_banner';
9
9
  import './beta/auto_complete/auto_complete';
10
- import './clipboard_copy';
10
+ import './beta/clipboard_copy';
11
11
  import './local_time';
12
12
  import './tab_container_component';
13
13
  import './time_ago_component';
@@ -1,13 +1,19 @@
1
1
  /* CSS component styles here */
2
+
3
+ /* alpha */
2
4
  @import "./alpha/action_list.pcss";
3
5
  @import "./alpha/auto_complete.pcss";
4
6
  @import "./alpha/banner.pcss";
7
+ @import "./alpha/dialog.pcss";
5
8
  @import "./alpha/dropdown.pcss";
6
9
  @import "./alpha/tab_nav.pcss";
10
+ @import "./alpha/text_field.pcss";
7
11
  @import "./alpha/button_marketing.pcss";
8
12
  @import "./alpha/toggle_switch.pcss";
9
13
  @import "./alpha/underline_nav.pcss";
10
14
  @import "./alpha/segmented_control.pcss";
15
+
16
+ /* beta */
11
17
  @import "./beta/avatar.pcss";
12
18
  @import "./beta/avatar_stack.pcss";
13
19
  @import "./beta/border_box.pcss";
@@ -21,6 +27,8 @@
21
27
  @import "./beta/popover.pcss";
22
28
  @import "./beta/progress_bar.pcss";
23
29
  @import "./beta/truncate.pcss";
30
+
31
+ /* to be renamed */
24
32
  @import "./menu_component.pcss";
25
33
  @import "./state_component.pcss";
26
34
  @import "./subhead_component.pcss";
@@ -7,7 +7,7 @@ import './alpha/toggle_switch'
7
7
  import './alpha/tool_tip'
8
8
  import './alpha/x_banner'
9
9
  import './beta/auto_complete/auto_complete'
10
- import './clipboard_copy'
10
+ import './beta/clipboard_copy'
11
11
  import './local_time'
12
12
  import './tab_container_component'
13
13
  import './time_ago_component'
@@ -1 +1 @@
1
- import '@github/time-elements';
1
+ import '@github/relative-time-element';
@@ -1 +1 @@
1
- import '@github/time-elements';
1
+ import '@github/relative-time-element';
@@ -15,7 +15,8 @@ module Primer
15
15
  @system_arguments = deny_tag_argument(**system_arguments)
16
16
  @system_arguments[:datetime] = time.utc.iso8601
17
17
  @system_arguments[:classes] = class_names("no-wrap", @system_arguments[:classes])
18
- @system_arguments[:tag] = "time-ago"
18
+ @system_arguments[:tag] = "relative-time"
19
+ @system_arguments[:tense] = "past"
19
20
  @system_arguments[:format] = "micro" if micro
20
21
  @time = time
21
22
  @micro = micro
@@ -1 +1 @@
1
- import '@github/time-elements'
1
+ import '@github/relative-time-element'
@@ -13,8 +13,14 @@ class SubmitButtonForm < ApplicationForm
13
13
  color: :success
14
14
  )
15
15
 
16
- my_form.submit(name: :submit, label: "Submit", scheme: :primary, mr: 3) do |c|
17
- c.with_leading_visual_icon(icon: :"check-circle")
16
+ my_form.group(layout: :horizontal) do |button_group|
17
+ button_group.submit(name: :submit, label: "Submit", scheme: :primary, mb: 3) do |c|
18
+ c.with_leading_visual_icon(icon: :"check-circle")
19
+ end
20
+
21
+ button_group.button(name: :button, label: "Click me", mb: 3) do |c|
22
+ c.with_leading_visual_icon(icon: :alert)
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -7,5 +7,17 @@ module Primer
7
7
  def primer_form_with(**kwargs, &block)
8
8
  form_with(**kwargs, skip_default_ids: false, builder: Primer::Forms::Builder, &block)
9
9
  end
10
+
11
+ def primer_fields_for(record_name, record_object = nil, options = {}, &block)
12
+ fields_for(
13
+ record_name,
14
+ record_object,
15
+ options.merge(
16
+ skip_default_ids: false,
17
+ builder: Primer::Forms::Builder
18
+ ),
19
+ &block
20
+ )
21
+ end
10
22
  end
11
23
  end
@@ -0,0 +1,12 @@
1
+ @define-mixin clearfix {
2
+ &::before {
3
+ display: table;
4
+ content: '';
5
+ }
6
+
7
+ &::after {
8
+ display: table;
9
+ clear: both;
10
+ content: '';
11
+ }
12
+ }
@@ -1,35 +1,105 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "yaml"
4
+
3
5
  module Primer
4
6
  # :nodoc:
5
- module Deprecations
6
- # If there is no alternative to suggest, set the value to nil
7
- DEPRECATED_COMPONENTS = {
8
- "Primer::LabelComponent" => "Primer::Beta::Label",
9
- "Primer::LinkComponent" => "Primer::Beta::Link",
10
- "Primer::Alpha::AutoComplete" => "Primer::Beta::AutoComplete",
11
- "Primer::Alpha::AutoComplete::Item" => "Primer::Beta::AutoComplete::Item",
12
- "Primer::BlankslateComponent" => "Primer::Beta::Blankslate",
13
- "Primer::BoxComponent" => "Primer::Box",
14
- "Primer::DropdownMenuComponent" => nil,
15
- "Primer::Dropdown" => "Primer::Alpha::Dropdown",
16
- "Primer::Dropdown::Menu" => "Primer::Alpha::Dropdown::Menu",
17
- "Primer::Dropdown::Menu::Item" => "Primer::Alpha::Dropdown::Menu::Item",
18
- "Primer::IconButton" => "Primer::Beta::IconButton",
19
- "Primer::Tooltip" => "Primer::Alpha::Tooltip",
20
- "Primer::PopoverComponent" => "Primer::Beta::Popover"
21
- }.freeze
22
-
23
- def self.deprecated?(name)
24
- DEPRECATED_COMPONENTS.key?(name)
25
- end
7
+ class Deprecations
8
+ class << self
9
+ def register(file_path)
10
+ data = YAML.load_file(file_path)
11
+ data["deprecations"].each do |dep|
12
+ register_deprecation(dep["component"], {
13
+ autocorrect: dep["autocorrect"],
14
+ guide: dep["guide"],
15
+ replacement: dep["replacement"]
16
+ })
17
+ end
18
+ end
26
19
 
27
- def self.suggested_component(name)
28
- DEPRECATED_COMPONENTS[name]
29
- end
20
+ def register_deprecation(component, options)
21
+ registered_deprecations[component] = {
22
+ autocorrect: options[:autocorrect],
23
+ guide: options[:guide],
24
+ replacement: options[:replacement]
25
+ }
26
+ end
27
+
28
+ def deprecated_components
29
+ registered_deprecations.keys.sort
30
+ end
31
+
32
+ def deprecated?(component_name)
33
+ # if the component is registered, it is deprecated
34
+ registered_deprecations.key?(component_name)
35
+ end
36
+
37
+ def replacement?(component_name)
38
+ !replacement(component_name).nil?
39
+ end
40
+
41
+ def replacement(component_name)
42
+ dep = registered_deprecations[component_name]
43
+ return nil if dep.nil?
44
+
45
+ dep[:replacement]
46
+ end
47
+
48
+ def correctable?(component_name)
49
+ dep = registered_deprecations[component_name]
50
+ return false if dep.nil?
51
+
52
+ dep[:autocorrect]
53
+ end
30
54
 
31
- def self.correctable?(name)
32
- !suggested_component(name).nil?
55
+ def guide?(component_name)
56
+ !guide(component_name).nil?
57
+ end
58
+
59
+ def guide(component_name)
60
+ dep = registered_deprecations[component_name]
61
+ return nil if dep.nil?
62
+
63
+ dep[:guide]
64
+ end
65
+
66
+ def deprecation_message(component_name)
67
+ return nil unless deprecated?(component_name)
68
+
69
+ msg = ["'#{component_name}' has been deprecated."]
70
+
71
+ # this nested structure is complex, because it has to
72
+ # match all of the valid scenarios for a component being
73
+ # replaceable, auto-correctable, and having a guide. for
74
+ # more information on what is and is not valid, see the
75
+ # documentation here: docs/contributors/deprecations.md
76
+
77
+ if replacement?(component_name) # has replacement
78
+ if correctable?(component_name) # is autocorrectable
79
+ msg << "Please update your code to use '#{replacement(component_name)}'"
80
+ msg << "or use rubocop's auto-correct option to do it for you."
81
+ msg << "See #{guide(component_name)} for more information." if guide?(component_name) # has a guide
82
+ elsif guide?(component_name) # not autocorrectable
83
+ msg << "See #{guide(component_name)} for information on replacing this component in your code." # has a guide
84
+ end
85
+ elsif !correctable?(component_name) # no replacement
86
+ if guide?(component_name) # has a guide
87
+ msg << "Unfortunately, there is no direct replacement."
88
+ msg << "See #{guide(component_name)} for available options to update your code."
89
+ end
90
+ end
91
+
92
+ msg.join(" ")
93
+ end
94
+
95
+ private
96
+
97
+ def registered_deprecations
98
+ @registered_deprecations ||= {}
99
+ end
33
100
  end
101
+
102
+ # auto-load PVC's deprecations
103
+ register(File.expand_path("deprecations.yml", __dir__))
34
104
  end
35
105
  end