Build chat message styles on the controller side (allowing for extra parameters).

This commit is contained in:
Paulo Reis 2017-12-13 12:16:21 +00:00
parent 9deddcf2a8
commit ca68f01a9d
2 changed files with 10 additions and 6 deletions

View file

@ -35,12 +35,9 @@ aside.chat(
span(ng-if="message.user.first_name") {{ message.user.first_name }}
span(ng-if="!message.user.first_name") {{ message.user.email }}
.message(
ng-style="{\
'border-color': 'hsl({{ hue(message.user) }}, 70%, 70%)',\
'background-color': 'hsl({{ hue(message.user) }}, 60%, 97%)'\
}"
ng-style="getMessageStyle(message.user);"
)
.arrow(ng-style="{'border-color': 'hsl({{ hue(message.user) }}, 70%, 70%)'}")
.arrow(ng-style="getArrowStyle(message.user)")
.message-content
p(
mathjax,

View file

@ -3,9 +3,16 @@ define [
"ide/colors/ColorManager"
], (App, ColorManager) ->
App.controller "ChatMessageController", ["$scope", "ide", ($scope, ide) ->
$scope.hue = (user) ->
hue = (user) ->
if !user?
return 0
else
return ColorManager.getHueForUserId(user.id)
$scope.getMessageStyle = (user) ->
"border-color" : "hsl(#{ hue(user) }, 70%, 70%)"
"background-color" : "hsl(#{ hue(user) }, 60%, 97%)"
$scope.getArrowStyle = (user) ->
"border-color" : "hsl(#{ hue(user) }, 70%, 70%)"
]