primer_view_components 0.0.18 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +101 -0
  3. data/app/assets/javascripts/primer_view_components.js +2 -0
  4. data/app/assets/javascripts/primer_view_components.js.map +1 -0
  5. data/app/components/primer/avatar_component.rb +27 -9
  6. data/app/components/primer/avatar_stack_component.html.erb +10 -0
  7. data/app/components/primer/avatar_stack_component.rb +81 -0
  8. data/app/components/primer/base_component.rb +4 -4
  9. data/app/components/primer/blankslate_component.html.erb +3 -3
  10. data/app/components/primer/blankslate_component.rb +16 -24
  11. data/app/components/primer/border_box_component.html.erb +4 -18
  12. data/app/components/primer/border_box_component.rb +75 -72
  13. data/app/components/primer/box_component.rb +2 -2
  14. data/app/components/primer/breadcrumb_component.rb +1 -1
  15. data/app/components/primer/button_component.rb +2 -2
  16. data/app/components/primer/button_group_component.rb +4 -1
  17. data/app/components/primer/button_marketing_component.rb +2 -2
  18. data/app/components/primer/component.rb +9 -6
  19. data/app/components/primer/counter_component.rb +5 -1
  20. data/app/components/primer/details_component.html.erb +2 -6
  21. data/app/components/primer/details_component.rb +22 -35
  22. data/app/components/primer/dropdown/menu_component.html.erb +12 -0
  23. data/app/components/primer/dropdown/menu_component.rb +48 -0
  24. data/app/components/primer/dropdown_component.html.erb +9 -0
  25. data/app/components/primer/dropdown_component.rb +75 -0
  26. data/app/components/primer/dropdown_menu_component.rb +8 -4
  27. data/app/components/primer/flash_component.html.erb +4 -7
  28. data/app/components/primer/flash_component.rb +18 -18
  29. data/app/components/primer/flex_component.rb +38 -1
  30. data/app/components/primer/flex_item_component.rb +15 -1
  31. data/app/components/primer/heading_component.rb +3 -1
  32. data/app/components/primer/label_component.rb +15 -25
  33. data/app/components/primer/layout_component.rb +2 -2
  34. data/app/components/primer/link_component.rb +6 -2
  35. data/app/components/primer/markdown_component.rb +293 -0
  36. data/app/components/primer/menu_component.html.erb +6 -0
  37. data/app/components/primer/menu_component.rb +71 -0
  38. data/app/components/primer/octicon_component.rb +9 -3
  39. data/app/components/primer/popover_component.rb +5 -5
  40. data/app/components/primer/primer.js +1 -0
  41. data/app/components/primer/primer.ts +1 -0
  42. data/app/components/primer/progress_bar_component.rb +5 -5
  43. data/app/components/primer/spinner_component.rb +7 -3
  44. data/app/components/primer/state_component.rb +21 -10
  45. data/app/components/primer/subhead_component.html.erb +3 -15
  46. data/app/components/primer/subhead_component.rb +45 -61
  47. data/app/components/primer/tab_container_component.js +1 -0
  48. data/app/components/primer/tab_container_component.rb +41 -0
  49. data/app/components/primer/tab_container_component.ts +1 -0
  50. data/app/components/primer/tab_nav_component.html.erb +17 -0
  51. data/app/components/primer/tab_nav_component.rb +108 -0
  52. data/app/components/primer/text_component.rb +1 -1
  53. data/app/components/primer/timeline_item_component.html.erb +4 -16
  54. data/app/components/primer/timeline_item_component.rb +41 -52
  55. data/app/components/primer/tooltip_component.rb +5 -5
  56. data/app/components/primer/truncate_component.rb +4 -4
  57. data/app/components/primer/underline_nav_component.rb +2 -2
  58. data/{lib → app/lib}/primer/class_name_helper.rb +0 -0
  59. data/{lib → app/lib}/primer/classify.rb +21 -10
  60. data/app/lib/primer/classify/cache.rb +125 -0
  61. data/{lib → app/lib}/primer/fetch_or_fallback_helper.rb +1 -1
  62. data/{lib → app/lib}/primer/join_style_arguments_helper.rb +1 -1
  63. data/app/lib/primer/view_helper.rb +22 -0
  64. data/app/lib/primer/view_helper/dsl.rb +34 -0
  65. data/lib/primer/view_components.rb +32 -1
  66. data/lib/primer/view_components/engine.rb +11 -3
  67. data/lib/primer/view_components/version.rb +5 -1
  68. data/lib/yard/renders_many_handler.rb +19 -0
  69. data/lib/yard/renders_one_handler.rb +19 -0
  70. data/static/statuses.json +1 -0
  71. metadata +61 -10
  72. data/app/components/primer/view_components.rb +0 -56
@@ -0,0 +1,9 @@
1
+ <%= render(Primer::DetailsComponent.new(**@system_arguments)) do |c| %>
2
+ <% c.summary(classes: @summary_classes) do %>
3
+ <%= button %>
4
+ <% end %>
5
+
6
+ <% c.body do %>
7
+ <%= menu %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # Dropdowns 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) of the select menu.
6
+ class DropdownComponent < Primer::Component
7
+ include ViewComponent::SlotableV2
8
+
9
+ # Required trigger for the dropdown. Only accepts a content.
10
+ # Its classes can be customized by the `summary_classes` param in the parent component
11
+ renders_one :button
12
+
13
+ # Required context menu for the dropdown
14
+ #
15
+ # @param direction [Symbol] <%= one_of(Primer::Dropdown::MenuComponent::DIRECTION_OPTIONS) %>
16
+ # @param scheme [Symbol] Pass :dark for dark mode theming
17
+ # @param header [String] Optional string to display as the header
18
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
19
+ renders_one :menu, Primer::Dropdown::MenuComponent
20
+
21
+ # @example Default
22
+ # <div>
23
+ # <%= render(Primer::DropdownComponent.new) do |c| %>
24
+ # <% c.button do %>
25
+ # Dropdown
26
+ # <% end %>
27
+ #
28
+ # <%= c.menu(header: "Options") do |menu|
29
+ # menu.item { "Item 1" }
30
+ # menu.item { "Item 2" }
31
+ # menu.item(divider: true)
32
+ # menu.item { "Item 3" }
33
+ # menu.item { "Item 4" }
34
+ # end %>
35
+ # <% end %>
36
+ # </div>
37
+ #
38
+ # @example With Direction
39
+ # <div>
40
+ # <%= render(Primer::DropdownComponent.new) do |c| %>
41
+ # <% c.button do %>
42
+ # Dropdown
43
+ # <% end %>
44
+ #
45
+ # <%= c.menu(header: "Options", direction: :s) do |menu|
46
+ # menu.item { "Item 1" }
47
+ # menu.item { "Item 2" }
48
+ # menu.item(divider: true)
49
+ # menu.item { "Item 3" }
50
+ # menu.item { "Item 4" }
51
+ # end %>
52
+ # <% end %>
53
+ # </div>
54
+ #
55
+ # @param overlay [Symbol] <%= one_of(Primer::DetailsComponent::OVERLAY_MAPPINGS.keys) %>
56
+ # @param reset [Boolean] Whether to hide the default caret on the button
57
+ # @param summary_classes [String] Custom classes to add to the button
58
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
59
+ def initialize(overlay: :default, reset: true, summary_classes: "", **system_arguments)
60
+ @system_arguments = system_arguments
61
+ @system_arguments[:overlay] = overlay
62
+ @system_arguments[:reset] = reset
63
+ @system_arguments[:position] = :relative
64
+ @system_arguments[:classes] = class_names(
65
+ @system_arguments[:classes],
66
+ "dropdown"
67
+ )
68
+ @summary_classes = summary_classes
69
+ end
70
+
71
+ def render?
72
+ button.present? && menu.present?
73
+ end
74
+ end
75
+ end
@@ -14,14 +14,18 @@ module Primer
14
14
  DIRECTION_DEFAULT = :se
15
15
  DIRECTION_OPTIONS = [DIRECTION_DEFAULT, :sw, :w, :e, :ne, :s].freeze
16
16
 
17
- # @example 200|With a header
18
- # <div style="margin-bottom: 150px">
17
+ def self.status
18
+ STATUSES[:deprecated]
19
+ end
20
+
21
+ # @example With a header
22
+ # <div>
19
23
  # <%= render(Primer::DetailsComponent.new(overlay: :default, reset: true, position: :relative)) do |c| %>
20
- # <% c.slot(:summary) do %>
24
+ # <% c.summary do %>
21
25
  # Dropdown
22
26
  # <% end %>
23
27
  #
24
- # <% c.slot(:body) do %>
28
+ # <% c.body do %>
25
29
  # <%= render(Primer::DropdownMenuComponent.new(header: "Options")) do %>
26
30
  # <ul>
27
31
  # <li><a class="dropdown-item" href="#url">Dropdown item</a></li>
@@ -1,14 +1,11 @@
1
1
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
- <%= render(Primer::OcticonComponent.new(icon: @icon)) if @icon %>
2
+ <%= primer(:octicon, icon: @icon) if @icon %>
3
3
  <%= content %>
4
4
  <% if @dismissible %>
5
5
  <button class="flash-close js-flash-close" type="button" aria-label="Close">
6
- <%= render(Primer::OcticonComponent.new(icon: "x")) %>
6
+ <%= primer(:octicon, icon: "x") %>
7
7
  </button>
8
8
  <% end %>
9
- <% if actions.present? %>
10
- <%= render Primer::BaseComponent.new(**actions.system_arguments) do %>
11
- <%= actions.content %>
12
- <% end %>
13
- <% end %>
9
+
10
+ <%= action %>
14
11
  <% end %>
@@ -3,9 +3,17 @@
3
3
  module Primer
4
4
  # Use the Flash component to inform users of successful or pending actions.
5
5
  class FlashComponent < Primer::Component
6
- include ViewComponent::Slotable
6
+ include ViewComponent::SlotableV2
7
7
 
8
- with_slot :actions, class_name: "Actions"
8
+ # Optional action content showed on the right side of the component.
9
+ #
10
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
11
+ renders_one :action, lambda { |**system_arguments|
12
+ system_arguments[:tag] = :div
13
+ system_arguments[:classes] = class_names(system_arguments[:classes], "flash-action")
14
+
15
+ Primer::BaseComponent.new(**system_arguments)
16
+ }
9
17
 
10
18
  DEFAULT_VARIANT = :default
11
19
  VARIANT_MAPPINGS = {
@@ -14,25 +22,25 @@ module Primer
14
22
  :danger => "flash-error",
15
23
  :success => "flash-success"
16
24
  }.freeze
17
- # @example 280|Variants
25
+ # @example Variants
18
26
  # <%= render(Primer::FlashComponent.new) { "This is a flash message!" } %>
19
27
  # <%= render(Primer::FlashComponent.new(variant: :warning)) { "This is a warning flash message!" } %>
20
28
  # <%= render(Primer::FlashComponent.new(variant: :danger)) { "This is a danger flash message!" } %>
21
29
  # <%= render(Primer::FlashComponent.new(variant: :success)) { "This is a success flash message!" } %>
22
30
  #
23
- # @example 80|Full width
31
+ # @example Full width
24
32
  # <%= render(Primer::FlashComponent.new(full: true)) { "This is a full width flash message!" } %>
25
33
  #
26
- # @example 80|Dismissible
34
+ # @example Dismissible
27
35
  # <%= render(Primer::FlashComponent.new(dismissible: true)) { "This is a dismissible flash message!" } %>
28
36
  #
29
- # @example 80|Icon
37
+ # @example Icon
30
38
  # <%= render(Primer::FlashComponent.new(icon: "people")) { "This is a flash message with an icon!" } %>
31
39
  #
32
- # @example 80|With actions
40
+ # @example With actions
33
41
  # <%= render(Primer::FlashComponent.new) do |component| %>
34
42
  # This is a flash message with actions!
35
- # <% component.slot(:actions) do %>
43
+ # <% component.action do %>
36
44
  # <%= render(Primer::ButtonComponent.new(variant: :small)) { "Take action" } %>
37
45
  # <% end %>
38
46
  # <% end %>
@@ -57,16 +65,8 @@ module Primer
57
65
  @system_arguments[:mb] ||= spacious ? 4 : nil
58
66
  end
59
67
 
60
- # :nodoc
61
- class Actions < Primer::Slot
62
- attr_reader :system_arguments
63
-
64
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
65
- def initialize(**system_arguments)
66
- @system_arguments = system_arguments
67
- @system_arguments[:tag] = :div
68
- @system_arguments[:classes] = class_names(@system_arguments[:classes], "flash-action")
69
- end
68
+ def self.status
69
+ Primer::Component::STATUSES[:beta]
70
70
  end
71
71
  end
72
72
  end
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # :nodoc
4
+ # Use FlexComponent to make an element lay out its content using the flexbox model.
5
+ # Before using these utilities, you should be familiar with CSS3 Flexible Box
6
+ # spec. If you are not, check out MDN's guide [Using CSS Flexible
7
+ # Boxes](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox).
5
8
  class FlexComponent < Primer::Component
6
9
  JUSTIFY_CONTENT_DEFAULT = nil
7
10
  JUSTIFY_CONTENT_MAPPINGS = {
@@ -32,6 +35,40 @@ module Primer
32
35
  DEFAULT_DIRECTION = nil
33
36
  ALLOWED_DIRECTIONS = [DEFAULT_DIRECTION, :column, :column_reverse, :row, :row_reverse].freeze
34
37
 
38
+ # @example Default
39
+ # <%= render(Primer::FlexComponent.new(bg: :gray)) do %>
40
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 1" } %>
41
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 2" } %>
42
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 3" } %>
43
+ # <% end %>
44
+ #
45
+ # @example Justify center
46
+ # <%= render(Primer::FlexComponent.new(justify_content: :center, bg: :gray)) do %>
47
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 1" } %>
48
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 2" } %>
49
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 3" } %>
50
+ # <% end %>
51
+ #
52
+ # @example Align end
53
+ # <%= render(Primer::FlexComponent.new(align_items: :end, bg: :gray)) do %>
54
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 1" } %>
55
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 2" } %>
56
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 3" } %>
57
+ # <% end %>
58
+ #
59
+ # @example Direction column
60
+ # <%= render(Primer::FlexComponent.new(direction: :column, bg: :gray)) do %>
61
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 1" } %>
62
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 2" } %>
63
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 3" } %>
64
+ # <% end %>
65
+ #
66
+ # @param justify_content [Symbol] Use this param to distribute space between and around flex items along the main axis of the container. <%= one_of(Primer::FlexComponent::JUSTIFY_CONTENT_OPTIONS) %>
67
+ # @param inline [Boolean] Defaults to false.
68
+ # @param flex_wrap [Boolean] Defaults to nil.
69
+ # @param align_items [Symbol] Use this param to align items on the cross axis. <%= one_of(Primer::FlexComponent::ALIGN_ITEMS_OPTIONS) %>
70
+ # @param direction [Symbol] Use this param to define the orientation of the main axis (row or column). By default, flex items will display in a row. <%= one_of(Primer::FlexComponent::ALLOWED_DIRECTIONS) %>
71
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
35
72
  def initialize(
36
73
  justify_content: JUSTIFY_CONTENT_DEFAULT,
37
74
  inline: INLINE_DEFAULT,
@@ -1,11 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # :nodoc
4
+ # Use FlexItemComponent to specify the ability of a flex item to alter its
5
+ # dimensions to fill available space
5
6
  class FlexItemComponent < Primer::Component
6
7
  FLEX_AUTO_DEFAULT = false
7
8
  FLEX_AUTO_ALLOWED_VALUES = [FLEX_AUTO_DEFAULT, true].freeze
8
9
 
10
+ # @example Default
11
+ # <%= render(Primer::FlexComponent.new) do %>
12
+ # <%= render(Primer::FlexItemComponent.new) do %>
13
+ # Item 1
14
+ # <% end %>
15
+ #
16
+ # <%= render(Primer::FlexItemComponent.new(flex_auto: true)) do %>
17
+ # Item 2
18
+ # <% end %>
19
+ # <% end %>
20
+ #
21
+ # @param flex_auto [Boolean] Fills available space and auto-sizes based on the content. Defaults to <%= Primer::FlexItemComponent::FLEX_AUTO_DEFAULT %>
22
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
9
23
  def initialize(flex_auto: FLEX_AUTO_DEFAULT, **system_arguments)
10
24
  @system_arguments = system_arguments
11
25
  @system_arguments[:classes] =
@@ -3,7 +3,9 @@
3
3
  module Primer
4
4
  # Use the Heading component to wrap a component that will create a heading element
5
5
  class HeadingComponent < Primer::Component
6
- # @example 70|Default
6
+ view_helper :heading
7
+
8
+ # @example Default
7
9
  # <%= render(Primer::HeadingComponent.new) { "H1 Text" } %>
8
10
  # <%= render(Primer::HeadingComponent.new(tag: :h2)) { "H2 Text" } %>
9
11
  # <%= render(Primer::HeadingComponent.new(tag: :h3)) { "H3 Text" } %>
@@ -3,7 +3,7 @@
3
3
  module Primer
4
4
  # Use labels to add contextual metadata to a design.
5
5
  class LabelComponent < Primer::Component
6
- NEW_SCHEME_MAPPINGS = {
6
+ SCHEME_MAPPINGS = {
7
7
  primary: "Label--primary",
8
8
  secondary: "Label--secondary",
9
9
  info: "Label--info",
@@ -12,21 +12,6 @@ module Primer
12
12
  danger: "Label--danger"
13
13
  }.freeze
14
14
 
15
- DEPRECATED_SCHEME_MAPPINGS = {
16
- gray: "Label--gray",
17
- dark_gray: "Label--gray-darker",
18
- yellow: "Label--yellow",
19
- orange: "Label--orange",
20
- red: "Label--red",
21
- green: "Label--green",
22
- blue: "Label--blue",
23
- purple: "Label--purple",
24
- pink: "Label--pink",
25
- outline: "Label--outline",
26
- green_outline: "Label--outline-green"
27
- }.freeze
28
-
29
- SCHEME_MAPPINGS = NEW_SCHEME_MAPPINGS.merge(DEPRECATED_SCHEME_MAPPINGS)
30
15
  SCHEME_OPTIONS = SCHEME_MAPPINGS.keys << nil
31
16
 
32
17
  VARIANT_MAPPINGS = {
@@ -35,20 +20,21 @@ module Primer
35
20
  }.freeze
36
21
  VARIANT_OPTIONS = VARIANT_MAPPINGS.keys << nil
37
22
 
38
- # @example 40|Schemes
39
- # <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "default" } %>
40
- # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :gray)) { "gray" } %>
41
- # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :dark_gray)) { "dark_gray" } %>
42
- # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :yellow)) { "yellow" } %>
43
- # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :green)) { "green" } %>
44
- # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :purple)) { "purple" } %>
23
+ # @example Schemes
24
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "Default" } %>
25
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :primary)) { "Primary" } %>
26
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :secondary)) { "Secondary" } %>
27
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :info)) { "Info" } %>
28
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :success)) { "Success" } %>
29
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :warning)) { "Warning" } %>
30
+ # <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :danger)) { "Danger" } %>
45
31
  #
46
- # @example 40|Variants
32
+ # @example Variants
47
33
  # <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "Default" } %>
48
34
  # <%= render(Primer::LabelComponent.new(title: "Label: Label", variant: :large)) { "Large" } %>
49
35
  #
50
36
  # @param title [String] `title` attribute for the component element.
51
- # @param scheme [Symbol] <%= one_of(Primer::LabelComponent::DEPRECATED_SCHEME_MAPPINGS.keys) %>
37
+ # @param scheme [Symbol] <%= one_of(Primer::LabelComponent::SCHEME_MAPPINGS.keys) %>
52
38
  # @param variant [Symbol] <%= one_of(Primer::LabelComponent::VARIANT_OPTIONS) %>
53
39
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
54
40
  def initialize(title:, scheme: nil, variant: nil, **system_arguments)
@@ -67,5 +53,9 @@ module Primer
67
53
  def call
68
54
  render(Primer::BaseComponent.new(**@system_arguments)) { content }
69
55
  end
56
+
57
+ def self.status
58
+ Primer::Component::STATUSES[:beta]
59
+ end
70
60
  end
71
61
  end
@@ -12,13 +12,13 @@ module Primer
12
12
  DEFAULT_SIDEBAR_COL = 3
13
13
  ALLOWED_SIDEBAR_COLS = (1..(MAX_COL - 1)).to_a.freeze
14
14
 
15
- # @example 40|Default
15
+ # @example Default
16
16
  # <%= render(Primer::LayoutComponent.new) do |component| %>
17
17
  # <% component.with(:sidebar) { "Sidebar" } %>
18
18
  # <% component.with(:main) { "Main" } %>
19
19
  # <% end %>
20
20
  #
21
- # @example 40|Left sidebar
21
+ # @example Left sidebar
22
22
  # <%= render(Primer::LayoutComponent.new(side: :left)) do |component| %>
23
23
  # <% component.with(:sidebar) { "Sidebar" } %>
24
24
  # <% component.with(:main) { "Main" } %>
@@ -3,10 +3,10 @@
3
3
  module Primer
4
4
  # Use links for moving from one page to another. The Link component styles anchor tags with default blue styling and hover text-decoration.
5
5
  class LinkComponent < Primer::Component
6
- # @example 40|Default
6
+ # @example Default
7
7
  # <%= render(Primer::LinkComponent.new(href: "http://www.google.com")) { "Link" } %>
8
8
  #
9
- # @example 40|Muted
9
+ # @example Muted
10
10
  # <%= render(Primer::LinkComponent.new(href: "http://www.google.com", muted: true)) { "Link" } %>
11
11
  #
12
12
  # @param href [String] URL to be used for the Link
@@ -25,5 +25,9 @@ module Primer
25
25
  def call
26
26
  render(Primer::BaseComponent.new(**@system_arguments)) { content }
27
27
  end
28
+
29
+ def self.status
30
+ Primer::Component::STATUSES[:beta]
31
+ end
28
32
  end
29
33
  end
@@ -0,0 +1,293 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # Use MarkdownComponent to wrap markdown content
5
+ class MarkdownComponent < Primer::Component
6
+ # @example Default
7
+ # <%= render(Primer::MarkdownComponent.new) do %>
8
+ # <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>
9
+ #
10
+ # <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>
11
+ #
12
+ # <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>
13
+ #
14
+ # <blockquote>
15
+ # <p>There should be no margin above this first sentence.</p>
16
+ # <p>Blockquotes should be a lighter gray with a gray border along the left side.</p>
17
+ # <p>There should be no margin below this final sentence.</p>
18
+ # </blockquote>
19
+ #
20
+ # <h1>Header 1</h1>
21
+ #
22
+ # <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>
23
+ #
24
+ # <h2>Header 2</h2>
25
+ #
26
+ # <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>
27
+ #
28
+ # <h3>Header 3</h3>
29
+ #
30
+ # <pre><code>This is a code block following a header.</code></pre>
31
+ #
32
+ # <h4>Header 4</h4>
33
+ #
34
+ # <ul>
35
+ # <li>This is an unordered list following a header.</li>
36
+ # <li>This is an unordered list following a header.</li>
37
+ # <li>This is an unordered list following a header.</li>
38
+ # </ul>
39
+ #
40
+ # <h5>Header 5</h5>
41
+ #
42
+ # <ol>
43
+ # <li>This is an ordered list following a header.</li>
44
+ # <li>This is an ordered list following a header.</li>
45
+ # <li>This is an ordered list following a header.</li>
46
+ # </ol>
47
+ #
48
+ # <h6>Header 6</h6>
49
+ #
50
+ # <table>
51
+ # <thead>
52
+ # <tr>
53
+ # <th>What</th>
54
+ # <th>Follows</th>
55
+ # </tr>
56
+ # </thead>
57
+ # <tbody>
58
+ # <tr>
59
+ # <td>A table</td>
60
+ # <td>A header</td>
61
+ # </tr>
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
+ # </tbody>
71
+ # </table>
72
+ #
73
+ # <hr />
74
+ #
75
+ # <p>There's a horizontal rule above and below this.</p>
76
+ #
77
+ # <hr />
78
+ #
79
+ # <p>Here is an unordered list:</p>
80
+ #
81
+ # <ul>
82
+ # <li>Salt-n-Pepa</li>
83
+ # <li>Bel Biv DeVoe</li>
84
+ # <li>Kid 'N Play</li>
85
+ # </ul>
86
+ #
87
+ # <p>And an ordered list:</p>
88
+ #
89
+ # <ol>
90
+ # <li>Michael Jackson</li>
91
+ # <li>Michael Bolton</li>
92
+ # <li>Michael Buble</li>
93
+ # </ol>
94
+ #
95
+ # <p>And an unordered task list:</p>
96
+ #
97
+ # <ul>
98
+ # <li><input type="checkbox" checked /> Create a sample markdown document</li>
99
+ # <li><input type="checkbox"/> Add task lists to it</li>
100
+ # <li><input type="checkbox"/> Take a vacation</li>
101
+ # </ul>
102
+ #
103
+ # <p>And a "mixed" task list:</p>
104
+ #
105
+ # <ul>
106
+ # <li><input type="checkbox"/> Steal underpants</li>
107
+ # <li>?</li>
108
+ # <li><input type="checkbox"/> Profit!</li>
109
+ # </ul>
110
+ #
111
+ # And a nested list:
112
+ #
113
+ # <ul>
114
+ # <li>Jackson 5
115
+ # <ul>
116
+ # <li>Michael</li>
117
+ # <li>Tito</li>
118
+ # <li>Jackie</li>
119
+ # <li>Marlon</li>
120
+ # <li>Jermaine</li>
121
+ # </ul>
122
+ # </li>
123
+ # <li>TMNT
124
+ # <ul>
125
+ # <li>Leonardo</li>
126
+ # <li>Michelangelo</li>
127
+ # <li>Donatello</li>
128
+ # <li>Raphael</li>
129
+ # </ul>
130
+ # </li>
131
+ # </ul>
132
+ #
133
+ # <p>Definition lists can be used with HTML syntax. Definition terms are bold and italic.</p>
134
+ #
135
+ # <dl>
136
+ # <dt>Name</dt>
137
+ # <dd>Godzilla</dd>
138
+ # <dt>Born</dt>
139
+ # <dd>1952</dd>
140
+ # <dt>Birthplace</dt>
141
+ # <dd>Japan</dd>
142
+ # <dt>Color</dt>
143
+ # <dd>Green</dd>
144
+ # </dl>
145
+ #
146
+ # <hr />
147
+ #
148
+ # <p>Tables should have bold headings and alternating shaded rows.</p>
149
+ #
150
+ # <table>
151
+ # <thead>
152
+ # <tr>
153
+ # <th>Artist</th>
154
+ # <th>Album</th>
155
+ # <th>Year</th>
156
+ # </tr>
157
+ # </thead>
158
+ # <tbody>
159
+ # <tr>
160
+ # <td>David Bowie</td>
161
+ # <td>Scary Monsters</td>
162
+ # <td>1980</td>
163
+ # </tr>
164
+ # <tr>
165
+ # <td>Prince</td>
166
+ # <td>Purple Rain</td>
167
+ # <td>1982</td>
168
+ # </tr>
169
+ # <tr>
170
+ # <td>Beastie Boys</td>
171
+ # <td>License to Ill</td>
172
+ # <td>1986</td>
173
+ # </tr>
174
+ # <tr>
175
+ # <td>Janet Jackson</td>
176
+ # <td>Rhythm Nation 1814</td>
177
+ # <td>1989</td>
178
+ # </tr>
179
+ # </tbody>
180
+ # </table>
181
+ #
182
+ # <p>If a table is too wide, it should condense down and/or scroll horizontally.</p>
183
+ #
184
+ # <table>
185
+ # <thead>
186
+ # <tr>
187
+ # <th>Artist</th>
188
+ # <th>Album</th>
189
+ # <th>Year</th>
190
+ # <th>Label</th>
191
+ # <th>Songs</th>
192
+ # </tr>
193
+ # </thead>
194
+ # <tbody>
195
+ # <tr>
196
+ # <td>David Bowie</td>
197
+ # <td>Scary Monsters</td>
198
+ # <td>1980</td>
199
+ # <td>RCA Records</td>
200
+ # <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>
201
+ # </tr>
202
+ # <tr>
203
+ # <td>Prince</td>
204
+ # <td>Purple Rain</td>
205
+ # <td>1982</td>
206
+ # <td>Warner Brothers Records</td>
207
+ # <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>
208
+ # </tr>
209
+ # <tr>
210
+ # <td>Beastie Boys</td>
211
+ # <td>License to Ill</td>
212
+ # <td>1986</td>
213
+ # <td>Def Jam</td>
214
+ # <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>
215
+ # </tr>
216
+ # <tr>
217
+ # <td>Janet Jackson</td>
218
+ # <td>Rhythm Nation 1814</td>
219
+ # <td>1989</td>
220
+ # <td>A&amp;M</td>
221
+ # <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>
222
+ # </tr>
223
+ # </tbody>
224
+ # </table>
225
+ #
226
+ # <hr />
227
+ #
228
+ # <p>Code snippets like <code>var foo = "bar";</code> can be shown inline.</p>
229
+ #
230
+ # <p>Also, <code>this should vertically align</code> <s><code>with this</code></s> <s>and this</s>.</p>
231
+ #
232
+ # <p>Code can also be shown in a block element.</p>
233
+ #
234
+ # <pre><code>var foo = "bar";</code></pre>
235
+ #
236
+ # <p>Code can also use syntax highlighting.</p>
237
+ #
238
+ # <pre><code class="prism-code language-javascript">var foo = "bar";</code></pre>
239
+ #
240
+ # <pre><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>
241
+ #
242
+ # <pre><code class="prism-code language-javascript">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>
243
+ #
244
+ # <p>Inline code inside table cells should still be distinguishable.</p>
245
+ #
246
+ # <table>
247
+ # <thead>
248
+ # <tr>
249
+ # <th>Language</th>
250
+ # <th>Code</th>
251
+ # </tr>
252
+ # </thead>
253
+ # <tbody>
254
+ # <tr>
255
+ # <td>JavasScript</td>
256
+ # <td><code>var foo = "bar";</code></td>
257
+ # </tr>
258
+ # <tr>
259
+ # <td>Ruby</td>
260
+ # <td><code>foo = "bar"</code></td>
261
+ # </tr>
262
+ # </tbody>
263
+ # </table>
264
+ #
265
+ # <hr />
266
+ #
267
+ # <p>Small images should be shown at their actual size.</p>
268
+ #
269
+ # <p><img src="http://placekitten.com/g/300/200/"/></p>
270
+ #
271
+ # <p>Large images should always scale down and fit in the content container.</p>
272
+ #
273
+ # <p><img src="http://placekitten.com/g/1200/800/"/></p>
274
+ #
275
+ # <pre><code>This is the final element on the page and there should be no margin below this.</code></pre>
276
+ # <% end %>
277
+ #
278
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
279
+ def initialize(**system_arguments)
280
+ @system_arguments = system_arguments
281
+ @system_arguments[:tag] ||= :div
282
+
283
+ @system_arguments[:classes] = class_names(
284
+ "markdown-body",
285
+ system_arguments[:classes]
286
+ )
287
+ end
288
+
289
+ def call
290
+ render(Primer::BaseComponent.new(**@system_arguments)) { content }
291
+ end
292
+ end
293
+ end