-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: dev
Are you sure you want to change the base?
feat: revamp home ui #334
Conversation
Release v0.19.0
Release v0.19.1
Release v0.20.0
Release: v0.20.1
Release v0.20.3
Release v0.20.4
To quickly test the new UI without modifying the feature flag response, simply update the
|
There was a problem hiding this 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.
There was a problem hiding this 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.
It's because of the dropdown, can we fix it in the next PR? it would take some time to refactor this. |
return newUiEnabled ? ( | ||
<ErrorMessage /> | ||
) : ( | ||
<div className="content-wrapper"> | ||
<h3 className="text-danger"> | ||
Error loading the explorer. Please reload the page to try again. | ||
</h3> | ||
</div> | ||
); | ||
}; |
There was a problem hiding this comment.
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.
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'; |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
<button className="hide-mainnet-mobile"> | ||
<GlobeMainnet |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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?
placeholder="Search tx or address" | ||
placeholder={`Search here`} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<img | ||
src={theme === 'dark' ? sun : moon} | ||
alt="themeColorButton" | ||
className="theme-color-btn" | ||
onClick={() => dispatch(toggleTheme())} | ||
/> |
There was a problem hiding this comment.
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.
{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" | ||
/> | ||
)} |
There was a problem hiding this comment.
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 = () => { |
There was a problem hiding this comment.
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.
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> | ||
); | ||
}; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Acceptance Criteria
Security Checklist
2024-10-16.12-30-01.mp4
2024-10-16.13-39-59.mp4