Avatar defaults and colors
This commit is contained in:
parent
a001882d58
commit
12d2b1bf7c
140 changed files with 4212 additions and 1084 deletions
|
@ -1,53 +1,15 @@
|
|||
// Copyright 2018-2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { AvatarColorType } from '../types/Colors';
|
||||
import { sample } from 'lodash';
|
||||
import { AvatarColors, AvatarColorType } from '../types/Colors';
|
||||
|
||||
const NEW_COLOR_NAMES = new Set(AvatarColors);
|
||||
|
||||
export function migrateColor(color?: string): AvatarColorType {
|
||||
switch (color) {
|
||||
// These colors no longer exist
|
||||
case 'orange':
|
||||
case 'amber':
|
||||
return 'vermilion';
|
||||
case 'yellow':
|
||||
return 'burlap';
|
||||
case 'deep_purple':
|
||||
return 'violet';
|
||||
case 'light_blue':
|
||||
return 'blue';
|
||||
case 'cyan':
|
||||
return 'teal';
|
||||
case 'lime':
|
||||
return 'wintergreen';
|
||||
|
||||
// Actual color names
|
||||
case 'red':
|
||||
return 'crimson';
|
||||
case 'deep_orange':
|
||||
return 'vermilion';
|
||||
case 'brown':
|
||||
return 'burlap';
|
||||
case 'pink':
|
||||
return 'plum';
|
||||
case 'purple':
|
||||
return 'violet';
|
||||
case 'green':
|
||||
return 'forest';
|
||||
case 'light_green':
|
||||
return 'wintergreen';
|
||||
case 'blue_grey':
|
||||
return 'steel';
|
||||
case 'grey':
|
||||
return 'steel';
|
||||
|
||||
// These can stay as they are
|
||||
case 'blue':
|
||||
case 'indigo':
|
||||
case 'teal':
|
||||
case 'ultramarine':
|
||||
return color;
|
||||
|
||||
default:
|
||||
return 'steel';
|
||||
if (color && NEW_COLOR_NAMES.has(color)) {
|
||||
return color;
|
||||
}
|
||||
|
||||
return sample(AvatarColors) || AvatarColors[0];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue