primer_view_components 0.0.119 → 0.0.121
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +60 -0
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/components/primer/alpha/modal_dialog.js +2 -0
- data/app/components/primer/alpha/modal_dialog.ts +2 -0
- data/app/components/primer/alpha/segmented_control/item.rb +1 -0
- data/app/components/primer/alpha/segmented_control.rb +30 -0
- data/app/components/primer/alpha/text_field.rb +1 -0
- data/app/components/primer/base_component.rb +3 -3
- data/app/components/primer/beta/close_button.rb +1 -1
- data/app/components/primer/{local_time.d.ts → beta/relative_time.d.ts} +0 -0
- data/app/components/primer/{local_time.js → beta/relative_time.js} +0 -0
- data/app/components/primer/{local_time.ts → beta/relative_time.ts} +0 -0
- data/app/components/primer/component.rb +2 -1
- data/app/components/primer/primer.d.ts +1 -2
- data/app/components/primer/primer.js +1 -2
- data/app/components/primer/primer.ts +1 -2
- data/app/forms/example_toggle_switch_form.rb +1 -1
- data/app/lib/primer/view_helper.rb +0 -1
- data/lib/primer/deprecations.yml +0 -91
- data/lib/primer/forms/acts_as_component.rb +12 -1
- data/lib/primer/forms/toggle_switch_form.rb +10 -3
- data/lib/primer/view_components/linters/button_component_migration_counter.rb +2 -2
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/primer/view_components.rb +5 -0
- data/lib/primer/yard/backend.rb +38 -0
- data/lib/primer/yard/component_manifest.rb +121 -0
- data/lib/primer/yard/docs_helper.rb +81 -0
- data/lib/primer/yard/legacy_gatsby_backend.rb +271 -0
- data/lib/primer/yard/registry.rb +146 -0
- data/lib/primer/yard/renders_many_handler.rb +23 -0
- data/lib/primer/yard/renders_one_handler.rb +23 -0
- data/lib/rubocop/config/default.yml +3 -0
- data/lib/rubocop/cop/primer/test_selector.rb +48 -0
- data/lib/tasks/docs.rake +37 -405
- data/lib/tasks/static.rake +22 -0
- data/previews/primer/alpha/auto_complete_preview.rb +6 -6
- data/previews/primer/alpha/dialog_preview/body_has_scrollbar_overflow.html.erb +9 -0
- data/previews/primer/alpha/dialog_preview.rb +15 -0
- data/previews/primer/alpha/segmented_control_preview/with_label_and_caption.html.erb +9 -0
- data/previews/primer/alpha/segmented_control_preview/with_subhead_actions.html.erb +11 -0
- data/previews/primer/alpha/segmented_control_preview.rb +7 -1
- data/previews/primer/alpha/text_field_preview.rb +14 -0
- data/previews/primer/alpha/toggle_switch_preview.rb +9 -9
- data/previews/primer/beta/auto_complete_preview.rb +17 -17
- data/previews/primer/url_helpers.rb +1 -1
- data/static/arguments.json +6 -132
- data/static/audited_at.json +2 -24
- data/static/constants.json +0 -71
- data/static/previews.json +1634 -0
- data/static/statuses.json +0 -22
- metadata +23 -40
- data/app/components/primer/box_component.rb +0 -7
- data/app/components/primer/clipboard_copy.rb +0 -7
- data/app/components/primer/dropdown/menu.rb +0 -14
- data/app/components/primer/dropdown.rb +0 -7
- data/app/components/primer/dropdown_menu_component.html.erb +0 -8
- data/app/components/primer/dropdown_menu_component.rb +0 -58
- data/app/components/primer/hellip_button.rb +0 -7
- data/app/components/primer/label_component.rb +0 -7
- data/app/components/primer/link_component.rb +0 -7
- data/app/components/primer/local_time.rb +0 -63
- data/app/components/primer/markdown.rb +0 -7
- data/app/components/primer/menu_component.rb +0 -7
- data/app/components/primer/octicon_component.rb +0 -7
- data/app/components/primer/octicon_symbols_component.rb +0 -7
- data/app/components/primer/popover_component.rb +0 -8
- data/app/components/primer/spinner_component.rb +0 -7
- data/app/components/primer/state_component.rb +0 -7
- data/app/components/primer/subhead_component.rb +0 -7
- data/app/components/primer/tab_container_component.rb +0 -7
- data/app/components/primer/time_ago_component.d.ts +0 -1
- data/app/components/primer/time_ago_component.js +0 -1
- data/app/components/primer/time_ago_component.rb +0 -51
- data/app/components/primer/time_ago_component.ts +0 -1
- data/app/components/primer/timeline_item_component.rb +0 -13
- data/lib/yard/docs_helper.rb +0 -79
- data/lib/yard/renders_many_handler.rb +0 -19
- data/lib/yard/renders_one_handler.rb +0 -19
- data/previews/primer/local_time_component_preview.rb +0 -57
- data/previews/primer/time_ago_component_preview.rb +0 -27
data/static/statuses.json
CHANGED
@@ -73,34 +73,12 @@
|
|
73
73
|
"Primer::Beta::Truncate::TruncateText": "alpha",
|
74
74
|
"Primer::BlankslateComponent": "deprecated",
|
75
75
|
"Primer::Box": "stable",
|
76
|
-
"Primer::BoxComponent": "deprecated",
|
77
76
|
"Primer::ButtonComponent": "deprecated",
|
78
|
-
"Primer::ClipboardCopy": "deprecated",
|
79
77
|
"Primer::ConditionalWrapper": "alpha",
|
80
78
|
"Primer::Content": "stable",
|
81
|
-
"Primer::Dropdown": "deprecated",
|
82
|
-
"Primer::Dropdown::Menu": "deprecated",
|
83
|
-
"Primer::Dropdown::Menu::Item": "deprecated",
|
84
|
-
"Primer::DropdownMenuComponent": "deprecated",
|
85
|
-
"Primer::HellipButton": "deprecated",
|
86
79
|
"Primer::IconButton": "deprecated",
|
87
|
-
"Primer::LabelComponent": "deprecated",
|
88
80
|
"Primer::LayoutComponent": "alpha",
|
89
|
-
"Primer::LinkComponent": "deprecated",
|
90
|
-
"Primer::LocalTime": "deprecated",
|
91
|
-
"Primer::Markdown": "deprecated",
|
92
|
-
"Primer::MenuComponent": "deprecated",
|
93
81
|
"Primer::Navigation::TabComponent": "alpha",
|
94
|
-
"Primer::OcticonComponent": "deprecated",
|
95
|
-
"Primer::OcticonSymbolsComponent": "deprecated",
|
96
|
-
"Primer::PopoverComponent": "deprecated",
|
97
|
-
"Primer::SpinnerComponent": "deprecated",
|
98
|
-
"Primer::StateComponent": "deprecated",
|
99
|
-
"Primer::SubheadComponent": "deprecated",
|
100
|
-
"Primer::TabContainerComponent": "deprecated",
|
101
|
-
"Primer::TimeAgoComponent": "deprecated",
|
102
|
-
"Primer::TimelineItemComponent": "deprecated",
|
103
|
-
"Primer::TimelineItemComponent::BadgeComponent": "deprecated",
|
104
82
|
"Primer::Tooltip": "deprecated",
|
105
83
|
"Primer::Truncate": "beta"
|
106
84
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: primer_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.121
|
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: 2023-
|
11
|
+
date: 2023-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -56,22 +56,22 @@ dependencies:
|
|
56
56
|
name: view_component
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: '2.0'
|
62
62
|
- - "<"
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: '
|
64
|
+
version: '4.0'
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- - "
|
69
|
+
- - ">"
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 2.
|
71
|
+
version: '2.0'
|
72
72
|
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '4.0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: allocation_stats
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -628,7 +628,10 @@ files:
|
|
628
628
|
- app/components/primer/beta/progress_bar.html.erb
|
629
629
|
- app/components/primer/beta/progress_bar.pcss
|
630
630
|
- app/components/primer/beta/progress_bar.rb
|
631
|
+
- app/components/primer/beta/relative_time.d.ts
|
632
|
+
- app/components/primer/beta/relative_time.js
|
631
633
|
- app/components/primer/beta/relative_time.rb
|
634
|
+
- app/components/primer/beta/relative_time.ts
|
632
635
|
- app/components/primer/beta/spinner.html.erb
|
633
636
|
- app/components/primer/beta/spinner.rb
|
634
637
|
- app/components/primer/beta/state.css
|
@@ -658,48 +661,21 @@ files:
|
|
658
661
|
- app/components/primer/blankslate_component.html.erb
|
659
662
|
- app/components/primer/blankslate_component.rb
|
660
663
|
- app/components/primer/box.rb
|
661
|
-
- app/components/primer/box_component.rb
|
662
664
|
- app/components/primer/button_component.html.erb
|
663
665
|
- app/components/primer/button_component.rb
|
664
|
-
- app/components/primer/clipboard_copy.rb
|
665
666
|
- app/components/primer/component.rb
|
666
667
|
- app/components/primer/conditional_wrapper.rb
|
667
668
|
- app/components/primer/content.rb
|
668
|
-
- app/components/primer/dropdown.rb
|
669
|
-
- app/components/primer/dropdown/menu.rb
|
670
|
-
- app/components/primer/dropdown_menu_component.html.erb
|
671
|
-
- app/components/primer/dropdown_menu_component.rb
|
672
|
-
- app/components/primer/hellip_button.rb
|
673
669
|
- app/components/primer/icon_button.html.erb
|
674
670
|
- app/components/primer/icon_button.rb
|
675
|
-
- app/components/primer/label_component.rb
|
676
671
|
- app/components/primer/layout_component.html.erb
|
677
672
|
- app/components/primer/layout_component.rb
|
678
|
-
- app/components/primer/link_component.rb
|
679
|
-
- app/components/primer/local_time.d.ts
|
680
|
-
- app/components/primer/local_time.js
|
681
|
-
- app/components/primer/local_time.rb
|
682
|
-
- app/components/primer/local_time.ts
|
683
|
-
- app/components/primer/markdown.rb
|
684
|
-
- app/components/primer/menu_component.rb
|
685
673
|
- app/components/primer/navigation/tab_component.html.erb
|
686
674
|
- app/components/primer/navigation/tab_component.rb
|
687
|
-
- app/components/primer/octicon_component.rb
|
688
|
-
- app/components/primer/octicon_symbols_component.rb
|
689
|
-
- app/components/primer/popover_component.rb
|
690
675
|
- app/components/primer/primer.d.ts
|
691
676
|
- app/components/primer/primer.js
|
692
677
|
- app/components/primer/primer.pcss
|
693
678
|
- app/components/primer/primer.ts
|
694
|
-
- app/components/primer/spinner_component.rb
|
695
|
-
- app/components/primer/state_component.rb
|
696
|
-
- app/components/primer/subhead_component.rb
|
697
|
-
- app/components/primer/tab_container_component.rb
|
698
|
-
- app/components/primer/time_ago_component.d.ts
|
699
|
-
- app/components/primer/time_ago_component.js
|
700
|
-
- app/components/primer/time_ago_component.rb
|
701
|
-
- app/components/primer/time_ago_component.ts
|
702
|
-
- app/components/primer/timeline_item_component.rb
|
703
679
|
- app/components/primer/tooltip.rb
|
704
680
|
- app/components/primer/truncate.css
|
705
681
|
- app/components/primer/truncate.css.json
|
@@ -877,6 +853,13 @@ files:
|
|
877
853
|
- lib/primer/view_components/linters/two_column_layout_migration_counter.rb
|
878
854
|
- lib/primer/view_components/statuses.rb
|
879
855
|
- lib/primer/view_components/version.rb
|
856
|
+
- lib/primer/yard/backend.rb
|
857
|
+
- lib/primer/yard/component_manifest.rb
|
858
|
+
- lib/primer/yard/docs_helper.rb
|
859
|
+
- lib/primer/yard/legacy_gatsby_backend.rb
|
860
|
+
- lib/primer/yard/registry.rb
|
861
|
+
- lib/primer/yard/renders_many_handler.rb
|
862
|
+
- lib/primer/yard/renders_one_handler.rb
|
880
863
|
- lib/rubocop/config/default.yml
|
881
864
|
- lib/rubocop/cop/primer.rb
|
882
865
|
- lib/rubocop/cop/primer/base_cop.rb
|
@@ -890,6 +873,7 @@ files:
|
|
890
873
|
- lib/rubocop/cop/primer/no_tag_memoize.rb
|
891
874
|
- lib/rubocop/cop/primer/primer_octicon.rb
|
892
875
|
- lib/rubocop/cop/primer/system_argument_instead_of_class.rb
|
876
|
+
- lib/rubocop/cop/primer/test_selector.rb
|
893
877
|
- lib/tasks/custom_utilities.yml
|
894
878
|
- lib/tasks/docs.rake
|
895
879
|
- lib/tasks/helpers/ast_processor.rb
|
@@ -898,9 +882,6 @@ files:
|
|
898
882
|
- lib/tasks/static.rake
|
899
883
|
- lib/tasks/test.rake
|
900
884
|
- lib/tasks/utilities.rake
|
901
|
-
- lib/yard/docs_helper.rb
|
902
|
-
- lib/yard/renders_many_handler.rb
|
903
|
-
- lib/yard/renders_one_handler.rb
|
904
885
|
- previews/primer/alpha/action_list_preview.rb
|
905
886
|
- previews/primer/alpha/action_list_preview/heading.html.erb
|
906
887
|
- previews/primer/alpha/auto_complete_preview.rb
|
@@ -909,6 +890,7 @@ files:
|
|
909
890
|
- previews/primer/alpha/banner_preview/with_action_content.html.erb
|
910
891
|
- previews/primer/alpha/button_marketing_preview.rb
|
911
892
|
- previews/primer/alpha/dialog_preview.rb
|
893
|
+
- previews/primer/alpha/dialog_preview/body_has_scrollbar_overflow.html.erb
|
912
894
|
- previews/primer/alpha/dialog_preview/custom_header.html.erb
|
913
895
|
- previews/primer/alpha/dialog_preview/nested_dialog.html.erb
|
914
896
|
- previews/primer/alpha/dialog_preview/test.html.erb
|
@@ -925,6 +907,8 @@ files:
|
|
925
907
|
- previews/primer/alpha/menu_preview/playground.html.erb
|
926
908
|
- previews/primer/alpha/nav_list_preview.rb
|
927
909
|
- previews/primer/alpha/segmented_control_preview.rb
|
910
|
+
- previews/primer/alpha/segmented_control_preview/with_label_and_caption.html.erb
|
911
|
+
- previews/primer/alpha/segmented_control_preview/with_subhead_actions.html.erb
|
928
912
|
- previews/primer/alpha/tab_nav_preview.rb
|
929
913
|
- previews/primer/alpha/tab_panels_preview.rb
|
930
914
|
- previews/primer/alpha/text_field_preview.rb
|
@@ -999,13 +983,12 @@ files:
|
|
999
983
|
- previews/primer/forms/forms_preview/submit_button_form.html.erb
|
1000
984
|
- previews/primer/forms/forms_preview/text_field_and_checkbox_form.html.erb
|
1001
985
|
- previews/primer/layout_component_preview.rb
|
1002
|
-
- previews/primer/local_time_component_preview.rb
|
1003
|
-
- previews/primer/time_ago_component_preview.rb
|
1004
986
|
- previews/primer/url_helpers.rb
|
1005
987
|
- static/arguments.json
|
1006
988
|
- static/assets/view-components.svg
|
1007
989
|
- static/audited_at.json
|
1008
990
|
- static/constants.json
|
991
|
+
- static/previews.json
|
1009
992
|
- static/statuses.json
|
1010
993
|
homepage: https://github.com/primer/view_components
|
1011
994
|
licenses:
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# DropdownMenus are lightweight context menus for housing navigation and actions.
|
5
|
-
# They're great for instances where you don't need the full power (and code)
|
6
|
-
# of the select menu.
|
7
|
-
class DropdownMenuComponent < Primer::Component
|
8
|
-
status :deprecated
|
9
|
-
|
10
|
-
SCHEME_DEFAULT = :default
|
11
|
-
SCHEME_MAPPINGS = {
|
12
|
-
SCHEME_DEFAULT => "",
|
13
|
-
:dark => "dropdown-menu-dark"
|
14
|
-
}.freeze
|
15
|
-
|
16
|
-
DIRECTION_DEFAULT = :se
|
17
|
-
DIRECTION_OPTIONS = [DIRECTION_DEFAULT, :sw, :w, :e, :ne, :s].freeze
|
18
|
-
|
19
|
-
# @example With a header
|
20
|
-
# <div>
|
21
|
-
# <%= render(Primer::Beta::Details.new(overlay: :default, reset: true, position: :relative)) do |component| %>
|
22
|
-
# <% component.with_summary do %>
|
23
|
-
# Dropdown
|
24
|
-
# <% end %>
|
25
|
-
#
|
26
|
-
# <% component.with_body do %>
|
27
|
-
# <%= render(Primer::DropdownMenuComponent.new(header: "Options")) do %>
|
28
|
-
# <ul>
|
29
|
-
# <li><a class="dropdown-item" href="#url">Dropdown item</a></li>
|
30
|
-
# <li><a class="dropdown-item" href="#url">Dropdown item</a></li>
|
31
|
-
# <li><a class="dropdown-item" href="#url">Dropdown item</a></li>
|
32
|
-
# </ul>
|
33
|
-
# <% end %>
|
34
|
-
# <% end %>
|
35
|
-
# <% end %>
|
36
|
-
# </div>
|
37
|
-
#
|
38
|
-
# @param direction [Symbol] <%= one_of(Primer::DropdownMenuComponent::DIRECTION_OPTIONS) %>
|
39
|
-
# @param scheme [Symbol] Pass `:dark` for dark mode theming
|
40
|
-
# @param header [String] Optional string to display as the header
|
41
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
42
|
-
def initialize(direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments)
|
43
|
-
@header = header
|
44
|
-
@direction = direction
|
45
|
-
@system_arguments = deny_tag_argument(**system_arguments)
|
46
|
-
|
47
|
-
@system_arguments[:tag] = "details-menu"
|
48
|
-
@system_arguments[:role] = "menu"
|
49
|
-
|
50
|
-
@system_arguments[:classes] = class_names(
|
51
|
-
@system_arguments[:classes],
|
52
|
-
"dropdown-menu",
|
53
|
-
"dropdown-menu-#{fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT)}",
|
54
|
-
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, SCHEME_DEFAULT)]
|
55
|
-
)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# Use `LocalTime` to format a date and time in the user's preferred locale format. This component requires JavaScript.
|
5
|
-
class LocalTime < Primer::Component
|
6
|
-
status :deprecated
|
7
|
-
|
8
|
-
DEFAULT_DIGIT_TYPE = :numeric
|
9
|
-
DIGIT_TYPE_OPTIONS = [DEFAULT_DIGIT_TYPE, :"2-digit"].freeze
|
10
|
-
|
11
|
-
DEFAULT_TEXT_TYPE = :short
|
12
|
-
TEXT_TYPE_OPTIONS = [DEFAULT_TEXT_TYPE, :long].freeze
|
13
|
-
|
14
|
-
# @example Default
|
15
|
-
# <%= render(Primer::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"))) %>
|
16
|
-
#
|
17
|
-
# @example All the options
|
18
|
-
# <%= render(Primer::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"), weekday: :long, year: :"2-digit", month: :long, day: :"2-digit", hour: :"2-digit", minute: :"2-digit", second: :"2-digit", time_zone_name: :long)) %>
|
19
|
-
#
|
20
|
-
# @example With initial content
|
21
|
-
# <%= render(Primer::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"))) do %>
|
22
|
-
# <!-- This content will be replaced once the component connects -->
|
23
|
-
# 2014/06/01 13:05
|
24
|
-
# <% end %>
|
25
|
-
#
|
26
|
-
# @param datetime [DateTime] The date to parse
|
27
|
-
# @param initial_text [String] Text to render before component is initialized
|
28
|
-
# @param weekday [Symbol] <%= one_of(Primer::LocalTime::TEXT_TYPE_OPTIONS) %>
|
29
|
-
# @param year [Symbol] <%= one_of(Primer::LocalTime::DIGIT_TYPE_OPTIONS) %>
|
30
|
-
# @param month [Symbol] <%= one_of(Primer::LocalTime::TEXT_TYPE_OPTIONS) %>
|
31
|
-
# @param day [Symbol] <%= one_of(Primer::LocalTime::DIGIT_TYPE_OPTIONS) %>
|
32
|
-
# @param hour [Symbol] <%= one_of(Primer::LocalTime::DIGIT_TYPE_OPTIONS) %>
|
33
|
-
# @param minute [Symbol] <%= one_of(Primer::LocalTime::DIGIT_TYPE_OPTIONS) %>
|
34
|
-
# @param second [Symbol] <%= one_of(Primer::LocalTime::DIGIT_TYPE_OPTIONS) %>
|
35
|
-
# @param time_zone_name [Symbol] <%= one_of(Primer::LocalTime::TEXT_TYPE_OPTIONS) %>
|
36
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
37
|
-
def initialize(datetime:, initial_text: nil, weekday: DEFAULT_TEXT_TYPE, year: DEFAULT_DIGIT_TYPE, month: DEFAULT_TEXT_TYPE, day: DEFAULT_DIGIT_TYPE, hour: DEFAULT_DIGIT_TYPE, minute: DEFAULT_DIGIT_TYPE, second: DEFAULT_DIGIT_TYPE, time_zone_name: DEFAULT_TEXT_TYPE, **system_arguments)
|
38
|
-
@system_arguments = deny_tag_argument(**system_arguments)
|
39
|
-
|
40
|
-
@datetime = datetime
|
41
|
-
|
42
|
-
@system_arguments[:tag] = "relative-time"
|
43
|
-
@system_arguments[:threshold] = "PT0S"
|
44
|
-
@system_arguments[:prefix] = ""
|
45
|
-
@system_arguments[:datetime] = datetime
|
46
|
-
|
47
|
-
@initial_text = initial_text
|
48
|
-
|
49
|
-
@system_arguments[:weekday] = fetch_or_fallback(TEXT_TYPE_OPTIONS, weekday, DEFAULT_TEXT_TYPE)
|
50
|
-
@system_arguments[:year] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, year, DEFAULT_DIGIT_TYPE)
|
51
|
-
@system_arguments[:month] = fetch_or_fallback(TEXT_TYPE_OPTIONS, month, DEFAULT_TEXT_TYPE)
|
52
|
-
@system_arguments[:day] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, day, DEFAULT_DIGIT_TYPE)
|
53
|
-
@system_arguments[:hour] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, hour, DEFAULT_DIGIT_TYPE)
|
54
|
-
@system_arguments[:minute] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, minute, DEFAULT_DIGIT_TYPE)
|
55
|
-
@system_arguments[:second] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, second, DEFAULT_DIGIT_TYPE)
|
56
|
-
@system_arguments[:"time-zone-name"] = fetch_or_fallback(TEXT_TYPE_OPTIONS, time_zone_name, DEFAULT_TEXT_TYPE)
|
57
|
-
end
|
58
|
-
|
59
|
-
def call
|
60
|
-
render(Primer::BaseComponent.new(**@system_arguments).with_content(@initial_text || @datetime.strftime("%B %-d, %Y %H:%M %Z")))
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
import '@github/relative-time-element';
|
@@ -1 +0,0 @@
|
|
1
|
-
import '@github/relative-time-element';
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# Use `TimeAgo` to display a time relative to how long ago it was. This component requires JavaScript.
|
5
|
-
class TimeAgoComponent < Primer::Component
|
6
|
-
status :deprecated
|
7
|
-
|
8
|
-
# @example Default
|
9
|
-
# <%= render(Primer::TimeAgoComponent.new(time: Time.at(628232400))) %>
|
10
|
-
#
|
11
|
-
# @param time [Time] The time to be formatted
|
12
|
-
# @param micro [Boolean] If true then the text will be formatted in "micro" mode, using as few characters as possible
|
13
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
14
|
-
def initialize(time:, micro: false, **system_arguments)
|
15
|
-
@system_arguments = deny_tag_argument(**system_arguments)
|
16
|
-
@system_arguments[:datetime] = time.utc.iso8601
|
17
|
-
@system_arguments[:classes] = class_names("no-wrap", @system_arguments[:classes])
|
18
|
-
@system_arguments[:tag] = "relative-time"
|
19
|
-
@system_arguments[:tense] = "past"
|
20
|
-
@system_arguments[:format] = "micro" if micro
|
21
|
-
@time = time
|
22
|
-
@micro = micro
|
23
|
-
end
|
24
|
-
|
25
|
-
def call
|
26
|
-
render(Primer::BaseComponent.new(**@system_arguments)) { time_in_words }
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def time_in_words
|
32
|
-
return @time.in_time_zone.strftime("%b %-d, %Y") unless @micro
|
33
|
-
|
34
|
-
seconds_ago = Time.current - @time
|
35
|
-
|
36
|
-
if seconds_ago < 1.minute
|
37
|
-
# :nocov:
|
38
|
-
"1m"
|
39
|
-
# :nocov:
|
40
|
-
elsif seconds_ago >= 1.minute && seconds_ago < 1.hour
|
41
|
-
"#{(seconds_ago / 60).floor}m"
|
42
|
-
elsif seconds_ago >= 1.hour && seconds_ago < 1.day
|
43
|
-
"#{(seconds_ago / 60 / 60).floor}h"
|
44
|
-
elsif seconds_ago >= 1.day && seconds_ago < 1.year
|
45
|
-
"#{(seconds_ago / 60 / 60 / 24).floor}d"
|
46
|
-
elsif seconds_ago >= 1.year
|
47
|
-
"#{(seconds_ago / 60 / 60 / 24 / 365).floor}y"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
import '@github/relative-time-element'
|
data/lib/yard/docs_helper.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# :nocov:
|
4
|
-
|
5
|
-
module YARD
|
6
|
-
# Helper methods to use for yard documentation
|
7
|
-
module DocsHelper
|
8
|
-
def one_of(enumerable, lower: false, sort: true)
|
9
|
-
# Sort the array if requested
|
10
|
-
if sort
|
11
|
-
enumerable = enumerable.sort do |a, b|
|
12
|
-
a.instance_of?(b.class) ? a <=> b : a.class.to_s <=> b.class.to_s
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
values =
|
17
|
-
case enumerable
|
18
|
-
when Hash
|
19
|
-
enumerable.map do |key, value|
|
20
|
-
"#{pretty_value(key)} (#{pretty_value(value)})"
|
21
|
-
end
|
22
|
-
else
|
23
|
-
enumerable.map do |key|
|
24
|
-
pretty_value(key)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
prefix = "One of"
|
29
|
-
prefix = prefix.downcase if lower
|
30
|
-
|
31
|
-
"#{prefix} #{values.to_sentence(two_words_connector: ' or ', last_word_connector: ', or ')}."
|
32
|
-
end
|
33
|
-
|
34
|
-
def link_to_accessibility
|
35
|
-
"[Accessibility](#accessibility)"
|
36
|
-
end
|
37
|
-
|
38
|
-
def link_to_system_arguments_docs
|
39
|
-
"[System arguments](/system-arguments)"
|
40
|
-
end
|
41
|
-
|
42
|
-
def link_to_typography_docs
|
43
|
-
"[Typography](/system-arguments#typography)"
|
44
|
-
end
|
45
|
-
|
46
|
-
def link_to_component(component)
|
47
|
-
status_module, short_name, class_name = status_module_and_short_name(component)
|
48
|
-
status_path = status_module.nil? ? "" : "#{status_module}/"
|
49
|
-
|
50
|
-
"[#{class_name}](/components/#{status_path}#{short_name.downcase})"
|
51
|
-
end
|
52
|
-
|
53
|
-
def link_to_octicons
|
54
|
-
"[Octicon](https://primer.style/octicons/)"
|
55
|
-
end
|
56
|
-
|
57
|
-
def link_to_heading_practices
|
58
|
-
"[Learn more about best heading practices (WAI Headings)](https://www.w3.org/WAI/tutorials/page-structure/headings/)"
|
59
|
-
end
|
60
|
-
|
61
|
-
def status_module_and_short_name(component)
|
62
|
-
name_with_status = component.name.gsub(/Primer::|Component/, "")
|
63
|
-
|
64
|
-
m = name_with_status.match(/(?<status>Beta|Alpha|Deprecated)?(?<_colons>::)?(?<name>.*)/)
|
65
|
-
[m[:status]&.downcase, m[:name].gsub("::", ""), m[:name]]
|
66
|
-
end
|
67
|
-
|
68
|
-
def pretty_value(val)
|
69
|
-
case val
|
70
|
-
when nil
|
71
|
-
"`nil`"
|
72
|
-
when Symbol
|
73
|
-
"`:#{val}`"
|
74
|
-
else
|
75
|
-
"`#{val}`"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module YARD
|
4
|
-
# YARD Handler to parse `renders_many` calls.
|
5
|
-
class RendersManyHandler < YARD::Handlers::Ruby::Base
|
6
|
-
handles method_call(:renders_many)
|
7
|
-
namespace_only
|
8
|
-
|
9
|
-
process do
|
10
|
-
name = statement.parameters.first.jump(:tstring_content, :ident).source
|
11
|
-
object = YARD::CodeObjects::MethodObject.new(namespace, name)
|
12
|
-
register(object)
|
13
|
-
parse_block(statement.last, owner: object)
|
14
|
-
|
15
|
-
object.dynamic = true
|
16
|
-
object[:renders_many] = true
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|