web47core 3.2.18 → 3.2.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e3d66a8c4889df2b3571702451b3a844cb267ea6577a140d98680bf12c1aa81
4
- data.tar.gz: 284fe80579952bd6584507b5935204f47de160137c9b9b6ca753a3bb62ff5ba3
3
+ metadata.gz: 295c70f1220ae3e566fc003d76204e5baefdaee83abef6fc9b43cccc9de93e12
4
+ data.tar.gz: aafcd956bedf3d1f032ef4f00115c8eae0d195306de03185c8b8cdff77a586d3
5
5
  SHA512:
6
- metadata.gz: 7dda1c0e1051215dc7e0a8cef71368a6bd98c404e00ce61e2d8cc28038343a527b87b09be809203ab484c921623e7c391c6963e91d345d5f34659bd34b4a03f9
7
- data.tar.gz: 6d00901a3c2d590185af382473187b08d9018e7e853d5af370f2278cbef5a4669f73532e92e6cdb1378bc4d5c79891ce3f063425cf19167f9cc46f5d1701bc78
6
+ metadata.gz: 40028db7e156aa29352a048236834661b6b527fe8e4bc0efccdc2add5ccc42ad92551eef6d9ff6a6d02ffdc31840c8b207e21fac789d61a007fa68a64fb7290b
7
+ data.tar.gz: e9f1098e8fb8689a472c17fe81e83129554a3e2abd825330c3d0cf6ee9ced2ca998ac567869db4595120ac625624711d6e66d16123fd064712d5524673229d40
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Render avatar based on a user's profile
4
+ module CoreAvatarHelper
5
+ # @abstract Render an avatar div based on the user
6
+ def user_avatar(user, size: 'sm', bg_color: 'info')
7
+ content_tag(:div, class: "avatar avatar-#{size} me-2") do
8
+ if user.avatar.present?
9
+ concat(content_tag(:img, src: "/assets/img/avatars/#{user.avatar}.png", class: 'rounded-circle') {})
10
+ else
11
+ concat(content_tag(:span, class: "avatar-initial rounded-circle bg-label-#{bg_color}") { user.initials })
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Helper methods for rendering the flash information received from the server and displaying it as toast messages
4
+ module CoreFlashToasterHelper
5
+ # @abstract render the whole toast container if there are toast messages to render
6
+ # @return HTML - To render in the page
7
+ def toast_container
8
+ return if flash.blank?
9
+
10
+ content_tag(:div, class: 'toast-container position-fixed top-0 start-50 translate-middle-x mt-5') do
11
+ flash.each { |key, value| concat(toast_flash_message(key, value)) unless 'timedout'.eql?(key) }
12
+ end
13
+ end
14
+
15
+ def toast_flash_message(key, value)
16
+ content_tag(:div, class: 'toast', role: :alert, aria: { live: :assertive, atomic: true }) do
17
+ concat(toast_flash_header(key))
18
+ concat(content_tag(:div, class: 'toast-body') { value })
19
+ end
20
+ end
21
+
22
+ def toast_flash_header(key)
23
+ content_tag(:div, class: 'toast-header') do
24
+ concat(content_tag(:i, class: [toast_flash_icon(key), 'me-2', toast_flash_color(key)].join(' ')) {})
25
+ concat(content_tag(:div, style: ['me-auto', 'fw-medium', toast_flash_color(key)].join(' ')) { key.humanize })
26
+ concat(tag(:button,
27
+ class: 'btn-close',
28
+ type: :button,
29
+ data: { 'bs-dismiss': :toast },
30
+ aria: { label: 'Close' }))
31
+ end
32
+ end
33
+
34
+ # @abstract map the flash key to an icon
35
+ # @return String - name of the icon to render
36
+ def toast_flash_color(key)
37
+ case key.downcase
38
+ when 'alert', 'error'
39
+ 'text-danger'
40
+ when 'warning'
41
+ 'text-warning'
42
+ else
43
+ 'text-info'
44
+ end
45
+ end
46
+
47
+ # @abstract map the flash key to a color scheme
48
+ # @return String - color mapped to the flash message type
49
+ def toast_flash_icon(key)
50
+ case key
51
+ when 'alert', 'error'
52
+ 'ri-alert-fill'
53
+ when 'warning'
54
+ 'ri-error-warning-fill'
55
+ else
56
+ 'ri-information-fill'
57
+ end
58
+ end
59
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Web47core
4
- VERSION = '3.2.18'
4
+ VERSION = '3.2.19'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web47core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.18
4
+ version: 3.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schroeder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-19 00:00:00.000000000 Z
11
+ date: 2025-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -564,9 +564,11 @@ files:
564
564
  - app/controllers/exceptions_controller.rb
565
565
  - app/controllers/notifications_controller.rb
566
566
  - app/controllers/status_controller.rb
567
+ - app/helpers/core_avatar_helper.rb
567
568
  - app/helpers/core_breadcrumb_helper.rb
568
569
  - app/helpers/core_card_nav_items_helper.rb
569
570
  - app/helpers/core_dropdown_helper.rb
571
+ - app/helpers/core_flash_toast_helper.rb
570
572
  - app/helpers/core_floating_action_button_helper.rb
571
573
  - app/helpers/core_form_helper.rb
572
574
  - app/helpers/core_helper.rb