openproject-primer_view_components 0.94.0 → 0.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ .ColorSwatch--indicator{border:var(--borderWidth-thin) solid var(--borderColor-default);border-radius:var(--borderRadius-small);height:var(--base-size-12);width:var(--base-size-12)}
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "open_project/color_swatch",
3
+ "selectors": [
4
+ ".ColorSwatch--indicator"
5
+ ]
6
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["color_swatch.pcss"],"names":[],"mappings":"AAEA,wBACE,+DAAgE,CAChE,uCAAwC,CACxC,0BAA2B,CAC3B,yBACF","file":"color_swatch.css","sourcesContent":["/* CSS for ColorSwatch */\n\n.ColorSwatch--indicator {\n border: var(--borderWidth-thin) solid var(--borderColor-default);\n border-radius: var(--borderRadius-small);\n height: var(--base-size-12);\n width: var(--base-size-12);\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /* CSS for ColorSwatch */
2
+
3
+ .ColorSwatch--indicator {
4
+ border: var(--borderWidth-thin) solid var(--borderColor-default);
5
+ border-radius: var(--borderRadius-small);
6
+ height: var(--base-size-12);
7
+ width: var(--base-size-12);
8
+ }
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module OpenProject
5
+ # Displays a small colored indicator for a given hex color code, optionally
6
+ # showing the hex value next to it.
7
+ class ColorSwatch < Primer::Component
8
+ status :open_project
9
+
10
+ # @param hexcode [String] The hex color code to display, e.g. `#FF0000`.
11
+ # @param show_value [Boolean] Whether to display the hex value next to the swatch.
12
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
13
+ def initialize(hexcode:, show_value: false, **system_arguments)
14
+ @hexcode = hexcode
15
+ @show_value = show_value
16
+ @system_arguments = system_arguments
17
+ @system_arguments[:align_items] ||= :center
18
+
19
+ @system_arguments[:classes] = class_names(
20
+ @system_arguments[:classes],
21
+ "ColorSwatch"
22
+ )
23
+ end
24
+
25
+ def call
26
+ render(Primer::OpenProject::FlexLayout.new(**@system_arguments)) do |flex|
27
+ flex.with_column do
28
+ render(Primer::BaseComponent.new(**swatch_arguments))
29
+ end
30
+
31
+ if show_value?
32
+ flex.with_column do
33
+ render(Primer::Beta::Text.new(tag: :span, ml: 2)) { hexcode }
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ attr_reader :hexcode
42
+
43
+ def show_value?
44
+ @show_value
45
+ end
46
+
47
+ def swatch_arguments
48
+ {
49
+ tag: :div,
50
+ classes: "ColorSwatch--indicator",
51
+ aria: { hidden: true },
52
+ style: "background-color: #{hexcode}"
53
+ }
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1 @@
1
+ .InsetBox--title-container{display:flex;align-items:center;gap:var(--base-size-8);margin-bottom:var(--base-size-8)}.InsetBox--body{display:grid;grid-template-areas:"content clip_board_copy" "actions actions";grid-template-columns:1fr auto;grid-template-rows:auto auto auto;align-items:center}.InsetBox--body--clip_board_copy{align-self:flex-start}.InsetBox--actions{gap:var(--base-size-8)}
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "open_project/inset_box",
3
+ "selectors": [
4
+ ".InsetBox--title-container",
5
+ ".InsetBox--body",
6
+ ".InsetBox--body--clip_board_copy",
7
+ ".InsetBox--actions"
8
+ ]
9
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["inset_box.pcss"],"names":[],"mappings":"AAEA,2BACE,YAAa,CACb,kBAAmB,CACnB,sBAAuB,CACvB,gCACF,CAEA,gBACE,YAAa,CACb,+DAAgE,CAChE,8BAA+B,CAC/B,iCAAkC,CAClC,kBACF,CAEA,iCACE,qBACF,CAEA,mBACE,sBACF","file":"inset_box.css","sourcesContent":["/* CSS for InsetBox */\n\n.InsetBox--title-container {\n display: flex;\n align-items: center;\n gap: var(--base-size-8);\n margin-bottom: var(--base-size-8);\n}\n\n.InsetBox--body {\n display: grid;\n grid-template-areas: \"content clip_board_copy\" \"actions actions\";\n grid-template-columns: 1fr auto;\n grid-template-rows: auto auto auto;\n align-items: center;\n}\n\n.InsetBox--body--clip_board_copy {\n align-self: flex-start;\n}\n\n.InsetBox--actions {\n gap: var(--base-size-8);\n}\n"]}
@@ -0,0 +1,46 @@
1
+ <%= render(
2
+ Primer::Box.new(
3
+ border: @border,
4
+ border_radius: 2,
5
+ p: 3,
6
+ **@scheme_arguments,
7
+ **@system_arguments
8
+ )
9
+ ) do %>
10
+ <% if title? || title_icon? %>
11
+ <div class="InsetBox--title-container">
12
+ <%= title_icon %>
13
+ <%= title %>
14
+ </div>
15
+ <% end %>
16
+
17
+ <%= render(Primer::OpenProject::GridLayout.new(css_class: "InsetBox--body", tag: :div)) do |grid| %>
18
+ <% if clipboard_copy_button?
19
+ grid.with_area(:clip_board_copy) do
20
+ render(clipboard_copy_button)
21
+ end
22
+ end %>
23
+
24
+ <% grid.with_area(:content, overflow: :hidden) do
25
+ content
26
+ end %>
27
+
28
+ <% if actions.any? %>
29
+ <% grid.with_area(:actions) do %>
30
+ <%= render(
31
+ Primer::Box.new(
32
+ display: :flex,
33
+ align_items: :center,
34
+ flex_wrap: :wrap,
35
+ mt: 2,
36
+ classes: "InsetBox--actions"
37
+ )
38
+ ) do %>
39
+ <% actions.each do |action| %>
40
+ <%= action %>
41
+ <% end %>
42
+ <% end %>
43
+ <% end %>
44
+ <% end %>
45
+ <% end %>
46
+ <% end %>
@@ -0,0 +1,24 @@
1
+ /* CSS for InsetBox */
2
+
3
+ .InsetBox--title-container {
4
+ display: flex;
5
+ align-items: center;
6
+ gap: var(--base-size-8);
7
+ margin-bottom: var(--base-size-8);
8
+ }
9
+
10
+ .InsetBox--body {
11
+ display: grid;
12
+ grid-template-areas: "content clip_board_copy" "actions actions";
13
+ grid-template-columns: 1fr auto;
14
+ grid-template-rows: auto auto auto;
15
+ align-items: center;
16
+ }
17
+
18
+ .InsetBox--body--clip_board_copy {
19
+ align-self: flex-start;
20
+ }
21
+
22
+ .InsetBox--actions {
23
+ gap: var(--base-size-8);
24
+ }
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module OpenProject
5
+ # A box with an inset background, used to call out a piece of content such
6
+ # as a tip, a warning, or a code snippet, optionally with a title, icon and actions.
7
+ class InsetBox < Primer::Component
8
+ status :open_project
9
+
10
+ DEFAULT_SCHEME = :default
11
+ SCHEME_MAPPINGS = {
12
+ DEFAULT_SCHEME => { bg: :inset },
13
+ info: { bg: :accent, border_color: :accent },
14
+ warning: { bg: :attention, border_color: :attention },
15
+ danger: { bg: :danger, border_color: :danger },
16
+ success: { bg: :success, border_color: :success }
17
+ }.freeze
18
+
19
+ attr_reader :border, :scheme_arguments, :system_arguments
20
+
21
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
22
+ renders_one :title_icon, Primer::Beta::Octicon
23
+
24
+ # @param tag [Symbol] <%= one_of(Primer::Beta::Heading::TAG_OPTIONS) %>
25
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
26
+ renders_one :title, lambda { |tag: :h3, **system_arguments|
27
+ Primer::Beta::Heading.new(tag: tag, font_size: 5, font_weight: :semibold, **system_arguments)
28
+ }
29
+
30
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
31
+ renders_many :actions, types: {
32
+ button: lambda { |**system_arguments|
33
+ Primer::Beta::Button.new(**system_arguments)
34
+ },
35
+ menu: lambda { |**system_arguments|
36
+ Primer::Alpha::ActionMenu.new(**system_arguments)
37
+ }
38
+ }
39
+
40
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
41
+ renders_one :clipboard_copy_button, lambda { |**system_arguments|
42
+ system_arguments[:scheme] ||= :invisible
43
+ system_arguments[:size] = :small
44
+ system_arguments[:ml] = 2
45
+ Primer::Beta::ClipboardCopyButton.new(**system_arguments)
46
+ }
47
+
48
+ # @param border [Boolean] Whether to render a border around the box.
49
+ # @param scheme [Symbol] <%= one_of(Primer::OpenProject::InsetBox::SCHEME_MAPPINGS.keys) %>
50
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
51
+ def initialize(border: true, scheme: DEFAULT_SCHEME, **system_arguments)
52
+ @border = border
53
+ @scheme_arguments = SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)]
54
+ @system_arguments = system_arguments
55
+
56
+ @system_arguments[:classes] = class_names(
57
+ @system_arguments[:classes],
58
+ "InsetBox"
59
+ )
60
+ end
61
+ end
62
+ end
63
+ end
@@ -58,3 +58,5 @@
58
58
  @import "./open_project/collapsible_section.pcss";
59
59
  @import "./open_project/pagination.pcss";
60
60
  @import "./open_project/filterable_tree_view.pcss";
61
+ @import "./open_project/color_swatch.pcss";
62
+ @import "./open_project/inset_box.pcss";
@@ -5,7 +5,7 @@ module Primer
5
5
  module ViewComponents
6
6
  module VERSION
7
7
  MAJOR = 0
8
- MINOR = 94
8
+ MINOR = 95
9
9
  PATCH = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module OpenProject
5
+ # @label ColorSwatch
6
+ class ColorSwatchPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ # @param hexcode [String] text
9
+ # @param show_value [Boolean] toggle
10
+ def playground(hexcode: "#CC0000", show_value: false)
11
+ render(Primer::OpenProject::ColorSwatch.new(hexcode: hexcode, show_value: show_value))
12
+ end
13
+
14
+ # @label Default
15
+ # @snapshot
16
+ def default
17
+ render(Primer::OpenProject::ColorSwatch.new(hexcode: "#CC0000"))
18
+ end
19
+
20
+ # @label With value
21
+ # @snapshot
22
+ def with_value
23
+ render(Primer::OpenProject::ColorSwatch.new(hexcode: "#CC0000", show_value: true))
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module OpenProject
5
+ # @label InsetBox
6
+ class InsetBoxPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ # @param border [Boolean] toggle
9
+ # @param scheme [Symbol] select [default, info, warning, danger, success]
10
+ # @param show_title [Boolean] toggle
11
+ # @param show_icon [Boolean] toggle
12
+ # @param show_actions [Boolean] toggle
13
+ # @param show_clipboard_copy_button [Boolean] toggle
14
+ def playground(border: true, scheme: :default, show_title: true, show_icon: false, show_actions: false, show_clipboard_copy_button: false)
15
+ render(Primer::OpenProject::InsetBox.new(border: border, scheme: scheme)) do |component|
16
+ component.with_title_icon(icon: :info) if show_icon
17
+ component.with_title { "Title" } if show_title
18
+ component.with_clipboard_copy_button(value: "Copyable value", "aria-label": "Copy value") if show_clipboard_copy_button
19
+
20
+ component.with_action_button(scheme: :default) { "Action" } if show_actions
21
+
22
+ "This is the content of the inset box."
23
+ end
24
+ end
25
+
26
+ # @label Default
27
+ # @snapshot
28
+ def default
29
+ render(Primer::OpenProject::InsetBox.new) do |component|
30
+ component.with_title { "Title" }
31
+ "This is the content of the inset box."
32
+ end
33
+ end
34
+
35
+ # @label With scheme
36
+ # @snapshot
37
+ def with_scheme
38
+ render(Primer::OpenProject::InsetBox.new(scheme: :warning)) do |component|
39
+ component.with_title { "Watch out" }
40
+ "This is a warning message."
41
+ end
42
+ end
43
+
44
+ # @label With icon
45
+ # @snapshot
46
+ def with_icon
47
+ render(Primer::OpenProject::InsetBox.new) do |component|
48
+ component.with_title_icon(icon: :info)
49
+ component.with_title { "Title" }
50
+ "This is the content of the inset box."
51
+ end
52
+ end
53
+
54
+ # @label With clipboard copy button
55
+ # @snapshot
56
+ def with_clipboard_copy_button
57
+ render(Primer::OpenProject::InsetBox.new) do |component|
58
+ component.with_title { "Title" }
59
+ component.with_clipboard_copy_button(value: "Copyable value", "aria-label": "Copy value")
60
+ "This is the content of the inset box."
61
+ end
62
+ end
63
+
64
+ # @label With actions
65
+ # @snapshot
66
+ def with_actions
67
+ render(Primer::OpenProject::InsetBox.new) do |component|
68
+ component.with_title { "Title" }
69
+ component.with_action_button(scheme: :default) { "Edit" }
70
+ component.with_action_button(scheme: :danger) { "Delete" }
71
+ "This is the content of the inset box."
72
+ end
73
+ end
74
+
75
+ # @label Without border
76
+ # @snapshot
77
+ def without_border
78
+ render(Primer::OpenProject::InsetBox.new(border: false)) do |component|
79
+ component.with_title { "Title" }
80
+ "This is the content of the inset box."
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -6127,6 +6127,34 @@
6127
6127
  }
6128
6128
  ]
6129
6129
  },
6130
+ {
6131
+ "component": "OpenProject::ColorSwatch",
6132
+ "status": "open_project",
6133
+ "a11y_reviewed": false,
6134
+ "short_name": "OpenProjectColorSwatch",
6135
+ "source": "https://github.com/primer/view_components/tree/main/app/components/primer/open_project/color_swatch.rb",
6136
+ "lookbook": "https://primer.style/view-components/lookbook/inspect/primer/open_project/color_swatch/default/",
6137
+ "parameters": [
6138
+ {
6139
+ "name": "hexcode",
6140
+ "type": "String",
6141
+ "default": "N/A",
6142
+ "description": "The hex color code to display, e.g. `#FF0000`."
6143
+ },
6144
+ {
6145
+ "name": "show_value",
6146
+ "type": "Boolean",
6147
+ "default": "`false`",
6148
+ "description": "Whether to display the hex value next to the swatch."
6149
+ },
6150
+ {
6151
+ "name": "system_arguments",
6152
+ "type": "Hash",
6153
+ "default": "N/A",
6154
+ "description": "[System arguments](/system-arguments)"
6155
+ }
6156
+ ]
6157
+ },
6130
6158
  {
6131
6159
  "component": "OpenProject::DangerDialog",
6132
6160
  "status": "open_project",
@@ -6543,6 +6571,34 @@
6543
6571
  }
6544
6572
  ]
6545
6573
  },
6574
+ {
6575
+ "component": "OpenProject::InsetBox",
6576
+ "status": "open_project",
6577
+ "a11y_reviewed": false,
6578
+ "short_name": "OpenProjectInsetBox",
6579
+ "source": "https://github.com/primer/view_components/tree/main/app/components/primer/open_project/inset_box.rb",
6580
+ "lookbook": "https://primer.style/view-components/lookbook/inspect/primer/open_project/inset_box/default/",
6581
+ "parameters": [
6582
+ {
6583
+ "name": "border",
6584
+ "type": "Boolean",
6585
+ "default": "`true`",
6586
+ "description": "Whether to render a border around the box."
6587
+ },
6588
+ {
6589
+ "name": "scheme",
6590
+ "type": "Symbol",
6591
+ "default": "`:default`",
6592
+ "description": "One of `:danger`, `:default`, `:info`, `:success`, or `:warning`."
6593
+ },
6594
+ {
6595
+ "name": "system_arguments",
6596
+ "type": "Hash",
6597
+ "default": "N/A",
6598
+ "description": "[System arguments](/system-arguments)"
6599
+ }
6600
+ ]
6601
+ },
6546
6602
  {
6547
6603
  "component": "OpenProject::PageHeader",
6548
6604
  "status": "open_project",
@@ -147,6 +147,7 @@
147
147
  "Primer::OpenProject::BorderGrid::Cell": "",
148
148
  "Primer::OpenProject::CollapsibleSection": "",
149
149
  "Primer::OpenProject::ColorField": "",
150
+ "Primer::OpenProject::ColorSwatch": "",
150
151
  "Primer::OpenProject::DangerDialog": "",
151
152
  "Primer::OpenProject::DangerDialog::ConfirmationCheckBox": "",
152
153
  "Primer::OpenProject::DangerDialog::FormWrapper": "",
@@ -163,6 +164,7 @@
163
164
  "Primer::OpenProject::Heading": "",
164
165
  "Primer::OpenProject::InlineMessage": "",
165
166
  "Primer::OpenProject::InputGroup": "",
167
+ "Primer::OpenProject::InsetBox": "",
166
168
  "Primer::OpenProject::PageHeader": "",
167
169
  "Primer::OpenProject::PageHeader::Dialog": "",
168
170
  "Primer::OpenProject::PageHeader::Menu": "",
data/static/classes.json CHANGED
@@ -268,6 +268,9 @@
268
268
  "ColorField": [
269
269
  "Primer::OpenProject::ColorField"
270
270
  ],
271
+ "ColorSwatch--indicator": [
272
+ "Primer::OpenProject::ColorSwatch"
273
+ ],
271
274
  "Counter": [
272
275
  "Primer::Beta::Counter"
273
276
  ],
@@ -388,6 +391,18 @@
388
391
  "InputGroup": [
389
392
  "Primer::OpenProject::InputGroup"
390
393
  ],
394
+ "InsetBox--actions": [
395
+ "Primer::OpenProject::InsetBox"
396
+ ],
397
+ "InsetBox--body": [
398
+ "Primer::OpenProject::InsetBox"
399
+ ],
400
+ "InsetBox--body--clip_board_copy": [
401
+ "Primer::OpenProject::InsetBox"
402
+ ],
403
+ "InsetBox--title-container": [
404
+ "Primer::OpenProject::InsetBox"
405
+ ],
391
406
  "Label": [
392
407
  "Primer::Beta::Label"
393
408
  ],
@@ -126,6 +126,7 @@ module.exports = new Set([
126
126
  'ColorField-picker',
127
127
  'ColorField-swatch',
128
128
  'ColorField-wrap',
129
+ 'ColorSwatch--indicator',
129
130
  'Counter',
130
131
  'Counter--primary',
131
132
  'Counter--secondary',
@@ -196,6 +197,10 @@ module.exports = new Set([
196
197
  'InputGroup-input-width--xlarge',
197
198
  'InputGroup-input-width--xsmall',
198
199
  'InputGroup-input-width--xxlarge',
200
+ 'InsetBox--actions',
201
+ 'InsetBox--body',
202
+ 'InsetBox--body--clip_board_copy',
203
+ 'InsetBox--title-container',
199
204
  'Label',
200
205
  'Label--accent',
201
206
  'Label--attention',
data/static/classnames.js CHANGED
@@ -126,6 +126,7 @@ const classNames = new Set([
126
126
  'ColorField-picker',
127
127
  'ColorField-swatch',
128
128
  'ColorField-wrap',
129
+ 'ColorSwatch--indicator',
129
130
  'Counter',
130
131
  'Counter--primary',
131
132
  'Counter--secondary',
@@ -196,6 +197,10 @@ const classNames = new Set([
196
197
  'InputGroup-input-width--xlarge',
197
198
  'InputGroup-input-width--xsmall',
198
199
  'InputGroup-input-width--xxlarge',
200
+ 'InsetBox--actions',
201
+ 'InsetBox--body',
202
+ 'InsetBox--body--clip_board_copy',
203
+ 'InsetBox--title-container',
199
204
  'Label',
200
205
  'Label--accent',
201
206
  'Label--attention',
@@ -1767,6 +1767,9 @@
1767
1767
  "Primer::OpenProject::ColorField": {
1768
1768
  "GeneratedSlotMethods": "Primer::OpenProject::ColorField::GeneratedSlotMethods"
1769
1769
  },
1770
+ "Primer::OpenProject::ColorSwatch": {
1771
+ "GeneratedSlotMethods": "Primer::OpenProject::ColorSwatch::GeneratedSlotMethods"
1772
+ },
1770
1773
  "Primer::OpenProject::DangerDialog": {
1771
1774
  "ConfirmationCheckBox": "Primer::OpenProject::DangerDialog::ConfirmationCheckBox",
1772
1775
  "FormWrapper": "Primer::OpenProject::DangerDialog::FormWrapper",
@@ -1900,6 +1903,31 @@
1900
1903
  "xxlarge"
1901
1904
  ]
1902
1905
  },
1906
+ "Primer::OpenProject::InsetBox": {
1907
+ "DEFAULT_SCHEME": "default",
1908
+ "GeneratedSlotMethods": "Primer::OpenProject::InsetBox::GeneratedSlotMethods",
1909
+ "SCHEME_MAPPINGS": {
1910
+ "default": {
1911
+ "bg": "inset"
1912
+ },
1913
+ "info": {
1914
+ "bg": "accent",
1915
+ "border_color": "accent"
1916
+ },
1917
+ "warning": {
1918
+ "bg": "attention",
1919
+ "border_color": "attention"
1920
+ },
1921
+ "danger": {
1922
+ "bg": "danger",
1923
+ "border_color": "danger"
1924
+ },
1925
+ "success": {
1926
+ "bg": "success",
1927
+ "border_color": "success"
1928
+ }
1929
+ }
1930
+ },
1903
1931
  "Primer::OpenProject::PageHeader": {
1904
1932
  "BACK_BUTTON_ICON_OPTIONS": [
1905
1933
  "arrow-left",