openproject-primer_view_components 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +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;order:0}.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)}
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "open_project/page_header",
3
+ "selectors": [
4
+ ".PageHeader",
5
+ ".PageHeader-title",
6
+ ".PageHeader-description",
7
+ ".PageHeader-actions",
8
+ ".PageHeader-actions+.PageHeader-description"
9
+ ]
10
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["page_header.pcss"],"names":[],"mappings":"AAEA,YAIE,gHAAqE,CAHrE,YAAa,CAIb,kBAAmB,CACnB,wBAAyB,CAHzB,0CAAsC,CADtC,mDAKF,CAGA,kBACE,aAAc,CACd,OACF,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/* <h2> sized heading with normal font weight */\n.PageHeader-title {\n flex: 1 1 auto;\n order: 0;\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"]}
@@ -0,0 +1,5 @@
1
+ <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
+ <%= title %>
3
+ <%= description %>
4
+ <%= actions %>
5
+ <% end %>
@@ -0,0 +1,36 @@
1
+ /* OP PageHeader */
2
+
3
+ .PageHeader {
4
+ display: flex;
5
+ padding-bottom: var(--stack-padding-condensed);
6
+ margin-bottom: var(--stack-gap-normal);
7
+ border-bottom: var(--borderWidth-thin) solid var(--borderColor-muted);
8
+ flex-flow: row wrap;
9
+ justify-content: flex-end; /* Keep actions right aligned. */
10
+ }
11
+
12
+ /* <h2> sized heading with normal font weight */
13
+ .PageHeader-title {
14
+ flex: 1 1 auto;
15
+ order: 0;
16
+ }
17
+
18
+ /* One-liner of supporting text */
19
+ .PageHeader-description {
20
+ font-size: var(--text-body-size-medium);
21
+ color: var(--fgColor-muted);
22
+ flex: 1 100%;
23
+ order: 2;
24
+ }
25
+
26
+ /* Add 1 or 2 buttons to the right of the heading */
27
+ .PageHeader-actions {
28
+ margin: var(--base-size-4) 0 var(--base-size-4) var(--base-size-4);
29
+ align-self: center;
30
+ justify-content: flex-end;
31
+ order: 1;
32
+
33
+ & + .PageHeader-description {
34
+ margin-top: var(--base-size-4);
35
+ }
36
+ }
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module OpenProject
5
+ # A ViewComponent PageHeader inspired by the primer react variant
6
+ class PageHeader < Primer::Component
7
+ HEADING_TAG_OPTIONS = [:h1, :h2, :h3, :h4, :h5, :h6].freeze
8
+ HEADING_TAG_FALLBACK = :h1
9
+
10
+ status :open_project
11
+
12
+ # The title of the page header
13
+ #
14
+ # @param tag [Symbol] <%= one_of(Primer::Beta::Heading::TAG_OPTIONS) %>
15
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
16
+ renders_one :title, lambda { |tag: :h1, **system_arguments|
17
+ system_arguments[:tag] = fetch_or_fallback(HEADING_TAG_OPTIONS, tag, HEADING_TAG_FALLBACK)
18
+ system_arguments[:classes] = class_names(system_arguments[:classes], "PageHeader-title")
19
+
20
+ Primer::BaseComponent.new(**system_arguments)
21
+ }
22
+
23
+ # Optional description below the title row
24
+ renders_one :description, lambda { |**system_arguments|
25
+ deny_tag_argument(**system_arguments)
26
+ system_arguments[:tag] = :div
27
+ system_arguments[:classes] = class_names(system_arguments[:classes], "PageHeader-description")
28
+
29
+ Primer::BaseComponent.new(**system_arguments)
30
+ }
31
+
32
+ # Actions
33
+ #
34
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
35
+ renders_one :actions, lambda { |**system_arguments|
36
+ deny_tag_argument(**system_arguments)
37
+ system_arguments[:tag] = :div
38
+ system_arguments[:classes] = class_names(system_arguments[:classes], "PageHeader-actions")
39
+
40
+ Primer::BaseComponent.new(**system_arguments)
41
+ }
42
+
43
+ def initialize(**system_arguments)
44
+ @system_arguments = deny_tag_argument(**system_arguments)
45
+
46
+ @system_arguments[:tag] = :header
47
+ @system_arguments[:classes] =
48
+ class_names(
49
+ @system_arguments[:classes],
50
+ "PageHeader"
51
+ )
52
+ end
53
+
54
+ def render?
55
+ title?
56
+ end
57
+ end
58
+ end
59
+ end
@@ -40,3 +40,6 @@
40
40
  @import "./beta/timeline_item.pcss";
41
41
  @import "./truncate.pcss";
42
42
  @import "./alpha/action_bar.pcss";
43
+
44
+ /* OP specifics */
45
+ @import "./open_project/page_header.pcss";
@@ -21,7 +21,8 @@ module Primer
21
21
  beta: :beta,
22
22
  stable: :stable,
23
23
  deprecated: :deprecated,
24
- experimental: :experimental
24
+ experimental: :experimental,
25
+ open_project: :open_project
25
26
  }.freeze
26
27
 
27
28
  class UnknownStatusError < StandardError; end
@@ -5,7 +5,7 @@ module Primer
5
5
  module ViewComponents
6
6
  module VERSION
7
7
  MAJOR = 0
8
- MINOR = 8
8
+ MINOR = 9
9
9
  PATCH = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
@@ -0,0 +1,22 @@
1
+ <%= render(Primer::OpenProject::PageHeader.new) do |component| %>
2
+ <% component.with_title(tag: :h1) do %>
3
+ A title
4
+ <% end %>
5
+ <% component.with_description do %>
6
+ A description with actions
7
+ <% end %>
8
+ <% component.with_actions do %>
9
+ <%= render(Primer::Alpha::ActionMenu.new) do |component| %>
10
+ <% component.with_show_button { "Menu" } %>
11
+ <% component.with_item(label: "Item", tag: :button, value: "") %>
12
+ <% component.with_item(
13
+ label: "Show dialog",
14
+ tag: :button,
15
+ content_arguments: { "data-show-dialog-id": "my-dialog" },
16
+ value: "",
17
+ scheme: :danger
18
+ ) %>
19
+ <% end %>
20
+ <% end %>
21
+ <% end %>
22
+
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module OpenProject
5
+ # @component Primer::OpenProject::PageHeader
6
+ # @label Page Header
7
+ class PageHeaderPreview < ViewComponent::Preview
8
+ # @label Default
9
+ # @snapshot
10
+ def default
11
+ render(Primer::OpenProject::PageHeader.new) do |header|
12
+ header.with_title { "Hello" }
13
+ header.with_description { "Last updated 5 minutes ago by XYZ." }
14
+ end
15
+ end
16
+
17
+
18
+ # @label Playground
19
+ #
20
+ def playground
21
+ render(Primer::OpenProject::PageHeader.new) do |header|
22
+ header.with_title { "Hello" }
23
+ header.with_description { "Last updated 5 minutes ago by XYZ." }
24
+ end
25
+ end
26
+
27
+ # @label With actions
28
+ def actions
29
+ render_with_template(locals: {})
30
+ end
31
+ end
32
+ end
33
+ end
data/static/classes.json CHANGED
@@ -411,6 +411,18 @@
411
411
  "Overlay-header": [
412
412
  "Primer::Alpha::Dialog"
413
413
  ],
414
+ "PageHeader": [
415
+ "Primer::OpenProject::PageHeader"
416
+ ],
417
+ "PageHeader-actions": [
418
+ "Primer::OpenProject::PageHeader"
419
+ ],
420
+ "PageHeader-description": [
421
+ "Primer::OpenProject::PageHeader"
422
+ ],
423
+ "PageHeader-title": [
424
+ "Primer::OpenProject::PageHeader"
425
+ ],
414
426
  "Popover": [
415
427
  "Primer::Beta::Popover"
416
428
  ],
data/static/previews.json CHANGED
@@ -4432,6 +4432,53 @@
4432
4432
  }
4433
4433
  ]
4434
4434
  },
4435
+ {
4436
+ "name": "page_header",
4437
+ "component": "PageHeader",
4438
+ "status": "openproject",
4439
+ "lookup_path": "primer/open_project/page_header",
4440
+ "examples": [
4441
+ {
4442
+ "preview_path": "primer/open_project/page_header/playground",
4443
+ "name": "playground",
4444
+ "snapshot": "true",
4445
+ "skip_rules": {
4446
+ "wont_fix": [
4447
+ "region"
4448
+ ],
4449
+ "will_fix": [
4450
+ "color-contrast"
4451
+ ]
4452
+ }
4453
+ },
4454
+ {
4455
+ "preview_path": "primer/open_project/page_header/default",
4456
+ "name": "default",
4457
+ "snapshot": "true",
4458
+ "skip_rules": {
4459
+ "wont_fix": [
4460
+ "region"
4461
+ ],
4462
+ "will_fix": [
4463
+ "color-contrast"
4464
+ ]
4465
+ }
4466
+ },
4467
+ {
4468
+ "preview_path": "primer/open_project/page_header/actions",
4469
+ "name": "actions",
4470
+ "snapshot": "true",
4471
+ "skip_rules": {
4472
+ "wont_fix": [
4473
+ "region"
4474
+ ],
4475
+ "will_fix": [
4476
+ "color-contrast"
4477
+ ]
4478
+ }
4479
+ }
4480
+ ]
4481
+ },
4435
4482
  {
4436
4483
  "name": "popover",
4437
4484
  "component": "Popover",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openproject-primer_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-09-04 00:00:00.000000000 Z
12
+ date: 2023-09-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionview
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 19.6.7
48
+ version: 19.7.0
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 19.6.7
55
+ version: 19.7.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: view_component
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -746,6 +746,12 @@ files:
746
746
  - app/components/primer/layout_component.html.erb
747
747
  - app/components/primer/layout_component.rb
748
748
  - app/components/primer/navigation/tab_component.rb
749
+ - app/components/primer/open_project/page_header.css
750
+ - app/components/primer/open_project/page_header.css.json
751
+ - app/components/primer/open_project/page_header.css.map
752
+ - app/components/primer/open_project/page_header.html.erb
753
+ - app/components/primer/open_project/page_header.pcss
754
+ - app/components/primer/open_project/page_header.rb
749
755
  - app/components/primer/primer.d.ts
750
756
  - app/components/primer/primer.js
751
757
  - app/components/primer/primer.pcss
@@ -1110,6 +1116,8 @@ files:
1110
1116
  - previews/primer/forms_preview/single_text_field_form.html.erb
1111
1117
  - previews/primer/forms_preview/submit_button_form.html.erb
1112
1118
  - previews/primer/forms_preview/text_field_and_checkbox_form.html.erb
1119
+ - previews/primer/open_project/page_header_preview.rb
1120
+ - previews/primer/open_project/page_header_preview/actions.html.erb
1113
1121
  - previews/primer/url_helpers.rb
1114
1122
  - static/arguments.json
1115
1123
  - static/assets/view-components.svg