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

[CHORE]: Remove transaction inconsistencies and improve type safety #6137

Merged
merged 19 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this types declaration file was missing when converting ActivityIndicator to typescript

Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@
"@types/qs": "6.9.7",
"@types/react": "18.2.65",
"@types/react-native-extra-dimensions-android": "1.2.3",
"@types/react-native-indicators": "0.16.6",
"@types/react-test-renderer": "18.3.0",
"@types/styled-components": "5.1.7",
"@types/url-parse": "1.4.3",
Expand Down
2 changes: 1 addition & 1 deletion src/__swaps__/types/refraction.ts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved all txn types into @/entities

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ZerionAsset } from '@/__swaps__/types/assets';
import { ChainId, ChainName } from '@/chains/types';
import { PaginatedTransactionsApiResponse } from '@/resources/transactions/types';
import { PaginatedTransactionsApiResponse } from '@/entities';

/**
* Metadata for a message from the Zerion API.
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typescript conversion

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ import { Centered } from './layout';
import styled from '@/styled-thing';
import { position } from '@/styles';

const Container = styled(Centered)(({ size }) => position.sizeAsObject(Number(size)));
const Container = styled(Centered)(({ size }: { size: number }) => position.sizeAsObject(Number(size)));

export default function ActivityIndicator({ color, isInteraction = false, size = 25, ...props }) {
type ActivityIndicatorProps = {
color?: string;
isInteraction?: boolean;
size?: number;
};

export default function ActivityIndicator({ color, isInteraction = false, size = 25, ...props }: ActivityIndicatorProps) {
const { colors } = useTheme();
return (
<Container size={size} {...props}>
Expand Down
48 changes: 36 additions & 12 deletions src/components/Divider.js → src/components/Divider.tsx
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typescript conversion

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import React from 'react';
import { magicMemo } from '../utils';
import styled from '@/styled-thing';
import { borders, position } from '@/styles';
import { View } from 'react-native';
import { ThemeContextProps, useTheme } from '@/theme';

export const DividerSize = 2;

const buildInsetFromProps = inset => {
const buildInsetFromProps = (inset: number | number[]): number[] => {
if (!inset) return [0, 0, 0, 0];
if (isNumber(inset)) return [inset, inset, inset, inset];

Expand All @@ -15,35 +17,41 @@ const buildInsetFromProps = inset => {
return [inset[0], rightInset, inset[2] || inset[0], !isNil(inset[3]) ? inset[3] : rightInset];
};

const horizontalBorderLineStyles = inset => `
const horizontalBorderLineStyles = (inset: number[]): string => `
${inset[3] ? borders.buildRadius('left', 2) : ''}
${inset[1] ? borders.buildRadius('right', 2) : ''}
left: ${inset[3]};
right: ${inset[1]};
`;

horizontalBorderLineStyles.object = inset => ({
horizontalBorderLineStyles.object = (inset: number[]): object => ({
...(inset[3] ? borders.buildRadiusAsObject('left', 2) : {}),
...(inset[1] ? borders.buildRadiusAsObject('right', 2) : {}),
left: inset[3],
right: inset[1],
});

const verticalBorderLineStyles = inset => `
const verticalBorderLineStyles = (inset: number[]): string => `
${inset[2] ? borders.buildRadius('bottom', 2) : ''}
${inset[0] ? borders.buildRadius('top', 2) : ''}
bottom: ${inset[2]};
top: ${inset[0]};
`;

verticalBorderLineStyles.object = inset => ({
verticalBorderLineStyles.object = (inset: number[]): object => ({
...(inset[2] ? borders.buildRadiusAsObject('bottom', 2) : {}),
...(inset[0] ? borders.buildRadiusAsObject('top', 2) : {}),
bottom: inset[2],
top: inset[0],
});

const BorderLine = styled.View(({ color, horizontal, inset }) => {
interface BorderLineProps {
color: string;
horizontal: boolean;
inset: number | number[];
}

const BorderLine = styled(View)(({ color, horizontal, inset }: BorderLineProps) => {
const insetFromProps = buildInsetFromProps(inset);
return {
...position.coverAsObject,
Expand All @@ -52,14 +60,30 @@ const BorderLine = styled.View(({ color, horizontal, inset }) => {
};
});

const Container = styled.View({
backgroundColor: ({ backgroundColor, theme: { colors } }) => backgroundColor || colors.white,
interface ContainerProps {
backgroundColor: string;
horizontal: boolean;
size: number;
theme: ThemeContextProps;
}

const Container = styled(View)(({ backgroundColor, theme: { colors } }: ContainerProps) => ({
backgroundColor: backgroundColor || colors.white,
flexShrink: 0,
height: ({ horizontal, size }) => (horizontal ? size : '100%'),
width: ({ horizontal, size }) => (horizontal ? '100%' : size),
});
height: ({ horizontal, size }: { horizontal: boolean; size: number }) => (horizontal ? size : '100%'),
width: ({ horizontal, size }: { horizontal: boolean; size: number }) => (horizontal ? '100%' : size),
}));

interface DividerProps {
backgroundColor?: string;
color?: string;
horizontal?: boolean;
inset?: number | number[];
size?: number;
[key: string]: any;
}

const Divider = ({ backgroundColor, color, horizontal = true, inset = [0, 0, 0, 19], size = DividerSize, ...props }) => {
const Divider = ({ backgroundColor, color, horizontal = true, inset = [0, 0, 0, 19], size = DividerSize, ...props }: DividerProps) => {
const { colors } = useTheme();
return (
<Container {...props} backgroundColor={backgroundColor} horizontal={horizontal} size={size}>
Expand Down
145 changes: 0 additions & 145 deletions src/components/activity-list/ActivityList.js
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> .tsx

This file was deleted.

Loading
Loading