Skip to content

Commit 8b8ef9d

Browse files
authored
[CS-5121]: Fix crash on wallet connect (#1168)
1 parent e6671b9 commit 8b8ef9d

3 files changed

Lines changed: 12 additions & 28 deletions

File tree

src/components/coin-icon/RequestVendorLogoIcon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Container } from '@cardstack/components';
55

66
import { ImgixImage } from '@rainbow-me/images';
77
import { position } from '@rainbow-me/styles';
8-
import colors from '@rainbow-me/styles/colors';
8+
import colors, { getFallbackTextColor } from '@rainbow-me/styles/colors';
99

1010
import { initials } from '../../utils';
1111
import { Centered } from '../layout';
@@ -60,7 +60,7 @@ export default function RequestVendorLogoIcon({
6060
) : (
6161
<Text
6262
align="center"
63-
color={colors.getFallbackTextColor(bgColor)}
63+
color={getFallbackTextColor(bgColor)}
6464
size="smedium"
6565
weight="semibold"
6666
>

src/components/collectible/CollectibleImage.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@ import React, { memo, useCallback, useState } from 'react';
22

33
import { ImageWithCachedMetadata, ImgixImage } from '@rainbow-me/images';
44
import { position } from '@rainbow-me/styles';
5-
import colors from '@rainbow-me/styles/colors';
5+
import { getFallbackTextColor } from '@rainbow-me/styles/colors';
66

77
import { buildCollectibleName } from '../../helpers/assets';
88
import { Centered } from '../layout';
99
import { Monospace } from '../text';
1010

11-
const getFallbackTextColor = bg =>
12-
colors.getTextColorForBackground(bg, {
13-
dark: colors.alpha(colors.blueGreyDark, 0.5),
14-
light: colors.white,
15-
});
16-
1711
const CollectibleImage = ({
1812
backgroundColor = 'white',
1913
imageUrl,
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import chroma from 'chroma-js';
22

33
import { avatarColor } from '@cardstack/theme';
44

5-
const buildRgba = (color, alpha = 1) => `rgba(${chroma(color).rgb()},${alpha})`;
5+
const buildRgba = (color: string, alpha = 1) =>
6+
`rgba(${chroma(color).rgb()},${alpha})`;
67

78
const colors = {
89
appleBlue: '#0E76FD', // '14, 118, 253'
@@ -34,27 +35,16 @@ const colors = {
3435
alpha: buildRgba,
3536
};
3637

37-
const isColorLight = targetColor =>
38-
chroma(targetColor || colors.white).luminance() > 0.5;
38+
export const getFallbackTextColor = (backgroundColor?: string) => {
39+
const dark = colors.alpha(colors.blueGreyDark, 0.5);
40+
const light = colors.whiteLabel;
41+
const isColorLight =
42+
chroma(backgroundColor || colors.white).luminance() > 0.5;
3943

40-
const getTextColorForBackground = (targetColor, textColors = {}) => {
41-
const { dark = colors.black, light = colors.white } = textColors;
42-
43-
return isColorLight(targetColor) ? dark : light;
44+
return isColorLight ? dark : light;
4445
};
4546

46-
const getFallbackTextColor = bg =>
47-
colors.getTextColorForBackground(bg, {
48-
dark: colors.alpha(colors.blueGreyDark, 0.5),
49-
light: colors.whiteLabel,
50-
});
51-
5247
export const getRandomColor = () =>
5348
Math.floor(Math.random() * avatarColor.length);
5449

55-
export default {
56-
...colors,
57-
getTextColorForBackground,
58-
getFallbackTextColor,
59-
getRandomColor,
60-
};
50+
export default colors;

0 commit comments

Comments
 (0)