openproject-primer_view_components 0.11.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +75 -0
  3. data/app/assets/javascripts/app/components/primer/primer.d.ts +1 -1
  4. data/app/assets/javascripts/primer_view_components.js +1 -1
  5. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  6. data/app/assets/styles/primer_view_components.css +1 -1
  7. data/app/assets/styles/primer_view_components.css.map +1 -1
  8. data/app/components/primer/alpha/action_menu/action_menu_element.js +2 -1
  9. data/app/components/primer/alpha/action_menu/action_menu_element.ts +2 -1
  10. data/app/components/primer/alpha/check_box_group.rb +2 -0
  11. data/app/components/primer/alpha/dialog/header.rb +12 -0
  12. data/app/components/primer/alpha/dialog.rb +1 -1
  13. data/app/components/primer/alpha/nav_list/divider.rb +2 -5
  14. data/app/components/primer/alpha/nav_list/group.rb +2 -98
  15. data/app/components/primer/alpha/nav_list/heading.rb +2 -27
  16. data/app/components/primer/alpha/nav_list/item.rb +2 -147
  17. data/app/components/primer/alpha/nav_list.rb +2 -205
  18. data/app/components/primer/alpha/overlay.css +1 -1
  19. data/app/components/primer/alpha/overlay.css.map +1 -1
  20. data/app/components/primer/alpha/overlay.pcss +1 -7
  21. data/app/components/primer/alpha/overlay.rb +6 -4
  22. data/app/components/primer/alpha/radio_button_group.rb +2 -0
  23. data/app/components/primer/alpha/text_field.css +1 -1
  24. data/app/components/primer/alpha/text_field.css.json +4 -1
  25. data/app/components/primer/alpha/text_field.css.map +1 -1
  26. data/app/components/primer/alpha/text_field.pcss +18 -3
  27. data/app/components/primer/alpha/tooltip.rb +3 -1
  28. data/app/components/primer/beta/button.css +1 -1
  29. data/app/components/primer/beta/button.css.json +2 -0
  30. data/app/components/primer/beta/button.css.map +1 -1
  31. data/app/components/primer/beta/button.pcss +11 -3
  32. data/app/components/primer/beta/icon_button.html.erb +1 -1
  33. data/app/components/primer/beta/icon_button.rb +8 -1
  34. data/app/components/primer/beta/link.css +1 -1
  35. data/app/components/primer/beta/link.css.json +1 -0
  36. data/app/components/primer/beta/link.css.map +1 -1
  37. data/app/components/primer/beta/link.pcss +5 -0
  38. data/app/components/primer/beta/link.rb +2 -2
  39. data/app/components/primer/beta/nav_list/divider.rb +14 -0
  40. data/app/components/primer/beta/nav_list/group.rb +107 -0
  41. data/app/components/primer/beta/nav_list/heading.rb +36 -0
  42. data/app/components/primer/beta/nav_list/item.rb +156 -0
  43. data/app/components/primer/beta/nav_list.rb +212 -0
  44. data/app/components/primer/focus_group.js +2 -1
  45. data/app/components/primer/focus_group.ts +2 -1
  46. data/app/components/primer/open_project/flex_layout.html.erb +23 -0
  47. data/app/components/primer/open_project/flex_layout.rb +52 -0
  48. data/app/components/primer/open_project/grid_layout/area.rb +38 -0
  49. data/app/components/primer/open_project/grid_layout.html.erb +11 -0
  50. data/app/components/primer/open_project/grid_layout.rb +34 -0
  51. data/app/components/primer/open_project/page_header.css +1 -1
  52. data/app/components/primer/open_project/page_header.css.map +1 -1
  53. data/app/components/primer/open_project/page_header.pcss +4 -0
  54. data/app/components/primer/primer.d.ts +1 -1
  55. data/app/components/primer/primer.js +1 -1
  56. data/app/components/primer/primer.ts +1 -1
  57. data/app/helpers/primer/form_helper.rb +10 -0
  58. data/lib/primer/deprecations.yml +20 -0
  59. data/lib/primer/forms/check_box_group.html.erb +3 -0
  60. data/lib/primer/forms/dsl/check_box_group_input.rb +1 -5
  61. data/lib/primer/forms/dsl/check_box_input.rb +5 -0
  62. data/lib/primer/forms/dsl/radio_button_input.rb +5 -0
  63. data/lib/primer/forms/form_control.html.erb +1 -4
  64. data/lib/primer/forms/radio_button_group.html.erb +3 -0
  65. data/lib/primer/forms/utils.rb +2 -0
  66. data/lib/primer/forms/validation_message.html.erb +4 -0
  67. data/lib/primer/forms/validation_message.rb +14 -0
  68. data/lib/primer/forms.rb +16 -0
  69. data/lib/primer/view_components/version.rb +2 -2
  70. data/lib/primer/yard/component_manifest.rb +4 -0
  71. data/previews/primer/alpha/check_box_group_preview.rb +13 -0
  72. data/previews/primer/alpha/dialog_preview/with_header.html.erb +5 -0
  73. data/previews/primer/alpha/dialog_preview.rb +17 -0
  74. data/previews/primer/alpha/overlay_preview.rb +1 -1
  75. data/previews/primer/alpha/radio_button_group_preview.rb +13 -0
  76. data/previews/primer/alpha/radio_button_preview.rb +1 -1
  77. data/previews/primer/alpha/text_field_preview/input_group_leading_action_menu.html.erb +21 -0
  78. data/previews/primer/alpha/text_field_preview/input_group_leading_button.html.erb +18 -0
  79. data/previews/primer/alpha/text_field_preview/input_group_trailing_button.html.erb +18 -0
  80. data/previews/primer/alpha/text_field_preview.rb +21 -0
  81. data/previews/primer/beta/button_preview.rb +1 -1
  82. data/previews/primer/{alpha → beta}/nav_list_preview/trailing_action.html.erb +1 -1
  83. data/previews/primer/{alpha → beta}/nav_list_preview.rb +5 -5
  84. data/previews/primer/open_project/flex_layout_preview.rb +73 -0
  85. data/previews/primer/open_project/grid_layout_preview.rb +37 -0
  86. data/static/arguments.json +260 -6
  87. data/static/audited_at.json +8 -0
  88. data/static/classes.json +3 -0
  89. data/static/constants.json +35 -0
  90. data/static/info_arch.json +1235 -505
  91. data/static/previews.json +192 -7
  92. data/static/statuses.json +13 -5
  93. metadata +30 -11
  94. /data/app/assets/javascripts/app/components/primer/{alpha → beta}/nav_list.d.ts +0 -0
  95. /data/app/components/primer/{alpha → beta}/nav_list/group.html.erb +0 -0
  96. /data/app/components/primer/{alpha → beta}/nav_list/item.html.erb +0 -0
  97. /data/app/components/primer/{alpha → beta}/nav_list.d.ts +0 -0
  98. /data/app/components/primer/{alpha → beta}/nav_list.html.erb +0 -0
  99. /data/app/components/primer/{alpha → beta}/nav_list.js +0 -0
  100. /data/app/components/primer/{alpha → beta}/nav_list.ts +0 -0
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module OpenProject
5
+ # A layouting component used to arrange multiple components in a CSS Grid
6
+ # Note that this component only provides helpers (as the class names and grid-area styles).
7
+ # However, it does not define the actual Grid which should be done in a separate CSS-file.
8
+ class GridLayout < Primer::Component
9
+ status :open_project
10
+ attr_reader :css_class
11
+
12
+ renders_many :areas, lambda { |area_name, component = ::Primer::BaseComponent, **system_arguments, &block|
13
+ render(Primer::OpenProject::GridLayout::Area.new(@css_class, area_name, component, **system_arguments), &block)
14
+ }
15
+
16
+ # @param css_class [String] The basic css class applied on the grid-container
17
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
18
+ def initialize(css_class:, **system_arguments)
19
+ super
20
+
21
+ @system_arguments = system_arguments
22
+ @css_class = css_class
23
+ @system_arguments[:classes] = class_names(
24
+ @system_arguments[:classes],
25
+ css_class
26
+ )
27
+ end
28
+
29
+ def render?
30
+ areas.any?
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1 +1 @@
1
- .PageHeader{border-bottom:var(--borderWidth-thin,max(1px,.0625rem)) solid var(--borderColor-muted,var(--color-border-muted));display:flex;flex-flow:row wrap;justify-content:flex-end;margin-bottom:var(--stack-gap-normal,1rem);padding-bottom:var(--stack-padding-condensed,.5rem)}.PageHeader-title{flex:1 1 auto;font-size:24px;font-weight:var(--base-text-weight-normal,400);order:0}.PageHeader-title--large{font-size:var(--text-title-size-large,2rem)}.PageHeader-description{color:var(--fgColor-muted,var(--color-fg-muted));flex:1 100%;font-size:var(--text-body-size-medium,.875rem);order:2}.PageHeader-actions{align-self:center;justify-content:flex-end;margin:var(--base-size-4,.25rem) 0 var(--base-size-4,.25rem) var(--base-size-4,.25rem);order:1}.PageHeader-actions+.PageHeader-description{margin-top:var(--base-size-4,.25rem)}
1
+ .PageHeader{border-bottom:var(--borderWidth-thin,max(1px,.0625rem)) solid var(--borderColor-muted,var(--color-border-muted));display:flex;flex-flow:row wrap;justify-content:flex-end;margin-bottom:var(--stack-gap-normal,1rem);padding-bottom:var(--stack-padding-condensed,.5rem)}@media (max-width:767.98px){.PageHeader{border-bottom:0}}.PageHeader-title{flex:1 1 auto;font-size:24px;font-weight:var(--base-text-weight-normal,400);order:0}.PageHeader-title--large{font-size:var(--text-title-size-large,2rem)}.PageHeader-description{color:var(--fgColor-muted,var(--color-fg-muted));flex:1 100%;font-size:var(--text-body-size-medium,.875rem);order:2}.PageHeader-actions{align-self:center;justify-content:flex-end;margin:var(--base-size-4,.25rem) 0 var(--base-size-4,.25rem) var(--base-size-4,.25rem);order:1}.PageHeader-actions+.PageHeader-description{margin-top:var(--base-size-4,.25rem)}
@@ -1 +1 @@
1
- {"version":3,"sources":["page_header.pcss"],"names":[],"mappings":"AAEA,YAIE,gHAAqE,CAHrE,YAAa,CAIb,kBAAmB,CACnB,wBAAyB,CAHzB,0CAAsC,CADtC,mDAKF,CAEA,kBAGE,aAAc,CAFd,cAAe,CACf,8CAA2C,CAE3C,OACF,CAEA,yBACE,2CACF,CAGA,wBAEE,gDAA2B,CAC3B,WAAY,CAFZ,8CAAuC,CAGvC,OACF,CAGA,oBAEE,iBAAkB,CAClB,wBAAyB,CAFzB,sFAAkE,CAGlE,OAKF,CAHE,4CACE,oCACF","file":"page_header.css","sourcesContent":["/* OP PageHeader */\n\n.PageHeader {\n display: flex;\n padding-bottom: var(--stack-padding-condensed);\n margin-bottom: var(--stack-gap-normal);\n border-bottom: var(--borderWidth-thin) solid var(--borderColor-muted);\n flex-flow: row wrap;\n justify-content: flex-end; /* Keep actions right aligned. */\n}\n\n.PageHeader-title {\n font-size: 24px;\n font-weight: var(--base-text-weight-normal);\n flex: 1 1 auto;\n order: 0;\n}\n\n.PageHeader-title--large {\n font-size: var(--text-title-size-large);\n}\n\n/* One-liner of supporting text */\n.PageHeader-description {\n font-size: var(--text-body-size-medium);\n color: var(--fgColor-muted);\n flex: 1 100%;\n order: 2;\n}\n\n/* Add 1 or 2 buttons to the right of the heading */\n.PageHeader-actions {\n margin: var(--base-size-4) 0 var(--base-size-4) var(--base-size-4);\n align-self: center;\n justify-content: flex-end;\n order: 1;\n\n & + .PageHeader-description {\n margin-top: var(--base-size-4);\n }\n}\n"]}
1
+ {"version":3,"sources":["page_header.pcss"],"names":[],"mappings":"AAEA,YAIE,gHAAqE,CAHrE,YAAa,CAIb,kBAAmB,CACnB,wBAAyB,CAHzB,0CAAsC,CADtC,mDASF,CAHE,4BARF,YASI,eAEJ,CADE,CAGF,kBAGE,aAAc,CAFd,cAAe,CACf,8CAA2C,CAE3C,OACF,CAEA,yBACE,2CACF,CAGA,wBAEE,gDAA2B,CAC3B,WAAY,CAFZ,8CAAuC,CAGvC,OACF,CAGA,oBAEE,iBAAkB,CAClB,wBAAyB,CAFzB,sFAAkE,CAGlE,OAKF,CAHE,4CACE,oCACF","file":"page_header.css","sourcesContent":["/* OP PageHeader */\n\n.PageHeader {\n display: flex;\n padding-bottom: var(--stack-padding-condensed);\n margin-bottom: var(--stack-gap-normal);\n border-bottom: var(--borderWidth-thin) solid var(--borderColor-muted);\n flex-flow: row wrap;\n justify-content: flex-end; /* Keep actions right aligned. */\n\n @media (max-width: 767.98px) {\n border-bottom: 0;\n }\n}\n\n.PageHeader-title {\n font-size: 24px;\n font-weight: var(--base-text-weight-normal);\n flex: 1 1 auto;\n order: 0;\n}\n\n.PageHeader-title--large {\n font-size: var(--text-title-size-large);\n}\n\n/* One-liner of supporting text */\n.PageHeader-description {\n font-size: var(--text-body-size-medium);\n color: var(--fgColor-muted);\n flex: 1 100%;\n order: 2;\n}\n\n/* Add 1 or 2 buttons to the right of the heading */\n.PageHeader-actions {\n margin: var(--base-size-4) 0 var(--base-size-4) var(--base-size-4);\n align-self: center;\n justify-content: flex-end;\n order: 1;\n\n & + .PageHeader-description {\n margin-top: var(--base-size-4);\n }\n}\n"]}
@@ -7,6 +7,10 @@
7
7
  border-bottom: var(--borderWidth-thin) solid var(--borderColor-muted);
8
8
  flex-flow: row wrap;
9
9
  justify-content: flex-end; /* Keep actions right aligned. */
10
+
11
+ @media (max-width: 767.98px) {
12
+ border-bottom: 0;
13
+ }
10
14
  }
11
15
 
12
16
  .PageHeader-title {
@@ -6,7 +6,7 @@ import './anchored_position';
6
6
  import './focus_group';
7
7
  import './alpha/image_crop';
8
8
  import './alpha/modal_dialog';
9
- import './alpha/nav_list';
9
+ import './beta/nav_list';
10
10
  import './alpha/segmented_control';
11
11
  import './alpha/toggle_switch';
12
12
  import './alpha/tool_tip';
@@ -6,7 +6,7 @@ import './anchored_position';
6
6
  import './focus_group';
7
7
  import './alpha/image_crop';
8
8
  import './alpha/modal_dialog';
9
- import './alpha/nav_list';
9
+ import './beta/nav_list';
10
10
  import './alpha/segmented_control';
11
11
  import './alpha/toggle_switch';
12
12
  import './alpha/tool_tip';
@@ -6,7 +6,7 @@ import './anchored_position'
6
6
  import './focus_group'
7
7
  import './alpha/image_crop'
8
8
  import './alpha/modal_dialog'
9
- import './alpha/nav_list'
9
+ import './beta/nav_list'
10
10
  import './alpha/segmented_control'
11
11
  import './alpha/toggle_switch'
12
12
  import './alpha/tool_tip'
@@ -19,5 +19,15 @@ module Primer
19
19
  &block
20
20
  )
21
21
  end
22
+
23
+ def inline_form(*args, &block)
24
+ Primer::Forms.inline_form(*args, &block)
25
+ end
26
+
27
+ def render_inline_form(*args, &block)
28
+ # rubocop:disable GitHub/RailsViewRenderLiteral
29
+ render(inline_form(*args, &block))
30
+ # rubocop:enable GitHub/RailsViewRenderLiteral
31
+ end
22
32
  end
23
33
  end
@@ -5,6 +5,26 @@
5
5
  # See 'docs/contributors/deprecations.md' for information on configuration options.
6
6
 
7
7
  deprecations:
8
+ - component: "Primer::Alpha::NavList::Divider"
9
+ autocorrect: true
10
+ replacement: "Primer::Beta::NavList::Divider"
11
+
12
+ - component: "Primer::Alpha::NavList::Item"
13
+ autocorrect: true
14
+ replacement: "Primer::Beta::NavList::Item"
15
+
16
+ - component: "Primer::Alpha::NavList::Heading"
17
+ autocorrect: true
18
+ replacement: "Primer::Beta::NavList::Heading"
19
+
20
+ - component: "Primer::Alpha::NavList::Group"
21
+ autocorrect: true
22
+ replacement: "Primer::Beta::NavList::Group"
23
+
24
+ - component: "Primer::Alpha::NavList"
25
+ autocorrect: true
26
+ replacement: "Primer::Beta::NavList"
27
+
8
28
  - component: "Primer::Alpha::AutoComplete"
9
29
  autocorrect: true
10
30
  replacement: "Primer::Beta::AutoComplete"
@@ -11,6 +11,9 @@
11
11
  <% end %>
12
12
  <% end %>
13
13
  </fieldset>
14
+ <div class="mt-2">
15
+ <%= render(ValidationMessage.new(input: @input)) %>
16
+ </div>
14
17
  <div class="mt-2">
15
18
  <%= render(Caption.new(input: @input)) %>
16
19
  </div>
@@ -5,7 +5,7 @@ module Primer
5
5
  module Dsl
6
6
  # :nodoc:
7
7
  class CheckBoxGroupInput < Input
8
- attr_reader :label, :check_boxes
8
+ attr_reader :name, :label, :check_boxes
9
9
 
10
10
  def initialize(name: nil, label: nil, **system_arguments)
11
11
  @name = name
@@ -21,10 +21,6 @@ module Primer
21
21
  CheckBoxGroup.new(input: self)
22
22
  end
23
23
 
24
- def name
25
- nil
26
- end
27
-
28
24
  def type
29
25
  :check_box_group
30
26
  end
@@ -26,6 +26,11 @@ module Primer
26
26
  yield(self) if block_given?
27
27
  end
28
28
 
29
+ # check boxes cannot be invalid, as both checked and unchecked are valid states
30
+ def valid?
31
+ true
32
+ end
33
+
29
34
  def to_component
30
35
  CheckBox.new(input: self)
31
36
  end
@@ -17,6 +17,11 @@ module Primer
17
17
  yield(self) if block_given?
18
18
  end
19
19
 
20
+ # radio buttons cannot be invalid, as both selected and unselected are valid states
21
+ def valid?
22
+ true
23
+ end
24
+
20
25
  def to_component
21
26
  RadioButton.new(input: self)
22
27
  end
@@ -9,10 +9,7 @@
9
9
  <% end %>
10
10
  <% end %>
11
11
  <%= content %>
12
- <%= content_tag(:div, **@input.validation_arguments) do %>
13
- <span class="FormControl-inlineValidation--visual"><%= render(Primer::Beta::Octicon.new(icon: :"alert-fill", size: :xsmall, aria: { hidden: true })) %></span>
14
- <%= content_tag(:span, @input.invalid? ? @input.validation_messages.first : "", **@input.validation_message_arguments) %>
15
- <% end %>
12
+ <%= render(ValidationMessage.new(input: @input)) %>
16
13
  <%= render(Caption.new(input: @input)) %>
17
14
  <% end %>
18
15
  <% else %>
@@ -11,6 +11,9 @@
11
11
  <% end %>
12
12
  <% end %>
13
13
  </fieldset>
14
+ <div class="mt-2">
15
+ <%= render(ValidationMessage.new(input: @input)) %>
16
+ </div>
14
17
  <div class="mt-2">
15
18
  <%= render(Caption.new(input: @input)) %>
16
19
  </div>
@@ -15,6 +15,8 @@ module Primer
15
15
  # conventions, so it should work ok. Zeitwerk also has this information but lacks a
16
16
  # public API to map constants to source files.
17
17
  def const_source_location(class_name)
18
+ return nil unless class_name
19
+
18
20
  # NOTE: underscore respects namespacing, i.e. will convert Foo::Bar to foo/bar.
19
21
  class_path = "#{class_name.underscore}.rb"
20
22
 
@@ -0,0 +1,4 @@
1
+ <%= content_tag(:div, **@input.validation_arguments) do %>
2
+ <span class="FormControl-inlineValidation--visual"><%= render(Primer::Beta::Octicon.new(icon: :"alert-fill", size: :xsmall, aria: { hidden: true })) %></span>
3
+ <%= content_tag(:span, @input.invalid? ? @input.validation_messages.first : "", **@input.validation_message_arguments) %>
4
+ <% end %>
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Forms
5
+ # :nodoc:
6
+ class ValidationMessage < BaseComponent
7
+ attr_reader :input
8
+
9
+ def initialize(input:)
10
+ @input = input
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # :nodoc:
5
+ module Forms
6
+ def self.inline_form(builder, base = nil, &block)
7
+ base ||= defined?(ApplicationForm) ? ApplicationForm : Primer::Forms::Base
8
+
9
+ klass = Class.new(base) do
10
+ form(&block)
11
+ end
12
+
13
+ klass.new(builder)
14
+ end
15
+ end
16
+ end
@@ -5,8 +5,8 @@ module Primer
5
5
  module ViewComponents
6
6
  module VERSION
7
7
  MAJOR = 0
8
- MINOR = 11
9
- PATCH = 0
8
+ MINOR = 12
9
+ PATCH = 1
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
12
12
  end
@@ -73,6 +73,10 @@ module Primer
73
73
  Primer::Alpha::NavList::Item => { js: true, examples: false },
74
74
  Primer::Alpha::NavList::Group => { js: true, examples: false },
75
75
 
76
+ Primer::Beta::NavList => { js: true },
77
+ Primer::Beta::NavList::Item => { js: true, examples: false },
78
+ Primer::Beta::NavList::Group => { js: true, examples: false },
79
+
76
80
  # ActionList is a base component that should not be used by itself, and thus
77
81
  # does not have examples of its own
78
82
  Primer::Alpha::ActionList => { js: true, examples: false },
@@ -9,17 +9,20 @@ module Primer
9
9
  # @param name text
10
10
  # @param label text
11
11
  # @param caption text
12
+ # @param validation_message text
12
13
  # @param disabled toggle
13
14
  def playground(
14
15
  name: "my-check-group",
15
16
  label: "I would go into battle with:",
16
17
  caption: "Qa'pla!",
18
+ validation_message: nil,
17
19
  disabled: false
18
20
  )
19
21
  system_arguments = {
20
22
  name: name,
21
23
  label: label,
22
24
  caption: caption,
25
+ validation_message: validation_message,
23
26
  disabled: disabled
24
27
  }
25
28
 
@@ -41,6 +44,16 @@ module Primer
41
44
  end
42
45
  end
43
46
 
47
+ # @label Invalid
48
+ def invalid
49
+ render(Primer::Alpha::CheckBoxGroup.new(validation_message: "Please choose at least one", name: "my-check-group", label: "I would go into battle with:")) do |component|
50
+ component.check_box(label: "Jean-Luc Picard", value: "picard4")
51
+ component.check_box(label: "Hikaru Sulu", value: "sulu4")
52
+ component.check_box(label: "Kathryn Janeway", value: "janeway4")
53
+ component.check_box(label: "Benjamin Sisko", value: "sisko4")
54
+ end
55
+ end
56
+
44
57
  # @!group Options
45
58
  # @snapshot
46
59
  #
@@ -0,0 +1,5 @@
1
+ <%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: title, subtitle: subtitle)) do |d| %>
2
+ <% d.with_show_button { button_text } %>
3
+ <% d.with_body { "Content" } %>
4
+ <% d.with_header(show_divider: show_divider, variant: header_variant) %>
5
+ <% end %>
@@ -60,6 +60,23 @@ module Primer
60
60
  end
61
61
  end
62
62
 
63
+ # @label With Header
64
+ #
65
+ # @param title [String] text
66
+ # @param subtitle [String] text
67
+ # @param header_variant [Symbol] select [medium, large]
68
+ # @param button_text [String] text
69
+ # @param show_divider [Boolean] toggle
70
+ def with_header(title: "Test Dialog", subtitle: nil, header_variant: :medium, button_text: "Show Dialog", show_divider: true)
71
+ render_with_template(locals: {
72
+ title: title,
73
+ subtitle: subtitle,
74
+ header_variant: header_variant,
75
+ button_text: button_text,
76
+ show_divider: show_divider
77
+ })
78
+ end
79
+
63
80
  # @label With Footer
64
81
  #
65
82
  # @param title [String] text
@@ -165,7 +165,7 @@ module Primer
165
165
  end
166
166
 
167
167
  # @label In an ActionMenu
168
- def in_an_action_menu()
168
+ def in_an_action_menu
169
169
  render_with_template(locals: {})
170
170
  end
171
171
 
@@ -9,17 +9,20 @@ module Primer
9
9
  # @param name text
10
10
  # @param label text
11
11
  # @param caption text
12
+ # @param validation_message text
12
13
  # @param disabled toggle
13
14
  def playground(
14
15
  name: "my-radio-group",
15
16
  label: "Question: what kind of bear is best?",
16
17
  caption: "There are basically two schools of thought",
18
+ validation_message: nil,
17
19
  disabled: false
18
20
  )
19
21
  system_arguments = {
20
22
  name: name,
21
23
  label: label,
22
24
  caption: caption,
25
+ validation_message: validation_message,
23
26
  disabled: disabled
24
27
  }
25
28
 
@@ -40,6 +43,16 @@ module Primer
40
43
  end
41
44
  end
42
45
 
46
+ # @label Invalid
47
+ # @snapshot
48
+ def invalid
49
+ render(Primer::Alpha::RadioButtonGroup.new(validation_message: "Please select an option", name: "my-radio-group", label: "Question: what kind of bear is best?")) do |component|
50
+ component.radio_button(label: "Bears", value: "bears")
51
+ component.radio_button(label: "Beets", value: "beets")
52
+ component.radio_button(label: "Battlestar Galactica", value: "bsg")
53
+ end
54
+ end
55
+
43
56
  # @!group Options
44
57
  #
45
58
  # @label With caption
@@ -51,7 +51,7 @@ module Primer
51
51
  # @label Checked
52
52
  # @snapshot
53
53
  def checked
54
- render(Primer::Alpha::RadioButton.new(name: "my-radio-button", label: "Battlestar Galactica", value: "bsg2", checked: true ))
54
+ render(Primer::Alpha::RadioButton.new(name: "my-radio-button", label: "Battlestar Galactica", value: "bsg2", checked: true))
55
55
  end
56
56
 
57
57
  # @label Visually hidden label
@@ -0,0 +1,21 @@
1
+
2
+ <%= render(Primer::BaseComponent.new(tag: :div, flex_items: :center, display: :flex)) do %>
3
+ <%= form_with(url: action_menu_form_action_path(format: route_format)) do |f| %>
4
+ <%= render(Primer::Alpha::ActionMenu.new(select_variant: :single, form_arguments: { builder: f, name: "foo" })) do |menu| %>
5
+ <% menu.with_show_button(classes: "rounded-right-0 border-right-0") { |button| button.with_trailing_action_icon(icon: :"triangle-down"); "Filter" } %>
6
+ <% menu.with_item(label: "Fast forward", data: { value: "fast_forward" }) %>
7
+ <% menu.with_item(label: "Recursive", data: { value: "recursive" }) %>
8
+ <% menu.with_item(label: "Ours", data: { value: "ours" }) %>
9
+ <% menu.with_item(label: "Resolve") %>
10
+ <% end %>
11
+ <% end %>
12
+ <%= render(Primer::Alpha::TextField.new(
13
+ name: "message",
14
+ placeholder: "What's happening?",
15
+ label: "What is your current status?",
16
+ classes: "rounded-left-0",
17
+ visually_hide_label: true,
18
+ value: "Some value",
19
+ inset: true,
20
+ )) %>
21
+ <% end %>
@@ -0,0 +1,18 @@
1
+
2
+ <%= render(Primer::BaseComponent.new(tag: :div, flex_items: :center, display: :flex)) do %>
3
+ <%= render(Primer::Beta::IconButton.new(
4
+ classes: "rounded-right-0 border-right-0",
5
+ icon: :smiley,
6
+ aria: { label: "Emoji" }
7
+ )
8
+ ) %>
9
+ <%= render(Primer::Alpha::TextField.new(
10
+ name: "message",
11
+ placeholder: "What's happening?",
12
+ label: "What is your current status?",
13
+ classes: "rounded-left-0",
14
+ visually_hide_label: true,
15
+ value: "Some value",
16
+ inset: true,
17
+ )) %>
18
+ <% end %>
@@ -0,0 +1,18 @@
1
+
2
+ <%= render(Primer::BaseComponent.new(tag: :div, flex_items: :center, display: :flex)) do %>
3
+ <%= render(Primer::Alpha::TextField.new(
4
+ name: "message",
5
+ placeholder: "What's happening?",
6
+ label: "What is your current status?",
7
+ classes: "rounded-right-0",
8
+ visually_hide_label: true,
9
+ value: "Some value",
10
+ inset: true,
11
+ )) %>
12
+ <%= render(Primer::Beta::IconButton.new(
13
+ classes: "rounded-left-0 border-left-0",
14
+ icon: :smiley,
15
+ aria: { label: "Emoji" }
16
+ )
17
+ ) %>
18
+ <% end %>
@@ -189,6 +189,27 @@ module Primer
189
189
  end
190
190
  #
191
191
  # @!endgroup
192
+
193
+ # @label Input group with leading button
194
+ #
195
+ # @snapshot
196
+ def input_group_leading_button
197
+ render_with_template
198
+ end
199
+
200
+ # @label Input group with trailing button
201
+ #
202
+ # @snapshot
203
+ def input_group_trailing_button
204
+ render_with_template
205
+ end
206
+
207
+ # @label Input group with ActionMenu
208
+ #
209
+ # @snapshot
210
+ def input_group_leading_action_menu(route_format: :html)
211
+ render_with_template(locals: { route_format: route_format })
212
+ end
192
213
  end
193
214
  end
194
215
  end
@@ -166,7 +166,7 @@ module Primer
166
166
  disabled: false
167
167
  )
168
168
  render_with_template(locals: {
169
- disabled: disabled,
169
+ disabled: disabled
170
170
  })
171
171
  end
172
172
 
@@ -1,4 +1,4 @@
1
- <%= render(Primer::Alpha::NavList.new(aria: { label: "Workflow results" })) do |list| %>
1
+ <%= render(Primer::Beta::NavList.new(aria: { label: "Workflow results" })) do |list| %>
2
2
  <% list.with_group do |group| %>
3
3
  <% group.with_heading(title: "Workflows") %>
4
4
  <% group.with_item(label: "Build and Test", href: "/workflows/1") do |item| %>
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- module Alpha
4
+ module Beta
5
5
  # @label NavList
6
6
  class NavListPreview < ViewComponent::Preview
7
7
  # @label Playground
8
8
  def playground
9
- render(Primer::Alpha::NavList.new(selected_item_id: :collaborators)) do |list|
9
+ render(Primer::Beta::NavList.new(selected_item_id: :collaborators)) do |list|
10
10
  list.with_heading(title: "Repository settings")
11
11
 
12
12
  list.with_item(label: "General", href: "/general") do |item|
@@ -34,7 +34,7 @@ module Primer
34
34
  # @label Default
35
35
  # @snapshot
36
36
  def default
37
- render(Primer::Alpha::NavList.new(selected_item_id: :code_review_limits)) do |list|
37
+ render(Primer::Beta::NavList.new(selected_item_id: :code_review_limits)) do |list|
38
38
  list.with_heading(title: "Repository settings")
39
39
 
40
40
  list.with_item(label: "General", href: "/general") do |item|
@@ -77,7 +77,7 @@ module Primer
77
77
  # @label Top-level items
78
78
  #
79
79
  def top_level_items
80
- render(Primer::Alpha::NavList.new) do |list|
80
+ render(Primer::Beta::NavList.new) do |list|
81
81
  list.with_heading(title: "Account settings")
82
82
 
83
83
  list.with_item(label: "General", href: "/general") do |item|
@@ -105,7 +105,7 @@ module Primer
105
105
  # @label Show more item
106
106
  # @snapshot
107
107
  def show_more_item
108
- render(Primer::Alpha::NavList.new(aria: { label: "My favorite foods" })) do |list|
108
+ render(Primer::Beta::NavList.new(aria: { label: "My favorite foods" })) do |list|
109
109
  list.with_group do |group|
110
110
  group.with_heading(title: "My favorite foods")
111
111
  group.with_item(label: "Popplers", href: "/foods/popplers")
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Setup Playground to use all available component props
4
+ # Setup Features to use individual component props and combinations
5
+
6
+ module Primer
7
+ module OpenProject
8
+ # @label FlexLayout
9
+ class FlexLayoutPreview < ViewComponent::Preview
10
+ # @label Playground
11
+ # @param direction [Symbol] select [column, column_reverse, row, row_reverse]
12
+ # @param justify_content [Symbol] select [space_between, space_around, center, flex_start, flex_end]
13
+ def playground(direction: :row, justify_content: :flex_start)
14
+ render(Primer::OpenProject::FlexLayout.new(direction: direction, justify_content: justify_content)) do |component|
15
+ component.with_box(bg: :attention, p: 6) do
16
+ "Block 1"
17
+ end
18
+ component.with_box(bg: :accent, p: 6) do
19
+ "Block 2"
20
+ end
21
+ end
22
+ end
23
+
24
+ # @label Default
25
+ def default
26
+ render(Primer::OpenProject::FlexLayout.new) do |component|
27
+ component.with_column(bg: :attention, p: 6) do
28
+ "Block 1"
29
+ end
30
+ component.with_column(bg: :accent, p: 6) do
31
+ "Block 2"
32
+ end
33
+ end
34
+ end
35
+
36
+ # @label Row layout
37
+ def row_layout
38
+ render(Primer::OpenProject::FlexLayout.new) do |component|
39
+ component.with_row(bg: :attention, p: 6) do
40
+ "Block 1"
41
+ end
42
+ component.with_row(bg: :accent, p: 6) do
43
+ "Block 2"
44
+ end
45
+ end
46
+ end
47
+
48
+ # @label Column layout
49
+ def column_layout
50
+ render(Primer::OpenProject::FlexLayout.new) do |component|
51
+ component.with_column(bg: :attention, p: 6) do
52
+ "Block 1"
53
+ end
54
+ component.with_column(bg: :accent, p: 6) do
55
+ "Block 2"
56
+ end
57
+ end
58
+ end
59
+
60
+ # @label Nested layout
61
+ def nested_layout
62
+ render(Primer::OpenProject::FlexLayout.new) do |component|
63
+ component.with_row(flex_layout: true) do |flex_child|
64
+ flex_child.with_column(bg: :attention, p: 3) { "Block 1" }
65
+ flex_child.with_column(bg: :success, p: 3) { "Block 2" }
66
+ end
67
+
68
+ component.with_row(bg: :accent, p: 6) { "Block 3" }
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end