Take darker of user colors (#325)

This commit is contained in:
Ben Halpern 2018-05-16 17:29:46 -04:00 committed by GitHub
parent 75d1a89c7a
commit 909efa6fab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,10 +42,15 @@ class MessagesController < ApplicationController
username: new_message.user.username,
message: new_message.message_html,
timestamp: new_message.timestamp,
color: new_message.user.bg_color_hex,
color: darker_user_color(new_message),
}.to_json
end
def darker_user_color(new_message)
HexComparer.new([new_message.user.bg_color_hex || "#000000",
new_message.user.text_color_hex || "#000000"]).brightness(0.9)
end
def message_params
params.require(:message).permit(:message_markdown, :user_id, :chat_channel_id)
end