apply color categories to sender profile name
This commit is contained in:
parent
2a264f36b7
commit
f2efbc15f4
5 changed files with 63 additions and 21 deletions
|
@ -13,3 +13,41 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
.mx_SenderProfile_name {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_SenderProfile_color1 {
|
||||||
|
color: #1e7ddc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_SenderProfile_color2 {
|
||||||
|
color: #a756a8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_SenderProfile_color3 {
|
||||||
|
color: #7ac9a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_SenderProfile_color4 {
|
||||||
|
color: #f2809d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_SenderProfile_color5 {
|
||||||
|
color: #ffc666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_SenderProfile_color6 {
|
||||||
|
color: #76ddd7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_SenderProfile_color7 {
|
||||||
|
color: #45529b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_SenderProfile_color8 {
|
||||||
|
color: #bfd251;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,11 +55,6 @@ limitations under the License.
|
||||||
line-height: 22px;
|
line-height: 22px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_EventTile .mx_SenderProfile .mx_SenderProfile_name,
|
|
||||||
.mx_EventTile .mx_SenderProfile .mx_SenderProfile_aux {
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mx_EventTile .mx_SenderProfile .mx_Flair {
|
.mx_EventTile .mx_SenderProfile .mx_Flair {
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
|
|
|
@ -15,21 +15,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import SdkConfig from './SdkConfig';
|
import SdkConfig from './SdkConfig';
|
||||||
|
import {hashCode} from './utils/FormattingUtils';
|
||||||
function hashCode(str) {
|
|
||||||
let hash = 0;
|
|
||||||
let i;
|
|
||||||
let chr;
|
|
||||||
if (str.length === 0) {
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
for (i = 0; i < str.length; i++) {
|
|
||||||
chr = str.charCodeAt(i);
|
|
||||||
hash = ((hash << 5) - hash) + chr;
|
|
||||||
hash |= 0;
|
|
||||||
}
|
|
||||||
return Math.abs(hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function phasedRollOutExpiredForUser(username, feature, now, rollOutConfig = SdkConfig.get().phasedRollOut) {
|
export function phasedRollOutExpiredForUser(username, feature, now, rollOutConfig = SdkConfig.get().phasedRollOut) {
|
||||||
if (!rollOutConfig) {
|
if (!rollOutConfig) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import sdk from '../../../index';
|
||||||
import Flair from '../elements/Flair.js';
|
import Flair from '../elements/Flair.js';
|
||||||
import FlairStore from '../../../stores/FlairStore';
|
import FlairStore from '../../../stores/FlairStore';
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
|
import {hashCode} from '../../../utils/FormattingUtils';
|
||||||
|
|
||||||
export default React.createClass({
|
export default React.createClass({
|
||||||
displayName: 'SenderProfile',
|
displayName: 'SenderProfile',
|
||||||
|
@ -96,6 +97,7 @@ export default React.createClass({
|
||||||
render() {
|
render() {
|
||||||
const EmojiText = sdk.getComponent('elements.EmojiText');
|
const EmojiText = sdk.getComponent('elements.EmojiText');
|
||||||
const {mxEvent} = this.props;
|
const {mxEvent} = this.props;
|
||||||
|
const colorNumber = hashCode(mxEvent.getSender()) % 8;
|
||||||
const name = mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender();
|
const name = mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender();
|
||||||
const {msgtype} = mxEvent.getContent();
|
const {msgtype} = mxEvent.getContent();
|
||||||
|
|
||||||
|
@ -119,7 +121,7 @@ export default React.createClass({
|
||||||
|
|
||||||
// Name + flair
|
// Name + flair
|
||||||
const nameFlair = <span>
|
const nameFlair = <span>
|
||||||
<span className="mx_SenderProfile_name">
|
<span className={`mx_SenderProfile_name mx_SenderProfile_color${colorNumber}`}>
|
||||||
{ nameElem }
|
{ nameElem }
|
||||||
</span>
|
</span>
|
||||||
{ flair }
|
{ flair }
|
||||||
|
|
|
@ -37,3 +37,24 @@ export function formatCount(count) {
|
||||||
export function formatCryptoKey(key) {
|
export function formatCryptoKey(key) {
|
||||||
return key.match(/.{1,4}/g).join(" ");
|
return key.match(/.{1,4}/g).join(" ");
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* calculates a numeric hash for a given string
|
||||||
|
*
|
||||||
|
* @param {string} str string to hash
|
||||||
|
*
|
||||||
|
* @return {number}
|
||||||
|
*/
|
||||||
|
export function hashCode(str) {
|
||||||
|
let hash = 0;
|
||||||
|
let i;
|
||||||
|
let chr;
|
||||||
|
if (str.length === 0) {
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
for (i = 0; i < str.length; i++) {
|
||||||
|
chr = str.charCodeAt(i);
|
||||||
|
hash = ((hash << 5) - hash) + chr;
|
||||||
|
hash |= 0;
|
||||||
|
}
|
||||||
|
return Math.abs(hash);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue