pulse_view_components 0.3.0 → 0.4.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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +98 -1
  3. data/README.md +26 -0
  4. data/app/assets/builds/js/pulse_view_components.js +3 -3
  5. data/app/assets/builds/js/pulse_view_components.js.map +1 -1
  6. data/app/assets/builds/pulse_view_components.css +2 -1
  7. data/app/assets/stylesheets/pulse_view_components/application.tailwind.css +44 -4
  8. data/app/assets/stylesheets/pulse_view_components/tokens.primitives.css +68 -0
  9. data/app/assets/stylesheets/pulse_view_components/tokens.system.css +95 -0
  10. data/app/components/pulse/action_list/divider.rb +13 -4
  11. data/app/components/pulse/action_list/form_wrapper.rb +2 -0
  12. data/app/components/pulse/action_list/heading.html.slim +7 -0
  13. data/app/components/pulse/action_list/heading.rb +2 -0
  14. data/app/components/pulse/action_list/item.html.slim +6 -6
  15. data/app/components/pulse/action_list/item.rb +11 -9
  16. data/app/components/pulse/action_list.css +109 -82
  17. data/app/components/pulse/action_list.html.slim +11 -0
  18. data/app/components/pulse/action_list.rb +5 -0
  19. data/app/components/pulse/badge.rb +20 -16
  20. data/app/components/pulse/base_component.rb +25 -1
  21. data/app/components/pulse/blank_slate.rb +4 -2
  22. data/app/components/pulse/border_box/header.rb +5 -3
  23. data/app/components/pulse/border_box.rb +21 -17
  24. data/app/components/pulse/box.rb +2 -0
  25. data/app/components/pulse/breadcrumb_item.rb +3 -1
  26. data/app/components/pulse/breadcrumbs.html.slim +2 -2
  27. data/app/components/pulse/breadcrumbs.rb +2 -0
  28. data/app/components/pulse/button.rb +28 -25
  29. data/app/components/pulse/component.rb +2 -1
  30. data/app/components/pulse/conditional_wrapper.rb +2 -0
  31. data/app/components/pulse/content.rb +2 -0
  32. data/app/components/pulse/counter.css +3 -3
  33. data/app/components/pulse/counter.rb +4 -0
  34. data/app/components/pulse/flash.rb +10 -6
  35. data/app/components/pulse/forms/error_explanation.html.slim +3 -3
  36. data/app/components/pulse/forms/error_explanation.rb +30 -13
  37. data/app/components/pulse/forms/error_explanation.yml +4 -0
  38. data/app/components/pulse/icon.rb +2 -0
  39. data/app/components/pulse/label.rb +5 -3
  40. data/app/components/pulse/layout.css +53 -52
  41. data/app/components/pulse/layout.rb +14 -6
  42. data/app/components/pulse/link.rb +10 -8
  43. data/app/components/pulse/modal.html.slim +20 -20
  44. data/app/components/pulse/modal.rb +10 -8
  45. data/app/components/pulse/modal_controller.js +3 -3
  46. data/app/components/pulse/nav_link.html.slim +7 -7
  47. data/app/components/pulse/nav_link.rb +4 -2
  48. data/app/components/pulse/nav_list/heading.rb +3 -1
  49. data/app/components/pulse/nav_list/item.html.slim +8 -0
  50. data/app/components/pulse/nav_list/item.rb +2 -2
  51. data/app/components/pulse/nav_list.rb +5 -0
  52. data/app/components/pulse/popover.html.slim +1 -1
  53. data/app/components/pulse/popover.rb +65 -26
  54. data/app/components/pulse/progress_bar.html.slim +2 -2
  55. data/app/components/pulse/progress_bar.rb +5 -3
  56. data/app/components/pulse/table/cell.html.slim +2 -2
  57. data/app/components/pulse/table/cell.rb +14 -10
  58. data/app/components/pulse/table/column.rb +2 -0
  59. data/app/components/pulse/table.html.slim +3 -3
  60. data/app/components/pulse/table.rb +19 -16
  61. data/app/components/pulse/text.rb +26 -24
  62. data/app/components/pulse/toast.html.slim +8 -8
  63. data/app/components/pulse/toast.rb +25 -23
  64. data/app/lib/pulse/status.rb +48 -0
  65. data/lib/pulse/view_components/version.rb +1 -1
  66. data/previews/foundations/colors_preview/palettes.html.slim +12 -0
  67. data/previews/foundations/colors_preview/semantic.html.slim +16 -0
  68. data/previews/foundations/colors_preview.rb +55 -0
  69. data/previews/pulse/action_list_preview.rb +77 -0
  70. data/previews/pulse/border_box_preview.rb +1 -1
  71. data/previews/pulse/counter_preview.rb +1 -1
  72. data/previews/pulse/flash_preview.rb +1 -1
  73. data/previews/pulse/forms/error_explanation_preview.rb +49 -0
  74. data/previews/pulse/layout_preview.rb +5 -5
  75. data/previews/pulse/nav_list_preview.rb +1 -1
  76. data/previews/pulse/popover_preview.rb +48 -22
  77. data/previews/pulse/progress_bar_preview.rb +1 -1
  78. data/previews/pulse/table_preview.rb +6 -6
  79. metadata +17 -11
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pulse
4
+ # @label ActionList (alpha)
5
+ class ActionListPreview < ViewComponent::Preview
6
+ # @label Playground
7
+ #
8
+ # @param title text
9
+ # @param subtitle text
10
+ # @param heading_level select [1, 2, 3, 4, 5, 6]
11
+ # @param show_dividers toggle
12
+ def default(title: 'Account', subtitle: nil, heading_level: 3,
13
+ show_dividers: false)
14
+ render(Pulse::ActionList.new(show_dividers:)) do |list|
15
+ list.with_heading(title:, subtitle: subtitle.presence,
16
+ heading_level: heading_level.to_i)
17
+ list.with_item(label: 'Profile', href: '#')
18
+ list.with_item(label: 'Notifications', href: '#')
19
+ list.with_item(label: 'Security', href: '#')
20
+ end
21
+ end
22
+
23
+ # @label Leading visuals
24
+ def leading_visuals
25
+ render(Pulse::ActionList.new) do |list|
26
+ list.with_item(label: 'Profile', href: '#') do |item|
27
+ item.with_leading_visual_icon(icon: :person)
28
+ end
29
+ list.with_item(label: 'Notifications', href: '#') do |item|
30
+ item.with_leading_visual_icon(icon: :bell)
31
+ end
32
+ list.with_item(label: 'Security', href: '#') do |item|
33
+ item.with_leading_visual_icon(icon: :key)
34
+ end
35
+ end
36
+ end
37
+
38
+ # @label Trailing visuals
39
+ def trailing_visuals
40
+ render(Pulse::ActionList.new) do |list|
41
+ list.with_item(label: 'Members', href: '#') do |item|
42
+ item.with_trailing_visual_counter(count: 12)
43
+ end
44
+ list.with_item(label: 'Starred', href: '#') do |item|
45
+ item.with_trailing_visual_icon(icon: :star)
46
+ end
47
+ list.with_item(label: 'Search', href: '#') do |item|
48
+ item.with_trailing_visual_text('⌘K')
49
+ end
50
+ end
51
+ end
52
+
53
+ # @label Descriptions
54
+ def descriptions
55
+ render(Pulse::ActionList.new) do |list|
56
+ list.with_item(label: 'Edit', href: '#') do |item|
57
+ item.with_leading_visual_icon(icon: :pencil)
58
+ item.with_description { 'Change the name and details' }
59
+ end
60
+ list.with_item(label: 'Archive', href: '#') do |item|
61
+ item.with_leading_visual_icon(icon: :archive)
62
+ item.with_description { 'Hide from the main list' }
63
+ end
64
+ end
65
+ end
66
+
67
+ # @label Dividers
68
+ def dividers
69
+ render(Pulse::ActionList.new) do |list|
70
+ list.with_item(label: 'Profile', href: '#')
71
+ list.with_item(label: 'Notifications', href: '#')
72
+ list.with_divider
73
+ list.with_item(label: 'Sign out', href: '#')
74
+ end
75
+ end
76
+ end
77
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pulse
4
- # @label BorderBox
4
+ # @label BorderBox (beta)
5
5
  class BorderBoxPreview < ViewComponent::Preview
6
6
  # @label Default
7
7
  def default
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pulse
4
- # @label Counter
4
+ # @label Counter (alpha)
5
5
  class CounterPreview < ViewComponent::Preview
6
6
  # @label Playground
7
7
  #
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pulse
4
- # @label Flash
4
+ # @label Flash (beta)
5
5
  class FlashPreview < ViewComponent::Preview
6
6
  # @label Playground
7
7
  #
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pulse
4
+ module Forms
5
+ # @label ErrorExplanation
6
+ class ErrorExplanationPreview < ViewComponent::Preview
7
+ # Previews ship in the gem, so they can't use a host app model.
8
+ class SampleRecord
9
+ include ActiveModel::Model
10
+
11
+ attr_accessor :title, :description
12
+
13
+ validates :title, presence: true
14
+ validates :description, length: { minimum: 20 }
15
+
16
+ def self.model_name
17
+ ActiveModel::Name.new(self, nil, 'Project')
18
+ end
19
+ end
20
+
21
+ # @label Playground
22
+ #
23
+ # The component renders nothing once both fields are valid.
24
+ #
25
+ # @param title text
26
+ # @param description text
27
+ def default(title: '', description: 'Too short')
28
+ render(Pulse::Forms::ErrorExplanation.new(
29
+ resource: invalid_record(title:, description:)
30
+ ))
31
+ end
32
+
33
+ # @label Single error
34
+ def single_error
35
+ render(Pulse::Forms::ErrorExplanation.new(
36
+ resource: invalid_record(
37
+ title: '', description: 'A description that is long enough'
38
+ )
39
+ ))
40
+ end
41
+
42
+ private
43
+
44
+ def invalid_record(**attributes)
45
+ SampleRecord.new(**attributes).tap(&:validate)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pulse
4
- # @label Layout
4
+ # @label Layout (beta)
5
5
  class LayoutPreview < ViewComponent::Preview
6
6
  # @label Playground
7
7
  # @param first_in_source [Symbol] select [sidebar, main]
@@ -10,10 +10,10 @@ module Pulse
10
10
  render(
11
11
  Pulse::Layout.new(gutter:, first_in_source:)
12
12
  ) do |component|
13
- component.with_main(classes: 'pulse-bg-blue-50') do
13
+ component.with_main(classes: 'pulse:bg-blue-50') do
14
14
  'Main content'
15
15
  end
16
- component.with_sidebar(classes: 'pulse-bg-gray-50') do
16
+ component.with_sidebar(classes: 'pulse:bg-neutral-50') do
17
17
  'Sidebar content'
18
18
  end
19
19
  end
@@ -22,10 +22,10 @@ module Pulse
22
22
  # @label Default
23
23
  def default
24
24
  render(Pulse::Layout.new) do |component|
25
- component.with_main(classes: 'pulse-bg-blue-50') do
25
+ component.with_main(classes: 'pulse:bg-blue-50') do
26
26
  'Main content'
27
27
  end
28
- component.with_sidebar(classes: 'pulse-bg-gray-50') do
28
+ component.with_sidebar(classes: 'pulse:bg-neutral-50') do
29
29
  'Sidebar content'
30
30
  end
31
31
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pulse
4
- # @label NavList
4
+ # @label NavList (alpha)
5
5
  class NavListPreview < ViewComponent::Preview
6
6
  # @label default
7
7
  def default
@@ -5,7 +5,7 @@ module Pulse
5
5
  class PopoverPreview < ViewComponent::Preview
6
6
  # @label Playground
7
7
  #
8
- # @param caret [Symbol] select [top, right, bottom, left, top_right, top_left, bottom_right, bottom_left, left_bottom, left_top, right_bottom, right_top]
8
+ # @param caret [Symbol] select {{ Pulse::Popover::CARET_OPTIONS }}
9
9
  def playground(caret: :top)
10
10
  render Pulse::Popover.new do |component|
11
11
  component.with_heading do
@@ -19,7 +19,7 @@ module Pulse
19
19
 
20
20
  # @label Default
21
21
  #
22
- # @param caret [Symbol] select [top, right, bottom, left, top_right, top_left, bottom_right, bottom_left, left_bottom, left_top, right_bottom, right_top]
22
+ # @param caret [Symbol] select {{ Pulse::Popover::CARET_OPTIONS }}
23
23
  def default(caret: :top)
24
24
  render Pulse::Popover.new do |component|
25
25
  component.with_heading do
@@ -41,37 +41,63 @@ module Pulse
41
41
  end
42
42
 
43
43
  # @!group Directions
44
- def bottom_right
45
- render Pulse::Popover.new do |component|
46
- component.with_body(caret: :bottom_right) do
47
- 'This is the Popover body.'
48
- end
49
- end
44
+ def top
45
+ popover_with_caret(:top)
46
+ end
47
+
48
+ def top_left
49
+ popover_with_caret(:top_left)
50
50
  end
51
51
 
52
52
  def top_right
53
- render Pulse::Popover.new do |component|
54
- component.with_body(caret: :top_right) do
55
- 'This is the Popover body.'
56
- end
57
- end
53
+ popover_with_caret(:top_right)
54
+ end
55
+
56
+ def bottom
57
+ popover_with_caret(:bottom)
58
58
  end
59
59
 
60
60
  def bottom_left
61
- render Pulse::Popover.new do |component|
62
- component.with_body(caret: :bottom_left) do
63
- 'This is the Popover body.'
64
- end
65
- end
61
+ popover_with_caret(:bottom_left)
66
62
  end
67
63
 
68
- def top_left
69
- render Pulse::Popover.new do |component|
70
- component.with_body(caret: :top_left) do
64
+ def bottom_right
65
+ popover_with_caret(:bottom_right)
66
+ end
67
+
68
+ def left
69
+ popover_with_caret(:left)
70
+ end
71
+
72
+ def left_top
73
+ popover_with_caret(:left_top)
74
+ end
75
+
76
+ def left_bottom
77
+ popover_with_caret(:left_bottom)
78
+ end
79
+
80
+ def right
81
+ popover_with_caret(:right)
82
+ end
83
+
84
+ def right_top
85
+ popover_with_caret(:right_top)
86
+ end
87
+
88
+ def right_bottom
89
+ popover_with_caret(:right_bottom)
90
+ end
91
+ # @!endgroup
92
+
93
+ private
94
+
95
+ def popover_with_caret(caret)
96
+ render Pulse::Popover.new(classes: 'pulse:m-8') do |component|
97
+ component.with_body(caret:) do
71
98
  'This is the Popover body.'
72
99
  end
73
100
  end
74
101
  end
75
- # @!endgroup
76
102
  end
77
103
  end
@@ -6,7 +6,7 @@ module Pulse
6
6
  # @label Playground
7
7
  #
8
8
  # @display wrapper true
9
- # @display wrapper_classes 'flex justify-center items-center p-4 bg-gray-50 h-10 w-24'
9
+ # @display wrapper_classes 'flex justify-center items-center p-4 bg-neutral-50 h-10 w-24'
10
10
  # @param percentage number
11
11
  # @param title text
12
12
  def playground(percentage: 50, title: nil)
@@ -74,7 +74,7 @@ module Pulse
74
74
  end
75
75
 
76
76
  def custom_table_classes
77
- render(Pulse::Table.new(COLLECTION, classes: 'pulse-mt-4')) do |c|
77
+ render(Pulse::Table.new(COLLECTION, classes: 'pulse:mt-4')) do |c|
78
78
  c.with_column(title: 'Column 1') do |row|
79
79
  row[:column1]
80
80
  end
@@ -89,7 +89,7 @@ module Pulse
89
89
 
90
90
  def custom_head_classes
91
91
  render(
92
- Pulse::Table.new(COLLECTION, head_classes: 'pulse-bg-secondary-100')
92
+ Pulse::Table.new(COLLECTION, head_classes: 'pulse:bg-secondary-100')
93
93
  ) do |c|
94
94
  c.with_column(title: 'Column 1') do |row|
95
95
  row[:column1]
@@ -105,7 +105,7 @@ module Pulse
105
105
 
106
106
  def custom_row_classes
107
107
  render(
108
- Pulse::Table.new(COLLECTION, row_classes: 'pulse-bg-secondary-50')
108
+ Pulse::Table.new(COLLECTION, row_classes: 'pulse:bg-secondary-50')
109
109
  ) do |c|
110
110
  c.with_column(title: 'Column 1') do |row|
111
111
  row[:column1]
@@ -124,13 +124,13 @@ module Pulse
124
124
  Pulse::Table.new(COLLECTION)
125
125
  ) do |c|
126
126
  c.with_column(title: 'Column 1',
127
- classes: 'pulse-bg-secondary-50') do |row|
127
+ classes: 'pulse:bg-secondary-50') do |row|
128
128
  row[:column1]
129
129
  end
130
- c.with_column(title: 'Column 2', classes: 'pulse-text-primary') do |row|
130
+ c.with_column(title: 'Column 2', classes: 'pulse:text-primary') do |row|
131
131
  row[:column2]
132
132
  end
133
- c.with_column(classes: 'pulse-font-bold') do |row|
133
+ c.with_column(classes: 'pulse:font-bold') do |row|
134
134
  row[:column3]
135
135
  end
136
136
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pulse_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Coyne
@@ -55,22 +55,16 @@ dependencies:
55
55
  name: tailwind_merge
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: 0.10.1
61
- - - "<"
58
+ - - "~>"
62
59
  - !ruby/object:Gem::Version
63
- version: 1.0.0
60
+ version: '1.5'
64
61
  type: :runtime
65
62
  prerelease: false
66
63
  version_requirements: !ruby/object:Gem::Requirement
67
64
  requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 0.10.1
71
- - - "<"
65
+ - - "~>"
72
66
  - !ruby/object:Gem::Version
73
- version: 1.0.0
67
+ version: '1.5'
74
68
  - !ruby/object:Gem::Dependency
75
69
  name: view_component
76
70
  requirement: !ruby/object:Gem::Requirement
@@ -220,11 +214,15 @@ files:
220
214
  - app/assets/images/pulse_view_components/icons/zap.svg
221
215
  - app/assets/javascripts/pulse_view_components.js
222
216
  - app/assets/stylesheets/pulse_view_components/application.tailwind.css
217
+ - app/assets/stylesheets/pulse_view_components/tokens.primitives.css
218
+ - app/assets/stylesheets/pulse_view_components/tokens.system.css
223
219
  - app/components/pulse/action_list.css
220
+ - app/components/pulse/action_list.html.slim
224
221
  - app/components/pulse/action_list.rb
225
222
  - app/components/pulse/action_list/divider.rb
226
223
  - app/components/pulse/action_list/form_wrapper.html.slim
227
224
  - app/components/pulse/action_list/form_wrapper.rb
225
+ - app/components/pulse/action_list/heading.html.slim
228
226
  - app/components/pulse/action_list/heading.rb
229
227
  - app/components/pulse/action_list/item.html.slim
230
228
  - app/components/pulse/action_list/item.rb
@@ -251,6 +249,7 @@ files:
251
249
  - app/components/pulse/flash.rb
252
250
  - app/components/pulse/forms/error_explanation.html.slim
253
251
  - app/components/pulse/forms/error_explanation.rb
252
+ - app/components/pulse/forms/error_explanation.yml
254
253
  - app/components/pulse/icon.rb
255
254
  - app/components/pulse/label.html.slim
256
255
  - app/components/pulse/label.rb
@@ -270,6 +269,7 @@ files:
270
269
  - app/components/pulse/nav_list/group.html.slim
271
270
  - app/components/pulse/nav_list/group.rb
272
271
  - app/components/pulse/nav_list/heading.rb
272
+ - app/components/pulse/nav_list/item.html.slim
273
273
  - app/components/pulse/nav_list/item.rb
274
274
  - app/components/pulse/popover.html.slim
275
275
  - app/components/pulse/popover.rb
@@ -291,12 +291,17 @@ files:
291
291
  - app/javascript/pulse_view_components/application.js
292
292
  - app/lib/pulse/attributes_helper.rb
293
293
  - app/lib/pulse/fetch_or_fallback_helper.rb
294
+ - app/lib/pulse/status.rb
294
295
  - app/lib/pulse/svg_helper.rb
295
296
  - lib/pulse/view_components.rb
296
297
  - lib/pulse/view_components/engine.rb
297
298
  - lib/pulse/view_components/version.rb
298
299
  - lib/pulse_view_components.rb
299
300
  - lib/tasks/pulse_view_components_tasks.rake
301
+ - previews/foundations/colors_preview.rb
302
+ - previews/foundations/colors_preview/palettes.html.slim
303
+ - previews/foundations/colors_preview/semantic.html.slim
304
+ - previews/pulse/action_list_preview.rb
300
305
  - previews/pulse/badge_preview.rb
301
306
  - previews/pulse/blank_slate_preview.rb
302
307
  - previews/pulse/border_box_preview.rb
@@ -304,6 +309,7 @@ files:
304
309
  - previews/pulse/button_preview.rb
305
310
  - previews/pulse/counter_preview.rb
306
311
  - previews/pulse/flash_preview.rb
312
+ - previews/pulse/forms/error_explanation_preview.rb
307
313
  - previews/pulse/icon_preview.rb
308
314
  - previews/pulse/label_preview.rb
309
315
  - previews/pulse/layout_preview.rb