satis 2.1.4 → 2.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e26b602df93c17a3366b1e9accf81411659f3b9447183f3b5c8649aa432a6ca4
4
- data.tar.gz: 7215147b9fe4b0a6e566ffbf883d2bf715c68c449e4c3da5a5fdfee876e7a956
3
+ metadata.gz: ab24a057287e49bf11f24ca8f304df57020c3904a79160fa8b4a625e55380d5a
4
+ data.tar.gz: bdd35c925b3c002640195b642cd652719f24931b27fe4915f528d9800b27fb24
5
5
  SHA512:
6
- metadata.gz: 962845e850d1d1311902e45edfea4b349e7b0bdc233cabda73fcb477b5d24321ddddd6d52156d3187a053f5cd4cdd003be176ac373da73d99898c27f22e7c493
7
- data.tar.gz: 617295f950f9891e74a8c96f5212e3edac351cc488b167479bb4e2ee1d37097f4e2d675825d6f6b4c59a513d86e664d4ee5e1be666741c27478587a0f0e4d03e
6
+ metadata.gz: db13c90b7bf3e47ada1d6ee10d386c6bb135a183b4bb0f365f12fc42205dd25000e9da2210e8c5ea5e6245aafaf877584c2bec618144e9445b9eee44d98a072f
7
+ data.tar.gz: 729675b75520efe3b592af046c999dda0a59a58d55f25f80647f96bc28ce4debe2499918cb3719be2e39978fab353df24dd3e249ecad73886f5a854baf1a0b3d
@@ -1,4 +1,4 @@
1
- button.inline-flex.items-center.justify-center.rounded-full.bg-gray-500.focus:outline-none.focus:ring-2.focus:ring-offset-2.focus:ring-primary-500 aria-expanded="false" aria-haspopup="true" type="button" class=options[:class]
1
+ button.inline-flex.items-center.justify-center.rounded-full.focus:outline-none.focus:ring-2.focus:ring-offset-2.focus:ring-primary-500 aria-expanded="false" aria-haspopup="true" type="button" class=options[:class] style="background-color: #{background_color}"
2
2
  - if photo&.attached?
3
3
  img class="rounded-full" src=photo_url alt=name class=options[:class]
4
4
  - elsif gravatar?
@@ -4,7 +4,7 @@ require 'net/http'
4
4
  module Satis
5
5
  module Avatar
6
6
  class Component < Satis::ApplicationComponent
7
- attr_reader :name, :photo, :email, :options
7
+ attr_reader :name, :photo, :email, :options, :color
8
8
 
9
9
  def initialize(name: nil, email: nil, photo: nil, **options)
10
10
  super
@@ -13,6 +13,8 @@ module Satis
13
13
  @options = options
14
14
  @options[:class] ||= 'w-8 h-8'
15
15
  @email = email
16
+ @background_color = "#6b7280"
17
+ @color = options.fetch(:color, true)
16
18
  end
17
19
 
18
20
  def initials
@@ -23,10 +25,16 @@ module Satis
23
25
  end
24
26
  end
25
27
 
28
+ # Returns the hex-background color for the avatar based on the name or email
29
+ def background_color
30
+ return unless name || email || color
31
+
32
+ @background_color = "##{Digest::MD5.hexdigest(name || email).first(6)}"
33
+ end
34
+
26
35
  def photo_url
27
36
  return unless photo&.attached?
28
37
 
29
- #helpers.main_app.url_for(photo)
30
38
  Rails.application.routes.url_helpers.rails_blob_path(photo, only_path: true)
31
39
  end
32
40
 
data/lib/satis/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Satis
2
- VERSION = "2.1.4"
2
+ VERSION = "2.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: satis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
11
+ date: 2024-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: browser