primer_view_components 0.0.41 → 0.0.46
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +265 -1
- 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/button_marketing.rb +70 -0
- data/app/components/primer/auto_complete.rb +99 -42
- data/app/components/primer/auto_complete/auto_complete.html.erb +1 -0
- data/app/components/primer/avatar_stack_component.rb +7 -1
- data/app/components/primer/base_component.rb +62 -26
- data/app/components/primer/beta/text.rb +27 -0
- data/app/components/primer/blankslate_component.html.erb +1 -0
- data/app/components/primer/blankslate_component.rb +64 -45
- data/app/components/primer/border_box_component.rb +3 -0
- data/app/components/primer/button_component.rb +3 -2
- data/app/components/primer/button_group.rb +1 -1
- data/app/components/primer/clipboard_copy.rb +25 -7
- data/app/components/primer/component.rb +5 -1
- data/app/components/primer/details_component.rb +18 -3
- data/app/components/primer/dropdown.d.ts +1 -0
- data/app/components/primer/{dropdown_component.html.erb → dropdown.html.erb} +2 -1
- data/app/components/primer/dropdown.js +1 -0
- data/app/components/primer/dropdown.rb +149 -0
- data/app/components/primer/dropdown.ts +1 -0
- data/app/components/primer/dropdown/menu.d.ts +1 -0
- data/app/components/primer/dropdown/menu.html.erb +25 -0
- data/app/components/primer/dropdown/menu.js +1 -0
- data/app/components/primer/dropdown/menu.rb +99 -0
- data/app/components/primer/dropdown/menu.ts +1 -0
- data/app/components/primer/heading_component.rb +1 -1
- data/app/components/primer/hidden_text_expander.rb +2 -2
- data/app/components/primer/icon_button.rb +1 -1
- data/app/components/primer/image_crop.rb +2 -2
- data/app/components/primer/markdown.rb +6 -2
- data/app/components/primer/menu_component.rb +7 -3
- data/app/components/primer/navigation/tab_component.rb +6 -6
- data/app/components/primer/octicon_component.rb +4 -3
- data/app/components/primer/popover_component.rb +2 -2
- data/app/components/primer/primer.d.ts +1 -0
- data/app/components/primer/primer.js +1 -0
- data/app/components/primer/primer.ts +1 -0
- data/app/components/primer/spinner_component.rb +2 -0
- data/app/components/primer/tab_nav_component.html.erb +4 -2
- data/app/components/primer/tab_nav_component.rb +48 -6
- data/app/components/primer/tooltip.rb +1 -1
- data/app/components/primer/truncate.rb +6 -2
- data/app/components/primer/underline_nav_component.html.erb +1 -1
- data/app/components/primer/underline_nav_component.rb +27 -5
- data/app/lib/primer/tabbed_component_helper.rb +2 -2
- data/{app/lib → lib}/primer/classify.rb +41 -35
- data/{app/lib → lib}/primer/classify/cache.rb +16 -35
- data/{app/lib → lib}/primer/classify/flex.rb +0 -0
- data/{app/lib → lib}/primer/classify/functional_background_colors.rb +2 -0
- data/{app/lib → lib}/primer/classify/functional_border_colors.rb +2 -0
- data/{app/lib → lib}/primer/classify/functional_colors.rb +0 -0
- data/{app/lib → lib}/primer/classify/functional_text_colors.rb +2 -0
- data/lib/primer/classify/grid.rb +45 -0
- data/lib/primer/classify/utilities.rb +137 -0
- data/lib/primer/classify/utilities.yml +1271 -0
- data/lib/primer/view_components.rb +1 -0
- data/lib/primer/view_components/engine.rb +2 -0
- data/lib/primer/view_components/linters.rb +3 -0
- data/lib/primer/view_components/linters/argument_mappers/button.rb +82 -0
- data/lib/primer/view_components/linters/argument_mappers/conversion_error.rb +10 -0
- data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +47 -0
- data/lib/primer/view_components/linters/button_component_migration_counter.rb +39 -0
- data/lib/primer/view_components/linters/flash_component_migration_counter.rb +16 -0
- data/lib/primer/view_components/linters/helpers.rb +191 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/docs.rake +180 -108
- data/lib/tasks/utilities.rake +105 -0
- data/lib/yard/docs_helper.rb +12 -2
- data/static/statuses.json +7 -5
- metadata +50 -20
- data/app/components/primer/button_marketing_component.rb +0 -68
- data/app/components/primer/dropdown/menu_component.html.erb +0 -12
- data/app/components/primer/dropdown/menu_component.rb +0 -46
- data/app/components/primer/dropdown_component.rb +0 -73
- data/app/components/primer/text_component.rb +0 -25
- data/app/lib/primer/classify/spacing.rb +0 -63
@@ -1,73 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# `Dropdown` is a lightweight context menu for housing navigation and actions.
|
5
|
-
# They're great for instances where you don't need the full power (and code) of the select menu.
|
6
|
-
class DropdownComponent < Primer::Component
|
7
|
-
# Required trigger for the dropdown. Only accepts a content.
|
8
|
-
# Its classes can be customized by the `summary_classes` param in the parent component
|
9
|
-
renders_one :button
|
10
|
-
|
11
|
-
# Required context menu for the dropdown
|
12
|
-
#
|
13
|
-
# @param direction [Symbol] <%= one_of(Primer::Dropdown::MenuComponent::DIRECTION_OPTIONS) %>
|
14
|
-
# @param scheme [Symbol] Pass `:dark` for dark mode theming
|
15
|
-
# @param header [String] Optional string to display as the header
|
16
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
17
|
-
renders_one :menu, Primer::Dropdown::MenuComponent
|
18
|
-
|
19
|
-
# @example Default
|
20
|
-
# <div>
|
21
|
-
# <%= render(Primer::DropdownComponent.new) do |c| %>
|
22
|
-
# <% c.button do %>
|
23
|
-
# Dropdown
|
24
|
-
# <% end %>
|
25
|
-
#
|
26
|
-
# <%= c.menu(header: "Options") do |menu|
|
27
|
-
# menu.item { "Item 1" }
|
28
|
-
# menu.item { "Item 2" }
|
29
|
-
# menu.item(divider: true)
|
30
|
-
# menu.item { "Item 3" }
|
31
|
-
# menu.item { "Item 4" }
|
32
|
-
# end %>
|
33
|
-
# <% end %>
|
34
|
-
# </div>
|
35
|
-
#
|
36
|
-
# @example With Direction
|
37
|
-
# <div>
|
38
|
-
# <%= render(Primer::DropdownComponent.new) do |c| %>
|
39
|
-
# <% c.button do %>
|
40
|
-
# Dropdown
|
41
|
-
# <% end %>
|
42
|
-
#
|
43
|
-
# <%= c.menu(header: "Options", direction: :s) do |menu|
|
44
|
-
# menu.item { "Item 1" }
|
45
|
-
# menu.item { "Item 2" }
|
46
|
-
# menu.item(divider: true)
|
47
|
-
# menu.item { "Item 3" }
|
48
|
-
# menu.item { "Item 4" }
|
49
|
-
# end %>
|
50
|
-
# <% end %>
|
51
|
-
# </div>
|
52
|
-
#
|
53
|
-
# @param overlay [Symbol] <%= one_of(Primer::DetailsComponent::OVERLAY_MAPPINGS.keys) %>
|
54
|
-
# @param reset [Boolean] Whether to hide the default caret on the button
|
55
|
-
# @param summary_classes [String] Custom classes to add to the button
|
56
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
57
|
-
def initialize(overlay: :default, reset: true, summary_classes: "", **system_arguments)
|
58
|
-
@system_arguments = system_arguments
|
59
|
-
@system_arguments[:overlay] = overlay
|
60
|
-
@system_arguments[:reset] = reset
|
61
|
-
@system_arguments[:position] = :relative
|
62
|
-
@system_arguments[:classes] = class_names(
|
63
|
-
@system_arguments[:classes],
|
64
|
-
"dropdown"
|
65
|
-
)
|
66
|
-
@summary_classes = summary_classes
|
67
|
-
end
|
68
|
-
|
69
|
-
def render?
|
70
|
-
button.present? && menu.present?
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# `Text` is a wrapper component that will apply typography styles to the text inside.
|
5
|
-
class TextComponent < Primer::Component
|
6
|
-
status :beta
|
7
|
-
|
8
|
-
DEFAULT_TAG = :span
|
9
|
-
|
10
|
-
# @example Default
|
11
|
-
# <%= render(Primer::TextComponent.new(tag: :p, font_weight: :bold)) { "Bold Text" } %>
|
12
|
-
# <%= render(Primer::TextComponent.new(tag: :p, color: :text_danger)) { "Danger Text" } %>
|
13
|
-
#
|
14
|
-
# @param tag [Symbol]
|
15
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
16
|
-
def initialize(tag: DEFAULT_TAG, **system_arguments)
|
17
|
-
@system_arguments = system_arguments
|
18
|
-
@system_arguments[:tag] = tag
|
19
|
-
end
|
20
|
-
|
21
|
-
def call
|
22
|
-
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
class Classify
|
5
|
-
# Handler for PrimerCSS spacing classes.
|
6
|
-
class Spacing
|
7
|
-
BASE_OPTIONS = (0..6).to_a.freeze
|
8
|
-
BASE_MAPPINGS = {
|
9
|
-
my: BASE_OPTIONS,
|
10
|
-
pb: BASE_OPTIONS,
|
11
|
-
pl: BASE_OPTIONS,
|
12
|
-
pr: BASE_OPTIONS,
|
13
|
-
pt: BASE_OPTIONS,
|
14
|
-
px: BASE_OPTIONS,
|
15
|
-
py: BASE_OPTIONS
|
16
|
-
}.freeze
|
17
|
-
|
18
|
-
MARGIN_DIRECTION_OPTIONS = [*(-6..-1), *BASE_OPTIONS].freeze
|
19
|
-
MARGIN_DIRECTION_MAPPINGS = {
|
20
|
-
mb: MARGIN_DIRECTION_OPTIONS,
|
21
|
-
ml: MARGIN_DIRECTION_OPTIONS,
|
22
|
-
mr: MARGIN_DIRECTION_OPTIONS,
|
23
|
-
mt: MARGIN_DIRECTION_OPTIONS
|
24
|
-
}.freeze
|
25
|
-
|
26
|
-
AUTO_OPTIONS = [*BASE_OPTIONS, :auto].freeze
|
27
|
-
AUTO_MAPPINGS = {
|
28
|
-
m: AUTO_OPTIONS,
|
29
|
-
mx: AUTO_OPTIONS
|
30
|
-
}.freeze
|
31
|
-
|
32
|
-
RESPONSIVE_OPTIONS = [*BASE_OPTIONS, :responsive].freeze
|
33
|
-
RESPONSIVE_MAPPINGS = {
|
34
|
-
p: RESPONSIVE_OPTIONS
|
35
|
-
}.freeze
|
36
|
-
|
37
|
-
MAPPINGS = {
|
38
|
-
**BASE_MAPPINGS,
|
39
|
-
**MARGIN_DIRECTION_MAPPINGS,
|
40
|
-
**AUTO_MAPPINGS,
|
41
|
-
**RESPONSIVE_MAPPINGS
|
42
|
-
}.freeze
|
43
|
-
KEYS = MAPPINGS.keys.freeze
|
44
|
-
|
45
|
-
class << self
|
46
|
-
def spacing(key, val, breakpoint)
|
47
|
-
validate(key, val) unless Rails.env.production?
|
48
|
-
|
49
|
-
return "#{key.to_s.dasherize}#{breakpoint}-n#{val.abs}" if val.is_a?(Numeric) && val.negative?
|
50
|
-
|
51
|
-
"#{key.to_s.dasherize}#{breakpoint}-#{val.to_s.dasherize}"
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def validate(key, val)
|
57
|
-
raise ArgumentError, "#{key} is not a spacing key" unless KEYS.include?(key)
|
58
|
-
raise ArgumentError, "#{val} is not a valid value for :#{key}. Use one of #{MAPPINGS[key]}" unless MAPPINGS[key].include?(val)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|