Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into GSW-408-Main-Commo…
Browse files Browse the repository at this point in the history
…n-Improve-UI
  • Loading branch information
khiemldk committed Oct 24, 2023
2 parents 8f0890b + 662b627 commit fd913b6
Show file tree
Hide file tree
Showing 74 changed files with 1,154 additions and 359 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@

node_modules
.vscode

.pnp.cjs
.pnp.loader.mjs

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/web/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEXT_PUBLIC_DEFAULT_CHAIN_ID="dev.gnoswap"
NEXT_PUBLIC_API_URL="https://dev-api.gnoswap.io/v3/testnet"
NEXT_PUBLIC_API_URL="https://dev.api.gnoswap.io/v3/testnet"
NEXT_PUBLIC_PACKAGE_POOL_PATH="gno.land/r/pool"
NEXT_PUBLIC_PACKAGE_POOL_ADDRESS="g1ee305k8yk0pjz443xpwtqdyep522f9g5r7d63w"
NEXT_PUBLIC_PACKAGE_POSITION_PATH="gno.land/r/position"
Expand Down
6 changes: 3 additions & 3 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@emotion/styled": "11.10.6",
"@floating-ui/react": "0.21.1",
"@gnolang/gno-js-client": "1.1.6",
"@hookform/resolvers": "^3.3.2",
"@hookform/resolvers": "3.3.2",
"@tanstack/react-query": "4.26.1",
"axios": "1.3.4",
"bignumber.js": "9.1.1",
Expand All @@ -28,12 +28,12 @@
"next": "13.2.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.47.0",
"react-hook-form": "7.47.0",
"typescript": "4.9.5",
"url-loader": "4.1.1",
"utility-types": "3.10.0",
"ws": "8.14.2",
"yup": "^1.3.2"
"yup": "1.3.2"
},
"devDependencies": {
"@babel/core": "7.21.0",
Expand Down
Binary file added packages/web/public/img-404.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const wrapper = (theme: Theme) => css`
${fonts.p3};
height: 26px;
padding: 0px 8px;
background-color: ${theme.color.background06};
background-color: ${theme.color.backgroundOpacity3};
color: ${theme.color.text04};
border-radius: 2px;
Expand All @@ -18,7 +18,7 @@ export const wrapper = (theme: Theme) => css`
color: ${theme.color.text02};
}
&:last-of-type {
color: ${theme.color.text05};
color: ${theme.color.text10};
}
}
Expand All @@ -30,4 +30,7 @@ export const wrapper = (theme: Theme) => css`
fill: ${theme.color.icon03};
}
}
@media (max-width: 1180px) {
height: 24px;
}
`;
1 change: 1 addition & 0 deletions packages/web/src/components/common/header/Header.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe("Header Component", () => {
connected: false,
account: null,
connectAdenaClient: () => null,
disconnectWallet: () => null,
sideMenuToggle: true,
onSideMenuToggle: () => null,
searchMenuToggle: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Default.args = {
connected: false,
account: defaultAccountInfo,
connectAdenaClient: action("connectAdenaClient"),
disconnectWallet: action("disconnectWallet"),
sideMenuToggle: true,
onSideMenuToggle: action("onSideMenuToggle"),
searchMenuToggle: true,
Expand Down
10 changes: 9 additions & 1 deletion packages/web/src/components/common/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface HeaderProps {
connected: boolean;
connectAdenaClient: () => void;
themeKey: "dark" | "light";
disconnectWallet: () => void;
}

const Header: React.FC<HeaderProps> = ({
Expand All @@ -57,6 +58,7 @@ const Header: React.FC<HeaderProps> = ({
connected,
connectAdenaClient,
themeKey,
disconnectWallet,
}) => {
return (
<>
Expand All @@ -75,7 +77,12 @@ const Header: React.FC<HeaderProps> = ({
{HEADER_NAV.map(item => (
<li
key={item.title}
className={pathname === item.path ? "selected" : ""}
className={
pathname === item.path ||
(item.subPath || []).some(_ => pathname.includes(_))
? "selected"
: ""
}
>
<Link href={item.path}>{item.title}</Link>
</li>
Expand All @@ -99,6 +106,7 @@ const Header: React.FC<HeaderProps> = ({
connected={connected}
connectAdenaClient={connectAdenaClient}
themeKey={themeKey}
disconnectWallet={disconnectWallet}
/>
</SearchContainer>
<NotificationButton breakpoint={breakpoint} />
Expand Down
60 changes: 1 addition & 59 deletions packages/web/src/components/common/icons/IconGnoswap404.tsx

Large diffs are not rendered by default.

27 changes: 21 additions & 6 deletions packages/web/src/components/common/line-graph/LineGraph.styles.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import { fonts } from "@constants/font.constant";
import styled from "@emotion/styled";
import { media } from "@styles/media";

export const LineGraphWrapper = styled.div`
position: relative;
display: flex;
flex-direction: column;
width: 100%;
height: 180px;
height: 319px;
overflow: visible;
${media.mobile} {
height: 263px;
}
& svg {
display: flex;
flex-direction: column;
width: 100%;
height: 180px;
height: 319px;
overflow: visible;
${media.mobile} {
height: 263px;
}
}
`;

Expand All @@ -29,13 +35,14 @@ export const LineGraphTooltipWrapper = styled.div<LineGraphTooltipWrapperProps>`
left: ${props => `${props.x}px`};
display: flex;
flex-direction: column;
width: 157px;
width: 148px;
height: auto;
padding: 6px 8px;
background: ${({ theme }) => theme.color.background05};
background: ${({ theme }) => theme.color.background02};
border-radius: 4px;
box-shadow: 2px 2px 12px 0px rgba(0, 0, 0, 0.15);
overflow: visible;
gap: 5px;
${fonts.p4};
& .tooltip-header {
Expand All @@ -44,9 +51,17 @@ export const LineGraphTooltipWrapper = styled.div<LineGraphTooltipWrapperProps>`
width: 100%;
height: auto;
justify-content: space-between;
font-size: 16px;
font-weight: 700;
line-height: 19px;
color: ${({ theme }) => theme.color.point};
}
& .tooltip-body {
color: ${({ theme }) => theme.color.point};
${fonts.p4};
color: ${({ theme }) => theme.color.text04};
.date {
margin-right: 4px;
}
}
`;
71 changes: 42 additions & 29 deletions packages/web/src/components/common/line-graph/LineGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BigNumber from "bignumber.js";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useEffect, useState, useMemo } from "react";
import { LineGraphTooltipWrapper, LineGraphWrapper } from "./LineGraph.styles";

function calculateSmoothing(pointA: Point, pointB: Point) {
Expand Down Expand Up @@ -61,6 +61,7 @@ export interface LineGraphProps {
width?: number;
height?: number;
point?: boolean;
firstPointColor?: string;
}

interface Point {
Expand Down Expand Up @@ -97,6 +98,7 @@ const LineGraph: React.FC<LineGraphProps> = ({
width = VIEWPORT_DEFAULT_WIDTH,
height = VIEWPORT_DEFAULT_HEIGHT,
point,
firstPointColor,
}) => {
const COMPONENT_ID = (Math.random() * 100000).toString();
const [activated, setActivated] = useState(false);
Expand Down Expand Up @@ -218,6 +220,13 @@ const LineGraph: React.FC<LineGraphProps> = ({
[getGraphLine, height, width],
);

const firstPoint = useMemo(() => {
if (points.length === 0) {
return { x: 0, y: 0};
}
return points[0];
}, [points]);

return (
<LineGraphWrapper
className={className}
Expand All @@ -235,7 +244,7 @@ const LineGraph: React.FC<LineGraphProps> = ({
<stop offset="100%" stopColor={gradientEndColor} />
</linearGradient>
</defs>
<g>
<g width={width}>
<path
fill={`url(#gradient${COMPONENT_ID})`}
stroke={color}
Expand All @@ -259,58 +268,62 @@ const LineGraph: React.FC<LineGraphProps> = ({
/>
))}
</g>
{isFocus() && currentPoint && (
{
<g>
<line
stroke={color}
stroke={firstPointColor ? firstPointColor : color}
strokeWidth={1}
x1={0}
y1={currentPoint.y}
y1={firstPoint.y}
x2={width}
y2={currentPoint.y}
strokeDasharray={3}
/>
<line
stroke={color}
strokeWidth={1}
x1={currentPoint.x}
y1={0}
x2={currentPoint.x}
y2={height}
y2={firstPoint.y}
strokeDasharray={3}
/>
<circle
cx={currentPoint.x}
cy={currentPoint.y}
r={3}
stroke={color}
fill={color}
/>
{isFocus() && currentPoint && (
<line
stroke={color}
strokeWidth={1}
x1={currentPoint.x}
y1={0}
x2={currentPoint.x}
y2={height}
strokeDasharray={3}
/>
)}
{isFocus() && currentPoint && (
<circle
cx={currentPoint.x}
cy={currentPoint.y}
r={3}
stroke={color}
fill={color}
/>
)}
</g>
)}
}
</svg>
{isFocus() && currentPointIndex > -1 && (
<LineGraphTooltipWrapper
x={
currentPoint?.x && currentPoint?.x > width / 2
? currentPoint?.x - 157
? currentPoint?.x - 150
: currentPoint?.x || 0
}
y={currentPoint?.y || 0}
>
<div className="tooltip-header">
<span className="value">{`$${BigNumber(
datas[currentPointIndex].value,
).toString()}`}</span>
</div>
<div className="tooltip-body">
<span className="date">
{parseTime(datas[currentPointIndex].time).date}
</span>
<span className="time">
{parseTime(datas[currentPointIndex].time).time}
</span>
</div>
<div className="tooltip-body">
<span className="value">{`$ ${BigNumber(
datas[currentPointIndex].value,
).toString()}`}</span>
</div>
</LineGraphTooltipWrapper>
)}
</LineGraphWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@ export const wrapper = (theme: Theme) => css`
fill: ${theme.color.icon03};
}
}
&:hover {
span {
color: ${theme.color.text03};
}
transition: all 0.3s ease;
svg {
* {
fill: ${theme.color.icon07};
}
}
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const SearchMenuModal: React.FC<SearchMenuModalProps> = ({
const onClickItem = (symbol: string) => {
location.href = "/tokens/" + symbol;
};
console.log(isFetched, "isFetched");

useEffect(() => {
const closeMenu = (e: MouseEvent) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const SelectTab: React.FC<SelectTabProps> = ({
buttonClassName,
}) => {
return (
<SelectTabWrapper>
<SelectTabWrapper className="select-tab-wrapper">
{list.map((type, idx) => (
<SelectButton
key={idx}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe("WalletConnectorButton Component", () => {
connected={false}
account={null}
connectAdenaClient={() => { }}
disconnectWallet={() => { }}
/>
</GnoswapThemeProvider>
</JotaiProvider>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ Disconnected.args = {
connected: false,
account: null,
connectAdenaClient: action("connectAdenaClient"),
disconnectWallet: action("disconnectWallet"),
};

export const Connected = Template.bind({});
Connected.args = {
connected: true,
account: defaultAccountInfo,
connectAdenaClient: action("connectAdenaClient"),
disconnectWallet: action("disconnectWallet"),
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ interface WalletConnectProps {
connected: boolean;
connectAdenaClient: () => void;
themeKey: "dark" | "light";
disconnectWallet: () => void;
}

const WalletConnectorButton: React.FC<WalletConnectProps> = ({
account,
connected,
connectAdenaClient,
themeKey,
disconnectWallet,
}) => {
const [toggle, setToggle] = useAtom(CommonState.headerToggle);

Expand Down Expand Up @@ -86,6 +88,7 @@ const WalletConnectorButton: React.FC<WalletConnectProps> = ({
account={account}
connected={connected}
connectAdenaClient={connectAdenaClient}
disconnectWallet={disconnectWallet}
onMenuToggle={onMenuToggle}
themeKey={themeKey}
/>
Expand Down
Loading

0 comments on commit fd913b6

Please sign in to comment.