Skip to content

Commit

Permalink
Merge branch 'main' into fix/numericinput-edge-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharqiewicz authored Sep 30, 2024
2 parents 9a8d44f + 54f0113 commit 1d01950
Show file tree
Hide file tree
Showing 47 changed files with 1,330 additions and 827 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ dist-ssr
!.yarn/versions

vite.config.ts.timestamp-*
coverage/
coverage/
# Local Netlify folder
.netlify
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Yarn version specified in the `packageManager` field.
**Important:** Modern [Yarn](https://yarnpkg.com/getting-started/install) releases should not be installed globally or
via npm - use Corepack instead.

**Note:** If you are using Volta to manage your Node.js versions, you need to follow the
instructions [here](https://yarnpkg.com/corepack#volta).
**Note:** If you are using Volta to manage your Node.js versions, you need to follow the instructions
[here](https://yarnpkg.com/corepack#volta).

### `yarn install`

Expand All @@ -48,7 +48,15 @@ We call on `version.cjs` to show the commit version on the sidebar.\
We also create a file, on the fly, a file named `_redirects` that will serve the index.html instead of giving a 404 no
matter what URL the browser requests.

## Fixing type issues
## Troubleshooting

### Missing price information

If you are missing the price information about the assets on the dashboard page, you are probably experiencing a CORS
problem with the batching server. If you want to fetch prices locally, you can use the proxy server available
at [pendulum-tools](https://github.com/pendulum-chain/pendulum-tools). Change url in `src/hooks/usePriceFetcher.ts` file to `http://localhost:3000`

### Fixing type issues

If you encounter issues with the IDE not detecting the type overwrites of the `@pendulum-chain/types` package properly,
make sure that all the `@polkadot/xxx` packages match the same version used in the types package. It is also important
Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
"@heroicons/react": "^2.1.1",
"@hookform/resolvers": "^2.9.11",
"@netlify/functions": "^2.8.1",
"@pendulum-chain/api": "^0.3.8",
"@pendulum-chain/api-solang": "^0.4.0",
"@polkadot/api": "^10.9.1",
"@polkadot/api-base": "^10.9.1",
"@polkadot/api-contract": "^10.9.1",
"@polkadot/api-derive": "^10.9.1",
"@pendulum-chain/api": "^1.1.1",
"@pendulum-chain/api-solang": "^0.7.0",
"@polkadot/api": "^13.2.1",
"@polkadot/api-base": "^13.2.1",
"@polkadot/api-contract": "^13.2.1",
"@polkadot/api-derive": "^13.2.1",
"@polkadot/extension-dapp": "^0.46.5",
"@polkadot/keyring": "^12.3.2",
"@polkadot/rpc-augment": "^10.9.1",
"@polkadot/rpc-core": "^10.9.1",
"@polkadot/rpc-provider": "^10.9.1",
"@polkadot/types": "^10.9.1",
"@polkadot/rpc-augment": "^13.2.1",
"@polkadot/rpc-core": "^13.2.1",
"@polkadot/rpc-provider": "^13.2.1",
"@polkadot/types": "^13.2.1",
"@polkadot/util": "^12.6.2",
"@talismn/connect-components": "^1.1.7",
"@talismn/connect-ui": "^1.1.2",
Expand Down Expand Up @@ -76,11 +76,11 @@
"@babel/preset-typescript": "^7.24.1",
"@graphql-codegen/cli": "^5.0.2",
"@graphql-codegen/client-preset": "^4.2.6",
"@pendulum-chain/types": "^0.3.8",
"@polkadot/types-augment": "^10.9.1",
"@polkadot/types-codec": "^10.9.1",
"@polkadot/types-create": "^10.9.1",
"@polkadot/types-known": "^10.9.1",
"@pendulum-chain/types": "^1.1.1",
"@polkadot/types-augment": "^13.2.1",
"@polkadot/types-codec": "^13.2.1",
"@polkadot/types-create": "^13.2.1",
"@polkadot/types-known": "^13.2.1",
"@preact/preset-vite": "^2.5.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^11.1.0",
Expand Down Expand Up @@ -131,7 +131,7 @@
"yarn": ">=1.22.19"
},
"resolutions": {
"@polkadot/api": "^10.9.1",
"@polkadot/api": "^13.2.1",
"@polkadot/extension-inject": "^0.46.9"
}
}
2 changes: 1 addition & 1 deletion src/components/CloseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const CloseButton = (props: ButtonProps) => (
color="ghost"
size="sm"
shape="circle"
className="text-xl font-thin !leading-5 w-[2.25rem] h-[2.25rem]"
className="h-[2.25rem] w-[2.25rem] text-xl font-thin !leading-5"
style={{ color: 'var(--secondary)' }}
type="button"
{...props}
Expand Down
129 changes: 0 additions & 129 deletions src/components/Layout/Nav.tsx

This file was deleted.

39 changes: 39 additions & 0 deletions src/components/Layout/Nav/NavCollapseMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export const NavCollapseMenu = ({
link,
disabled,
button,
children,
ariaControls,
activeSelection,
onClick,
}: {
link: string;
disabled?: boolean;
button: JSX.Element | null;
children: JSX.Element | null;
ariaControls?: string;
activeSelection?: string | null;
onClick: (link: string | null) => void;
}) => {
const isItemActive = !!activeSelection && activeSelection === link;

const handleOnClick = () => {
onClick(isItemActive ? null : link);
};

return (
<section className={`collapse ${disabled ? 'disabled' : 'collapse-arrow'} ${isItemActive ? 'collapse-open' : ''} `}>
<button
type="button"
className={`nav-item collapse-btn collapse-title ${isItemActive ? 'active' : ''}`}
aria-controls={ariaControls}
aria-disabled={disabled}
aria-expanded={isItemActive}
onClick={handleOnClick}
>
{button}
</button>
<div className="collapse-content p-0">{children}</div>
</section>
);
};
43 changes: 43 additions & 0 deletions src/components/Layout/Nav/NavItem/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { NavLink } from 'react-router-dom';
import { LinkItem } from '../../links';

const isExternalLink = (link: string) => {
try {
const parsedUrl = new URL(link);
return ['http:', 'https:'].includes(parsedUrl.protocol);
} catch {
return false;
}
};

export const NavItem = ({
item,
onClick,
isSubNavItem = false,
}: {
item: LinkItem;
onClick?: () => void;
isSubNavItem?: boolean;
}) => {
const { link, prefix, suffix, title, props, hidden } = item;
if (hidden) return null;
const isExternal = isExternalLink(link);

const linkUi = (
<>
{prefix}
<span>{title}</span>
{suffix}
</>
);
const cls = `nav-item font-outfit ${props?.className?.() || ''} ${isSubNavItem ? 'text-sm' : ''}`;
return isExternal ? (
<a href={link} {...props} className={cls} onClick={onClick}>
{linkUi}
</a>
) : (
<NavLink to={link} {...props} onClick={onClick} className={cls}>
{linkUi}
</NavLink>
);
};
80 changes: 80 additions & 0 deletions src/components/Layout/Nav/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { memo, useEffect, useMemo, useState } from 'preact/compat';
import { useLocation } from 'react-router-dom';
import { useGlobalState } from '../../../GlobalStateProvider';
import { NavCollapseButtonContent } from '../NavCollapseButtonContent';
import { createLinks, LinkItem } from '../links';
import { NavItem } from './NavItem';
import { NavCollapseMenu } from './NavCollapseMenu';

const getActiveLink = (pathname: string): string | null => {
const [path] = pathname.split('?');
const paths = path.split('/').filter(Boolean);
return paths.length > 1 ? `/${paths[1]}` : null;
};

export type NavProps = {
onClick?: () => void;
};

const Nav = memo(({ onClick }: NavProps) => {
const state = useGlobalState();

const [isPlaying, setIsPlaying] = useState(false);
const [links, setLinks] = useState<LinkItem[]>([]);

const { pathname } = useLocation();
const activeLink = useMemo(() => getActiveLink(pathname), [pathname]);
const [activeSelection, setActiveSelection] = useState<null | string>(activeLink);

const handleMouseEnter = () => {
setIsPlaying(true);
};

useEffect(() => {
const [defaultLinks, loadedLinksPromise] = createLinks(state.tenantName);
setLinks(defaultLinks);

loadedLinksPromise.then(setLinks).catch((error) => console.error("Couldn't load links", error));
}, [state.tenantName]);

return (
<nav>
{links.map((item, i) => {
if (item.hidden) return;

return item.submenu ? (
<div onMouseEnter={handleMouseEnter} className="my-2.5">
<NavCollapseMenu
key={i}
disabled={item.disabled}
ariaControls="submenu"
button={<NavCollapseButtonContent item={item} isPlaying={isPlaying} />}
activeSelection={activeSelection}
link={item.link}
onClick={setActiveSelection}
>
<ul className="submenu" id={`submenu-${i}`}>
{item.submenu.map((subItem, j) => (
<li key={`${i}-${j}`} className="ml-[3px]">
<NavItem item={subItem} onClick={onClick} isSubNavItem={true} />
</li>
))}
</ul>
</NavCollapseMenu>
</div>
) : (
<NavItem
key={i}
item={item}
onClick={() => {
setActiveSelection(item.link);
onClick && onClick();
}}
/>
);
})}
</nav>
);
});

export default Nav;
Loading

0 comments on commit 1d01950

Please sign in to comment.