Skip to content

V2.0.0 UI update#391

Merged
simon-bai merged 53 commits into
masterfrom
release/v2.0.0
Nov 26, 2024
Merged

V2.0.0 UI update#391
simon-bai merged 53 commits into
masterfrom
release/v2.0.0

Conversation

@simon-bai

Copy link
Copy Markdown
Contributor

V2.0.0 UI update. close #390

simon-bai and others added 30 commits November 12, 2024 18:06
Comment thread tailwind.config.js Outdated
'00auto': '0 0 auto',
},
screens: {
'min-769': '769px',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) should follow standard breakpoint conventions like https://getbootstrap.com/docs/5.0/layout/breakpoints/

    screens: {
      'sm': '640px',
      'md': '768px',
      'lg': '1024px',
      'xl': '1280px',
      '2xl': '1536px'
    }

for this case, perhaps we do a custom breakpoint md: 769px

@@ -0,0 +1,18 @@
import { memo } from 'react';
import AdsCarousel from './_components/ScrollAds';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) no clear reason to have _components instead of components? should rename _* to *

</div>

<div className="mx-auto box-border w-full max-w-[1440px] px-4 min-[769px]:px-6 min-[993px]:min-w-[200px] min-[993px]:px-10">
<BannerContainer />

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good cleanup!

@@ -0,0 +1,36 @@
import { useAppSelector } from '@_store';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) @_store is confusing. Should change tsconfig to be "@/": ["src/"]. Common conventions:

  • @ for source folder
  • ~ for root folder

import AceEditor from 'react-ace';
import 'ace-builds/src-noconflict/mode-csharp';
import 'ace-builds/src-noconflict/theme-github';
import 'ace-builds/src-noconflict/theme-tomorrow';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) do on-demand dynamic import if there are more than >1 theme, or just remove -github

}, [width]);
const isLG = useMemo(() => {
return width < 1024;
return width < 1025;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) avoid magic numbers. Those values should be exported figma design tokens similar to what I wrote in tailwind config { lg: '1024' }

const { tokens, nfts, accounts, contracts, blocks } = res;
if (tokens.length) {
router.push(`/${defaultChain}/token/${tokens[0].symbol}`);
router.push(`/${MULTI_CHAIN}/token/${tokens[0].symbol}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) multiple nested ifs are really hard to follow. Refactor this block out into a separate util getRouteFromParams method:

getRouteFromParams(res: ISearchResponse): string {
   // check for tokens, nfts, accounts etc to assign a route
   return route;
}

then write tests for the method

return isMainNet ? 'tDVV' : 'tDVW';
};

export const useCurrentPageChain = () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) add UT as it's a new hook

{ ...commonColumns[2], width: 384 },
{ ...commonColumns[3], width: 384 },
];
export default function getColumns(currentPage, pageSize): ColumnsType<HolderItem> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

getColumns is just re-exported getCommonColumns with same parameters here. Why not export function getCommonColumns(currentPage, pageSize): ColumnsType<HolderItem> ?

Comment thread src/_utils/contant.ts
Testnet: 'https://t.me/aelfscantest_bot',
};

export const SEARCH_TITLE = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) rename file to const.ts or constants.ts later

Comment thread src/_utils/formatter.ts
export const thousandsNumber = (number: string | number): string => {
const num = Number(number);
if (number === '' || Number.isNaN(num) || number === null) return '-';
if (number === '' || Number.isNaN(num) || number === null) return '--';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) I see alot of '--' so it's better to make this a const or ENUM for formatting.

Comment thread src/app/[chain]/address/list.tsx Outdated
};

const chainChange = (value: string) => {
console.log(value, 'value');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remove console.log for production builds

Comment thread src/app/[chain]/address/list.tsx Outdated
},
}}
showMultiChain={chain === MULTI_CHAIN}
showMultiChain={true}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

just showMultiChain will do, unless you expect the condition to change many times

Comment thread src/app/[chain]/address/page.tsx Outdated
defaultPageSize={Number(ps)}
defaultPageType={defaultPageType}
defaultChain={defaultChain}
defaultChain={defaultChain || ''}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

move to L14 to group fallback values in 1 place const defaultChain = searchParams['chain'] || MULTI_CHAIN || ''

}
const selectFile = filtered[0];
const newPath = `${path}${selectFile.name}/`;
// if (index === names.length - 1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Delete the commented out block. You have git history for changes.

onChange(e.node.key.split('#'));
};

const ismd = useMD();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

change useMD to useBreakpointMD to be descriptive and check other usages too

const chainArr = useMemo(() => {
return chainList.map((ele) => ele.chainList_id);
}, [chainList]);
console.log(chainArr, props, 'props');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remove console.log in production builds

const { chain } = useParams();
const params = useSearchParams();
const chain = params.get('chain') || MULTI_CHAIN;
const selectChain = useMemo(() => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

double check that you actually need useMemo here if the param is directly from nextjs hook


return (
<div className="chain-select-container mr-4 w-full !py-0" id="chain-select-container">
<div className="chain-select-container w-full !py-0" id="chain-select-container" suppressHydrationWarning>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) add a comment to explain why the need to supress warnings here

}, [name, showContractAddress, type]);

return type === AddressType.address || showContractAddress || (type === AddressType.Contract && !name) ? (
address ? (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) move the jsx code into functions like renderAddress and renderName and convert ternary conditions to if-else. This is hard to read.

if (type === AddressType.address || showContractAddress || (type === AddressType.Contract && !name) {
   return address ? renderAddress() : '-';
}
else {
   return name ? renderName() : '-';
}

please enable https://eslint.org/docs/latest/rules/no-nested-ternary rules for eslint

)
) : name ? (
<div className="address w-full truncate">
<div className="address flex w-full truncate">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix)
image
I'm getting a warning from eslint-plugin-tailwindcss. extract with @apply later

import clsx from 'clsx';
import QrCodeModal from './qrCode';

export default function MultiChain({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) add UT for new component

@@ -0,0 +1,26 @@
import IconFont from '@_components/IconFont';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(tofix) same as above

@work-kevin-flynn work-kevin-flynn self-requested a review November 26, 2024 14:48
@simon-bai simon-bai merged commit ba7aebf into master Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V2.0.0 UI update

2 participants