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

feat: revamp home ui #334

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from

Conversation

julia-eileen
Copy link

@julia-eileen julia-eileen commented Oct 16, 2024

Acceptance Criteria

  • Configure the project to allow the old UI codebase to coexist with the new one until the revamp is completed.
  • Implement a feature flag system using the useNewUiEnabled hook.
  • Modify the Sass build script to generate output for both the old and new UI.
  • Set up the project to allow a theming system (dark and light mode).
  • Update navigation, status components, and the homepage according to the new UI.

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.
2024-10-16.12-30-01.mp4
2024-10-16.13-39-59.mp4

@julia-eileen julia-eileen changed the base branch from master to dev October 16, 2024 16:57
@julia-eileen
Copy link
Author

To quickly test the new UI without modifying the feature flag response, simply update the hooks/useNewUiEnabled.js file with the following content:

/**
 * Copyright (c) Hathor Labs and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import { useFlag } from '@unleash/proxy-client-react';
import { UNLEASH_NEW_UI_FEATURE_FLAG } from '../constants';

export const useNewUiEnabled = () => {
  const newUiEnabled = useFlag(UNLEASH_NEW_UI_FEATURE_FLAG) || true;

  return newUiEnabled;
};

@tuliomir tuliomir self-assigned this Oct 16, 2024
@tuliomir tuliomir added the enhancement New feature or request label Oct 16, 2024
Copy link
Contributor

@tuliomir tuliomir left a comment

Choose a reason for hiding this comment

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

Thanks for contributing to our project! Here are some questions and suggestions on an initial partial review.

src/hooks/useIsMobile.js Outdated Show resolved Hide resolved
src/hooks/useNewUiLoad.js Outdated Show resolved Hide resolved
src/utils/getTheme.js Outdated Show resolved Hide resolved
src/hooks/useMount.js Outdated Show resolved Hide resolved
src/screens/DashboardTx.js Outdated Show resolved Hide resolved
src/components/Switch.js Outdated Show resolved Hide resolved
src/components/Switch.js Outdated Show resolved Hide resolved
src/actions/index.js Show resolved Hide resolved
src/components/GDPRConsent.js Outdated Show resolved Hide resolved
src/components/Navigation.js Outdated Show resolved Hide resolved
@tuliomir tuliomir self-requested a review October 21, 2024 14:01
Copy link
Contributor

@tuliomir tuliomir left a comment

Choose a reason for hiding this comment

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

Not related to any file in specific: When running the application in localhost using the new UI, I'm receiving the following warning on browser console:

index.js:26 Warning: validateDOMNesting(...): <li> cannot appear as a descendant of <li>.
    at li
    at ConditionalNavigation (http://localhost:3000/static/js/main.chunk.js:4765:5)

This may be related to some specific usage on the Navigation.js file, but I'm unsure of its source as of now.

@julia-eileen
Copy link
Author

Not related to any file in specific: When running the application in localhost using the new UI, I'm receiving the following warning on browser console:

index.js:26 Warning: validateDOMNesting(...): <li> cannot appear as a descendant of <li>.
    at li
    at ConditionalNavigation (http://localhost:3000/static/js/main.chunk.js:4765:5)

This may be related to some specific usage on the Navigation.js file, but I'm unsure of its source as of now.

It's because of the dropdown, can we fix it in the next PR? it would take some time to refactor this.

Comment on lines +80 to +89
return newUiEnabled ? (
<ErrorMessage />
) : (
<div className="content-wrapper">
<h3 className="text-danger">
Error loading the explorer. Please reload the page to try again.
</h3>
</div>
);
};
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: Why not move the hook + logic to the ErrorMessage component?

This would make both the usage and later refactors to remove the old ui, simpler.

Comment on lines +15 to +17
import moon from '../assets/images/moon.svg';
import sun from '../assets/images/sun-dark.svg';
import { ReactComponent as NewLogo } from '../assets/images/new-logo.svg';
Copy link
Member

Choose a reason for hiding this comment

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

question: Is there any difference between these import styles?

theme === 'dark' ? 'dark-theme-logo' : 'light-theme-logo'
} theme-mainnet-btn`}
/>
<span className="nav-title">Hathor Mainnet</span>
Copy link
Member

Choose a reason for hiding this comment

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

issue: The explorer works as the explorer for Hathor Testnet and some other custom networks.

Maybe we should get the connected network from the redux state.
See this line, the serverInfo received by setServerInfo can save the connected network on the redux and we can read it here and in the other places where mainnet is hard-coded.

Comment on lines +112 to +113
<button className="hide-mainnet-mobile">
<GlobeMainnet
Copy link
Member

Choose a reason for hiding this comment

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

To avoid confusion maybe we shoud rename this to "hide-network-mobile" and "GlobeNetwork".

<span className="navbar-toggler-icon" />
</button>
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<ul className="navbar-nav me-auto">
Copy link
Member

Choose a reason for hiding this comment

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

Correct me if i'm wrong, but it seems there is a lot of duplicated items in the renderUi, renderNewUi and SideBar.
Maybe we should create a component for these duplicated items.

For instance, this list (ul) seems like it would have no problem being extracted to another component.
What do you think?

Comment on lines -174 to +218
placeholder="Search tx or address"
placeholder={`Search here`}
Copy link
Member

Choose a reason for hiding this comment

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

issue: The UI is not indicative of what can be searched.

We should keep the "Search tx or address" so users know that he can also search for an address.
Or maybe we can keep the "Search here" and when the user focus on the input it shows a message explaining that he can search both txs and addresses.

Copy link
Author

Choose a reason for hiding this comment

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

We changed it accordingly with the figma prototype.

Screenshot_20241021_171735_Firefox

Should we change it back?

Comment on lines +227 to +232
<img
src={theme === 'dark' ? sun : moon}
alt="themeColorButton"
className="theme-color-btn"
onClick={() => dispatch(toggleTheme())}
/>
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: Move this to the theme toggle component.

Maybe the theme toggle component should receive a bool to render as a switch or an image button.
This way we don't have to inline the theme toggle.

Comment on lines +243 to +262
{showSearchInput ? (
<input
type="search"
className={`form-control me-2 bg-dark text-light mobile-search-input ${
showSearchInput ? 'expanded' : ''
}`}
placeholder="Search..."
aria-label="Search"
ref={txSearchRef}
onKeyUp={handleKeyUp}
onBlur={() => setShowSearchInput(false)}
autoFocus
/>
) : (
<SearchIcon
fill={theme === 'dark' ? 'white' : 'black'}
onClick={toggleSearchInput}
className="mobile-search-icon"
/>
)}
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: Extract this into another component.

Just an idea, since showSearchInput can be moved to the component and the rest seems to work.
Also, this Navigation component would be more straightforward and easier to read.

import { useDispatch, useSelector } from 'react-redux';
import { toggleTheme } from '../actions';

export const SwitchButton = () => {
Copy link
Member

@r4mmer r4mmer Oct 21, 2024

Choose a reason for hiding this comment

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

issue: Components we should have the same name as the file.

Also, this Switch maybe should be named ThemeSwitch to make it more indicative of what it does.

Comment on lines +23 to +56
const parseTimestamp = timestamp => {
const date = new Date(timestamp * 1000);

const userLocale = navigator.language || navigator.userLanguage || 'en-US';

return new Intl.DateTimeFormat(userLocale, {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false,
})
.format(date)
.replace(',', '');
};

const renderIdCell = id => {
const idStart = id.substring(0, isMobile ? 4 : 12);
const idEnd = id.substring(id.length - (isMobile ? 4 : 12), id.length);

return (
<div className="id-cell">
{idStart}
<div className="ellipsis">
<div className="ellipsi"></div>
<div className="ellipsi"></div>
<div className="ellipsi"></div>
</div>
{idEnd}
</div>
);
};
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: Maybe we should move this to the utils folder so we can use this timestamp parser in other places as well.

Copy link
Author

Choose a reason for hiding this comment

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

We moved it, in the next PR it will be in the utils/date.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Review (WIP)
Development

Successfully merging this pull request may close these issues.

5 participants