Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: [Part 2] - Ongoing Work for legacy <Text> comp replacement. #7571

Merged
merged 8 commits into from
Oct 27, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ import { StyleSheet, TextStyle } from 'react-native';

const styleSheet = (params: { theme: Theme }) => {
const { theme } = params;
const { colors, typography } = theme;
const { colors } = theme;
return StyleSheet.create({
buttonLabel: {
color: colors.primary.default,
paddingTop: 8,
textAlign: 'center',
},
content: {
color: colors.text.alternative,
},

disclaimer: {
...typography.sBodyXS,
color: colors.text.alternative,
paddingTop: 16,
} as TextStyle,
});
Expand Down
15 changes: 12 additions & 3 deletions app/components/UI/AssetOverview/AboutAsset/ContentDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import React, { useState } from 'react';
import { View } from 'react-native';
import ButtonLink from '../../../../component-library/components/Buttons/Button/variants/ButtonLink';
import { useStyles } from '../../../../component-library/hooks';
import Text from '../../../Base/Text';
import Text, {
TextColor,
TextVariant,
} from '../../../../component-library/components/Texts/Text';
import styleSheet from './ContentDisplay.styles';
import { strings } from '../../../../../locales/i18n';

Expand All @@ -29,12 +32,18 @@ const ContentDisplay = ({
<View>
<Text
numberOfLines={isExpanded ? undefined : numberOfLines}
style={styles.content}
color={TextColor.Alternative}
>
{content}
</Text>
{disclaimer && isExpanded && (
<Text style={styles.disclaimer}>{disclaimer}</Text>
<Text
color={TextColor.Alternative}
variant={TextVariant.BodyXS}
style={styles.disclaimer}
>
{disclaimer}
</Text>
)}
<ButtonLink
onPress={toggleContent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const styleSheet = (params: {
theme,
vars: { selected },
} = params;
const { colors, typography } = theme;
const { colors } = theme;
return StyleSheet.create({
button: {
backgroundColor: selected
Expand All @@ -26,7 +26,6 @@ const styleSheet = (params: {
justifyContent: 'center',
},
label: {
...typography.sBodySM,
letterSpacing: 3,
color: selected ? colors.background.default : colors.primary.default,
textAlign: 'center',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import { TouchableOpacity } from 'react-native';
import { useStyles } from '../../../../component-library/hooks';
import Text from '../../../Base/Text';
import Text, {
TextVariant,
} from '../../../../component-library/components/Texts/Text';
import styleSheet from './ChartNavigationButton.styles';

interface ChartNavigationButtonProps {
Expand All @@ -18,7 +20,9 @@ const ChartNavigationButton = ({
const { styles } = useStyles(styleSheet, { selected });
return (
<TouchableOpacity style={styles.button} onPress={onPress}>
<Text style={styles.label}>{label}</Text>
<Text variant={TextVariant.BodySM} style={styles.label}>
{label}
</Text>
</TouchableOpacity>
);
};
Expand Down
9 changes: 1 addition & 8 deletions app/components/UI/AssetOverview/Price/Price.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ const styleSheet = (params: {
wrapper: {
paddingHorizontal: 16,
},
symbol: {
...typography.sBodySM,
} as TextStyle,
name: {
...typography.lBodyLGMedium,
fontWeight: '500',
Jonathansoufer marked this conversation as resolved.
Show resolved Hide resolved
} as TextStyle,
price: {
...typography.lHeadingLG,
} as TextStyle,
priceDiff: {
...typography.sBodyMD,
Jonathansoufer marked this conversation as resolved.
Show resolved Hide resolved
color:
priceDiff > 0
? colors.success.default
Expand All @@ -38,9 +34,6 @@ const styleSheet = (params: {
priceDiffIcon: {
marginTop: 10,
},
timePeriod: {
...typography.sBodyMD,
} as TextStyle,
loadingPrice: {
paddingTop: 8,
},
Expand Down
14 changes: 10 additions & 4 deletions app/components/UI/AssetOverview/Price/Price.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { strings } from '../../../../../locales/i18n';
import { useStyles } from '../../../../component-library/hooks';
import { toDateFormat } from '../../../../util/date';
import { addCurrencySymbol } from '../../../../util/number';
import Text from '../../../Base/Text';
import Text, {
TextVariant,
} from '../../../../component-library/components/Texts/Text';
import Title from '../../../Base/Title';
import { Asset } from '../AssetOverview.types';
import PriceChart from '../PriceChart/PriceChart';
Expand Down Expand Up @@ -77,8 +79,12 @@ const Price = ({
return (
<>
<View style={styles.wrapper}>
<Text style={styles.symbol}>{asset.symbol}</Text>
{asset.name && <Text style={styles.name}>{asset.name}</Text>}
<Text variant={TextVariant.BodySM}>{asset.symbol}</Text>
{asset.name && (
<Text variant={TextVariant.HeadingMD} style={styles.name}>
{asset.name}
</Text>
)}
{!isNaN(price) && (
<Title style={styles.price} testID={TOKEN_PRICE}>
{isLoading ? (
Expand Down Expand Up @@ -123,7 +129,7 @@ const Price = ({
{addCurrencySymbol(diff, currentCurrency, true)} (
{diff > 0 ? '+' : ''}
{diff === 0 ? '0' : ((diff / comparePrice) * 100).toFixed(2)}
%) <Text style={styles.timePeriod}>{date}</Text>
%) <Text>{date}</Text>
Jonathansoufer marked this conversation as resolved.
Show resolved Hide resolved
</Text>
) : null}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const styleSheet = (params: { theme: Theme }) => {
textAlign: 'center',
} as TextStyle,
noDataOverlayText: {
...typography.sBodyLGMedium,
textAlign: 'center',
} as TextStyle,
});
Expand Down
6 changes: 4 additions & 2 deletions app/components/UI/AssetOverview/PriceChart/PriceChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import Icon, {
IconSize,
} from '../../../../component-library/components/Icons/Icon';
import { useStyles } from '../../../../component-library/hooks';
import Text from '../../../Base/Text';
import Text, {
TextVariant,
} from '../../../../component-library/components/Texts/Text';
import Title from '../../../Base/Title';
import styleSheet, { CHART_HEIGHT } from './PriceChart.styles';
import { placeholderData } from './utils';
Expand Down Expand Up @@ -221,7 +223,7 @@ const PriceChart = ({
<Title style={styles.noDataOverlayTitle}>
{strings('asset_overview.no_chart_data.title')}
</Title>
<Text style={styles.noDataOverlayText}>
<Text variant={TextVariant.BodyLGMedium} style={styles.noDataOverlayText}>
{strings('asset_overview.no_chart_data.description')}
</Text>
</View>
Expand Down