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: Style improvements for buttons and tooltips #147

Merged
merged 8 commits into from
Dec 16, 2024
2 changes: 1 addition & 1 deletion src/components/nav/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const footerLinks2 = [
];

const footerLinks3 = [
{ title: 'Twitter', url: links.twitter, external: true, icon: <TwitterIcon color="#fff" /> },
{ title: 'X', url: links.twitter, external: true, icon: <TwitterIcon color="#fff" /> },
{ title: 'Discord', url: links.discord, external: true, icon: <DiscordIcon color="#fff" /> },
{ title: 'Github', url: links.github, external: true, icon: <GithubIcon color="#fff" /> },
];
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/MiniSearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function MiniSearchBar() {
placeholder="Hash or address"
className="h-8 w-32 rounded-full px-2.5 py-2 text-sm font-light transition-[width] duration-500 ease-in-out placeholder:text-gray-600 focus:w-64 focus:outline-none"
/>
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-pink-500">
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-pink-500 duration-500 hover:bg-blue-500">
<IconButton type="submit" title="Search">
<SearchIcon width={14} height={14} color={Color.white} />
</IconButton>
Expand Down
30 changes: 23 additions & 7 deletions src/components/search/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export function SearchBar({ value, placeholder, onChangeValue, isFetching }: Pro
onChangeValue(value);
};

const iconStyle =
jmrossy marked this conversation as resolved.
Show resolved Hide resolved
'flex h-10 w-10 items-center justify-center rounded-full bg-pink-600 sm:h-12 sm:w-12';

return (
<div className="flex w-full items-center rounded-full bg-white p-1 transition-all duration-500">
<input
Expand All @@ -28,15 +31,28 @@ export function SearchBar({ value, placeholder, onChangeValue, isFetching }: Pro
placeholder={placeholder}
className="h-10 flex-1 rounded-full p-1 font-light placeholder:text-gray-600 focus:outline-none sm:h-12 sm:px-4 md:px-5"
/>
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-pink-500 sm:h-12 sm:w-12">
{isFetching && <SpinnerIcon color={Color.white} width={26} height={26} />}
{!isFetching && !value && <Image src={SearchIcon} width={20} height={20} alt="" />}
{!isFetching && value && (
<IconButton title="Clear search" onClick={() => onChange(null)}>

{isFetching && (
<div className={iconStyle}>
<SpinnerIcon color={Color.white} width={26} height={26} />
</div>
)}
{!isFetching && !value && (
<div className={iconStyle}>
<Image src={SearchIcon} width={20} height={20} alt="" />
</div>
)}
{!isFetching && value && (
<div className={`${iconStyle} bg-pink-600 duration-500 hover:bg-blue-500 sm:h-12 sm:w-12`}>
<IconButton
title="Clear search"
className="h-full w-full rounded-full"
onClick={() => onChange(null)}
>
<XIcon width={16} height={16} color="white" />
</IconButton>
)}
</div>
</div>
)}
</div>
);
}
2 changes: 1 addition & 1 deletion src/consts/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const links = {
discord: 'https://discord.gg/VK9ZUy3aTV',
github: 'https://github.com/hyperlane-xyz',
jobs: 'https://jobs.lever.co/Hyperlane',
twitter: 'https://twitter.com/hyperlane',
twitter: 'https://x.com/hyperlane',
blog: 'https://medium.com/hyperlane',
tenderlySimDocs:
'https://docs.tenderly.co/simulations-and-forks/how-to-simulate-a-transaction/using-simulation-ui',
Expand Down
1 change: 1 addition & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { AppLayout } from '../AppLayout';
import { ErrorBoundary } from '../components/errors/ErrorBoundary';
import { config } from '../consts/config';
import { ChainConfigSyncer } from '../features/chains/ChainConfigSyncer';
import '../styles/custom.css';
import { MAIN_FONT } from '../styles/fonts';
import '../styles/global.css';

Expand Down
4 changes: 4 additions & 0 deletions src/styles/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Fix for tooltips breaking layout on mobile devices (<526px width). */


@media (max-width: 526px) {#gas-info, #transaction-info, #message-info{max-width: calc(100% - 10px);}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use tailwind classes instead of creating a new css file.
If you need to do specific amounts like 526px, you can use a class like max-w-[526px], but it would be better if you can make this work with just the max-w classes in tailwind's base set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! Unfortunately, this appears to be a limitation or bug in the Tooltip library. When we try to pass a className like max-w-[calc(100%-10px)] sm:max-w-[526px], it gets applied to an unexpected tag instead of the actual tooltip. This behavior prevents us from fully leveraging Tailwind classes in this case. For now, me had to rely on a custom CSS file to address this issue.

Copy link
Contributor

@Xaroz Xaroz Dec 11, 2024

Choose a reason for hiding this comment

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

There is a property inside the Tooltip called data-tooltip-class-name which directly modifies the className for the tooltip component. I vote we also move this part to the widgets lib @jmrossy

Copy link
Collaborator

Choose a reason for hiding this comment

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

@NikolaiKryshnev would you like to give this classname-based approach a try? Also from the CI failure it looks like you need to run yarn prettier to fix the formatting issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jmrossy Thanks for the suggestion! I gave the data-tooltip-class-name approach a try, and it seems to work well.
image

Loading