openproject-primer_view_components 0.10.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +87 -0
- data/app/assets/javascripts/app/components/primer/primer.d.ts +1 -1
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_menu/action_menu_element.js +2 -1
- data/app/components/primer/alpha/action_menu/action_menu_element.ts +2 -1
- data/app/components/primer/alpha/check_box_group.rb +2 -0
- data/app/components/primer/alpha/dialog/header.rb +12 -0
- data/app/components/primer/alpha/dialog.rb +1 -1
- data/app/components/primer/alpha/nav_list/divider.rb +2 -5
- data/app/components/primer/alpha/nav_list/group.rb +2 -98
- data/app/components/primer/alpha/nav_list/heading.rb +2 -27
- data/app/components/primer/alpha/nav_list/item.rb +2 -147
- data/app/components/primer/alpha/nav_list.rb +2 -205
- data/app/components/primer/alpha/overlay.css +1 -1
- data/app/components/primer/alpha/overlay.css.map +1 -1
- data/app/components/primer/alpha/overlay.pcss +1 -7
- data/app/components/primer/alpha/overlay.rb +6 -4
- data/app/components/primer/alpha/radio_button_group.rb +2 -0
- data/app/components/primer/alpha/text_field.css +1 -1
- data/app/components/primer/alpha/text_field.css.json +4 -1
- data/app/components/primer/alpha/text_field.css.map +1 -1
- data/app/components/primer/alpha/text_field.pcss +18 -3
- data/app/components/primer/alpha/tooltip.rb +3 -1
- data/app/components/primer/beta/button.css +1 -1
- data/app/components/primer/beta/button.css.json +2 -0
- data/app/components/primer/beta/button.css.map +1 -1
- data/app/components/primer/beta/button.pcss +11 -3
- data/app/components/primer/beta/icon_button.html.erb +1 -1
- data/app/components/primer/beta/icon_button.rb +8 -1
- data/app/components/primer/beta/link.css +1 -1
- data/app/components/primer/beta/link.css.json +1 -0
- data/app/components/primer/beta/link.css.map +1 -1
- data/app/components/primer/beta/link.pcss +5 -0
- data/app/components/primer/beta/link.rb +2 -2
- data/app/components/primer/beta/nav_list/divider.rb +14 -0
- data/app/components/primer/beta/nav_list/group.rb +107 -0
- data/app/components/primer/beta/nav_list/heading.rb +36 -0
- data/app/components/primer/beta/nav_list/item.rb +156 -0
- data/app/components/primer/beta/nav_list.rb +212 -0
- data/app/components/primer/focus_group.js +2 -1
- data/app/components/primer/focus_group.ts +2 -1
- data/app/components/primer/open_project/border_grid/cell.html.erb +3 -0
- data/app/components/primer/open_project/border_grid/cell.rb +25 -0
- data/app/components/primer/open_project/border_grid.css +1 -0
- data/app/components/primer/open_project/border_grid.css.json +11 -0
- data/app/components/primer/open_project/border_grid.css.map +1 -0
- data/app/components/primer/open_project/border_grid.html.erb +7 -0
- data/app/components/primer/open_project/border_grid.pcss +35 -0
- data/app/components/primer/open_project/border_grid.rb +36 -0
- data/app/components/primer/open_project/drag_handle.css +1 -0
- data/app/components/primer/open_project/drag_handle.css.json +6 -0
- data/app/components/primer/open_project/drag_handle.css.map +1 -0
- data/app/components/primer/open_project/drag_handle.html.erb +6 -0
- data/app/components/primer/open_project/drag_handle.pcss +6 -0
- data/app/components/primer/open_project/drag_handle.rb +28 -0
- data/app/components/primer/open_project/flex_layout.html.erb +23 -0
- data/app/components/primer/open_project/flex_layout.rb +52 -0
- data/app/components/primer/open_project/grid_layout/area.rb +38 -0
- data/app/components/primer/open_project/grid_layout.html.erb +11 -0
- data/app/components/primer/open_project/grid_layout.rb +34 -0
- data/app/components/primer/open_project/page_header.css +1 -1
- data/app/components/primer/open_project/page_header.css.map +1 -1
- data/app/components/primer/open_project/page_header.pcss +4 -0
- data/app/components/primer/primer.d.ts +1 -1
- data/app/components/primer/primer.js +1 -1
- data/app/components/primer/primer.pcss +2 -0
- data/app/components/primer/primer.ts +1 -1
- data/app/helpers/primer/form_helper.rb +10 -0
- data/lib/primer/deprecations.yml +20 -0
- data/lib/primer/forms/check_box_group.html.erb +3 -0
- data/lib/primer/forms/dsl/check_box_group_input.rb +1 -5
- data/lib/primer/forms/dsl/check_box_input.rb +5 -0
- data/lib/primer/forms/dsl/radio_button_input.rb +5 -0
- data/lib/primer/forms/form_control.html.erb +1 -4
- data/lib/primer/forms/radio_button_group.html.erb +3 -0
- data/lib/primer/forms/utils.rb +2 -0
- data/lib/primer/forms/validation_message.html.erb +4 -0
- data/lib/primer/forms/validation_message.rb +14 -0
- data/lib/primer/forms.rb +16 -0
- data/lib/primer/view_components/version.rb +2 -2
- data/lib/primer/yard/component_manifest.rb +4 -0
- data/previews/primer/alpha/check_box_group_preview.rb +13 -0
- data/previews/primer/alpha/dialog_preview/with_header.html.erb +5 -0
- data/previews/primer/alpha/dialog_preview.rb +17 -0
- data/previews/primer/alpha/overlay_preview.rb +1 -1
- data/previews/primer/alpha/radio_button_group_preview.rb +13 -0
- data/previews/primer/alpha/radio_button_preview.rb +1 -1
- data/previews/primer/alpha/text_field_preview/input_group_leading_action_menu.html.erb +21 -0
- data/previews/primer/alpha/text_field_preview/input_group_leading_button.html.erb +18 -0
- data/previews/primer/alpha/text_field_preview/input_group_trailing_button.html.erb +18 -0
- data/previews/primer/alpha/text_field_preview.rb +21 -0
- data/previews/primer/beta/button_preview.rb +1 -1
- data/previews/primer/{alpha → beta}/nav_list_preview/trailing_action.html.erb +1 -1
- data/previews/primer/{alpha → beta}/nav_list_preview.rb +5 -5
- data/previews/primer/open_project/border_grid_preview.rb +42 -0
- data/previews/primer/open_project/drag_handle_preview.rb +23 -0
- data/previews/primer/open_project/flex_layout_preview.rb +73 -0
- data/previews/primer/open_project/grid_layout_preview.rb +37 -0
- data/static/arguments.json +314 -6
- data/static/audited_at.json +11 -0
- data/static/classes.json +18 -0
- data/static/constants.json +48 -0
- data/static/info_arch.json +1867 -955
- data/static/previews.json +273 -7
- data/static/statuses.json +16 -5
- metadata +46 -11
- /data/app/assets/javascripts/app/components/primer/{alpha → beta}/nav_list.d.ts +0 -0
- /data/app/components/primer/{alpha → beta}/nav_list/group.html.erb +0 -0
- /data/app/components/primer/{alpha → beta}/nav_list/item.html.erb +0 -0
- /data/app/components/primer/{alpha → beta}/nav_list.d.ts +0 -0
- /data/app/components/primer/{alpha → beta}/nav_list.html.erb +0 -0
- /data/app/components/primer/{alpha → beta}/nav_list.js +0 -0
- /data/app/components/primer/{alpha → beta}/nav_list.ts +0 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module OpenProject
|
5
|
+
# Add a general description of component here
|
6
|
+
# Add additional usage considerations or best practices that may aid the user to use the component correctly.
|
7
|
+
# @accessibility Add any accessibility considerations
|
8
|
+
class DragHandle < Primer::Component
|
9
|
+
status :open_project
|
10
|
+
|
11
|
+
DEFAULT_SIZE = Primer::Beta::Octicon::SIZE_DEFAULT
|
12
|
+
SIZE_OPTIONS = Primer::Beta::Octicon::SIZE_OPTIONS
|
13
|
+
|
14
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
15
|
+
def initialize(size: Primer::OpenProject::DragHandle::DEFAULT_SIZE, **system_arguments)
|
16
|
+
@system_arguments = system_arguments
|
17
|
+
@system_arguments[:tag] = "div"
|
18
|
+
@system_arguments[:classes] =
|
19
|
+
class_names(
|
20
|
+
@system_arguments[:classes],
|
21
|
+
"DragHandle"
|
22
|
+
)
|
23
|
+
|
24
|
+
@size = fetch_or_fallback(Primer::OpenProject::DragHandle::SIZE_OPTIONS, size, Primer::OpenProject::DragHandle::DEFAULT_SIZE)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% if rows.any? %>
|
2
|
+
<%= render(Primer::Box.new(**@system_arguments.merge(direction: :column))) do %>
|
3
|
+
<% rows.each do |row| %>
|
4
|
+
<%= row %>
|
5
|
+
<% end %>
|
6
|
+
<% end %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% if columns.any? %>
|
10
|
+
<%= render(Primer::Box.new(**@system_arguments.merge(direction: :row))) do %>
|
11
|
+
<% columns.each do |column| %>
|
12
|
+
<%= column %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<% if boxes.any? %>
|
18
|
+
<%= render(Primer::Box.new(**@system_arguments)) do %>
|
19
|
+
<% boxes.each do |box| %>
|
20
|
+
<%= box %>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
<% end %>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module OpenProject
|
5
|
+
# A layouting component used to arrange multiple components next / below each other
|
6
|
+
class FlexLayout < Primer::Component
|
7
|
+
status :open_project
|
8
|
+
|
9
|
+
renders_many :rows, lambda { |**system_arguments, &block|
|
10
|
+
child_component(system_arguments, &block)
|
11
|
+
}
|
12
|
+
renders_many :columns, lambda { |**system_arguments, &block|
|
13
|
+
child_component(system_arguments, &block)
|
14
|
+
}
|
15
|
+
# boxes are used when direction is set to row or column based on responsive breakpoints
|
16
|
+
renders_many :boxes, lambda { |**system_arguments, &block|
|
17
|
+
child_component(system_arguments, &block)
|
18
|
+
}
|
19
|
+
|
20
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
21
|
+
def initialize(**system_arguments)
|
22
|
+
super
|
23
|
+
|
24
|
+
@system_arguments = deny_tag_argument(**system_arguments) || {}
|
25
|
+
@system_arguments[:display] = :flex
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def render?
|
31
|
+
# no slot provided
|
32
|
+
raise ArgumentError, "You have to provide either rows, columns or boxes as a slot" if rows.empty? && columns.empty? && boxes.empty?
|
33
|
+
|
34
|
+
if [rows, columns, boxes].count { |arr| !arr.empty? } == 1
|
35
|
+
# only rows or columns or boxes are used
|
36
|
+
true
|
37
|
+
elsif [rows, columns, boxes].count { |arr| !arr.empty? } > 1
|
38
|
+
# rows, columns and boxes are used together, which is not allowed
|
39
|
+
raise ArgumentError, "You can't mix row, column and box slots"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def child_component(system_arguments, &block)
|
44
|
+
if system_arguments[:flex_layout] == true
|
45
|
+
Primer::OpenProject::FlexLayout.new(**system_arguments.except(:flex_layout), &block)
|
46
|
+
else
|
47
|
+
Primer::Box.new(**system_arguments || {})
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module OpenProject
|
5
|
+
class GridLayout
|
6
|
+
# GridLayout::Area is an internal component that wraps the items in a div with the given new class and responding "grid-area"
|
7
|
+
class Area < Primer::Component
|
8
|
+
status :open_project
|
9
|
+
|
10
|
+
DEFAULT_TAG = :div
|
11
|
+
TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
|
12
|
+
|
13
|
+
# @param css_class [String] The basic css class applied on the grid-container
|
14
|
+
# @param area_name [Symbol] The specific area name, used for creating the element class and the "grid-area" style
|
15
|
+
# @param component [ViewComponent::Base] The instance of the component to be rendered.
|
16
|
+
# @param tag [Symbol] <%= one_of(Primer::OpenProject::GridLayout::Area::TAG_OPTIONS) %>
|
17
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
18
|
+
def initialize(css_class, area_name, component = ::Primer::BaseComponent, tag: DEFAULT_TAG, **system_arguments)
|
19
|
+
@component = component
|
20
|
+
@system_arguments = system_arguments
|
21
|
+
@styles = [
|
22
|
+
"grid-area: #{area_name}"
|
23
|
+
]
|
24
|
+
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
25
|
+
@system_arguments[:style] = join_style_arguments(@system_arguments[:style], *@styles)
|
26
|
+
@system_arguments[:classes] = class_names(
|
27
|
+
@system_arguments[:classes],
|
28
|
+
"#{css_class}--#{area_name}"
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def call
|
33
|
+
render(@component.new(**@system_arguments)) { content }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -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,
|
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"]}
|
@@ -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 './
|
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 './
|
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 './
|
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
|
data/lib/primer/deprecations.yml
CHANGED
@@ -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"
|
@@ -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
|
@@ -9,10 +9,7 @@
|
|
9
9
|
<% end %>
|
10
10
|
<% end %>
|
11
11
|
<%= content %>
|
12
|
-
<%=
|
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 %>
|
data/lib/primer/forms/utils.rb
CHANGED
@@ -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 %>
|
data/lib/primer/forms.rb
ADDED
@@ -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
|
@@ -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
|
#
|
@@ -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
|
@@ -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 %>
|