Skip to content

Commit

Permalink
Merge pull request #283 from gnoswap-labs/GSW-DEV-Fix-Common-Page
Browse files Browse the repository at this point in the history
  • Loading branch information
akstar82 authored Dec 19, 2023
2 parents f103415 + 3ba67bb commit 246a1ea
Show file tree
Hide file tree
Showing 33 changed files with 176 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export interface BarAreaGraphProps {
isHiddenStart?: boolean;
currentIndex?: number;
tokenA: TokenModel;
tokenB: TokenModel
tokenB: TokenModel;
themeKey: "dark" | "light";
}

const VIEWPORT_DEFAULT_WIDTH = 400;
Expand Down Expand Up @@ -59,6 +60,7 @@ const BarAreaGraph: React.FC<BarAreaGraphProps> = ({
isHiddenStart,
tokenA,
tokenB,
themeKey,
}) => {
const existTickRage = (!minTick || !maxTick) === false;
const [mouseDown, setMouseDown] = useState(false);
Expand Down Expand Up @@ -245,7 +247,7 @@ const BarAreaGraph: React.FC<BarAreaGraphProps> = ({
bins={bins}
tokenA={tokenA}
tokenB={tokenB}
themeKey={"dark"}
themeKey={themeKey}
mouseover
position="top"
offset={40}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface MyPositionCardListProps {
showPagination: boolean;
showLoadMore: boolean;
width: number;
themeKey: "dark" | "light";
}

const MyPositionCardList: React.FC<MyPositionCardListProps> = ({
Expand All @@ -32,13 +33,14 @@ const MyPositionCardList: React.FC<MyPositionCardListProps> = ({
onScroll,
showPagination,
width,
themeKey,
}) => (
<CardListWrapper>
<GridWrapper ref={divRef} onScroll={onScroll}>
{
positions.length > 0 &&
positions.map((position, idx) => (
<MyPositionCard currentIndex={idx} position={position} key={idx} movePoolDetail={movePoolDetail} mobile={mobile} />
<MyPositionCard currentIndex={idx} position={position} key={idx} movePoolDetail={movePoolDetail} mobile={mobile} themeKey={themeKey}/>
))}
{isFetched &&
positions.length > 0 && positions.length < 4 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ interface MyPositionCardProps {
movePoolDetail: (id: string) => void;
mobile: boolean;
currentIndex?: number;
themeKey: "dark" | "light";
}

const MyPositionCard: React.FC<MyPositionCardProps> = ({
position,
movePoolDetail,
mobile,
currentIndex,
themeKey,
}) => {
const GRAPH_WIDTH = mobile ? 226 : 258;
const GRAPH_HEIGHT = 80;
Expand Down Expand Up @@ -194,6 +196,7 @@ const MyPositionCard: React.FC<MyPositionCardProps> = ({
tokenB={tokenB}
isHiddenStart={isHiddenStart}
currentIndex={currentIndex}
themeKey={themeKey}
/>
</div>
<div className="min-max-price">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const NotificationItem: React.FC<ItemProps> = ({ groups, breakpoint }) => {
/>
</DoubleLogo>
)}
<div className="content-wrap">{item.content}</div>
<div className="content-wrap" dangerouslySetInnerHTML={{ __html: item.content || ""}} />
</div>
</div>
{item.status === "SUCCESS" ? (
Expand Down Expand Up @@ -116,7 +116,7 @@ const NotificationItem: React.FC<ItemProps> = ({ groups, breakpoint }) => {
/>
</DoubleLogoWrapperTest>
)}
<span className="summary-content">{item.content}</span>
<div className="summary-content" dangerouslySetInnerHTML={{ __html: item.content || ""}} />
{item.status === "SUCCESS" ? (
<IconCircleInCheck className="success-icon status-icon" />
) : item.status === "FAILED" ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const TxsSummaryItem = styled.div`
position: relative;
width: 100%;
min-height: 40px;
padding: 8px 24px;
padding: 12px 24px;
height: auto;
cursor: pointer;
${fonts.body12};
Expand All @@ -130,6 +130,9 @@ export const TxsSummaryItem = styled.div`
.summary-content {
width: 100%;
padding: 0px 10px 0px 44px;
span {
font-weight: 500;
}
}
.status-icon {
margin-left: 8px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const NotificationList: React.FC<NotificationListProps> = ({
onClearAll,
}) => {
const listRef = useRef<HTMLDivElement | null>(null);

return (
<>
<NotificationListWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const PoolGraph: React.FC<PoolGraphProps> = ({
.attr("y1", 0)
.attr("y2", boundsHeight)
.attr("stroke-dasharray", 4)
.attr("stroke", "#FFFFFF")
.attr("stroke", `${themeKey === "dark" ? "#FFFFFF": "#596782"}`)
.attr("stroke-width", 0.5);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ export const SelectTokenIncentivizeWrapper = styled.div`
&.token-list-wrapper-auto-height {
height: auto;
}
${media.mobile} {
height: 248px;
}
overflow-y: auto;
.no-data-found {
${mixins.flexbox("row", "center", "center")};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface EarnMyPositionContentProps {
width: number;
loadMore: boolean;
onClickLoadMore?: () => void;
themeKey: "dark" | "light";
}

const EarnMyPositionsContent: React.FC<EarnMyPositionContentProps> = ({
Expand All @@ -39,6 +40,7 @@ const EarnMyPositionsContent: React.FC<EarnMyPositionContentProps> = ({
width,
loadMore,
onClickLoadMore,
themeKey,
}) => {
if (!connected || isSwitchNetwork) {
return (
Expand Down Expand Up @@ -67,6 +69,7 @@ const EarnMyPositionsContent: React.FC<EarnMyPositionContentProps> = ({
width={width}
loadMore={loadMore}
onClickLoadMore={onClickLoadMore}
themeKey={themeKey}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface EarnMyPositionsProps {
width: number;
loadMore: boolean;
onClickLoadMore?: () => void;
themeKey: "dark" | "light";
}

const EarnMyPositions: React.FC<EarnMyPositionsProps> = ({
Expand All @@ -46,6 +47,7 @@ const EarnMyPositions: React.FC<EarnMyPositionsProps> = ({
width,
loadMore,
onClickLoadMore,
themeKey,
}) => (
<EarnMyPositionswrapper>
<EarnMyPositionsHeader
Expand All @@ -72,6 +74,7 @@ const EarnMyPositions: React.FC<EarnMyPositionsProps> = ({
width={width}
loadMore={loadMore}
onClickLoadMore={onClickLoadMore}
themeKey={themeKey}
/>
</EarnMyPositionswrapper>
);
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/components/home/home-swap/HomeSwap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const HomeSwap: React.FC<HomeSwapProps> = ({
swapTokenInfo.tokenABalance.replace(/,/g, ""),
).toString();
setFromAmount(formatValue);
changeTokenAAmount(formatValue);
}
}, [swapTokenInfo.tokenABalance, connected, setFromAmount]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const PoolIncentivizeSelectPoolItemWrapper = styled.div<Props>`
align-items: center;
.token-pair-name {
color: ${({ theme }) => theme.color.text03};
color: ${({ theme }) => theme.color.text02};
${fonts.body9}
${media.mobile} {
${fonts.body11}
Expand All @@ -43,7 +43,7 @@ export const PoolIncentivizeSelectPoolItemWrapper = styled.div<Props>`
.liquidity {
height: 14px;
color: ${({ theme }) => theme.color.text03};
color: ${({ theme }) => theme.color.text02};
${fonts.body9}
line-height: 100%;
${media.mobile} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PoolIncentivizeSelectPoolItemWrapper, PoolIncentivizeSelectPoolItemDefa
import DoubleLogo from "@components/common/double-logo/DoubleLogo";
import Badge, { BADGE_TYPE } from "@components/common/badge/Badge";
import { PoolSelectItemInfo } from "@models/pool/info/pool-select-item-info";
import { convertLargePrice } from "@utils/stake-position-utils";

export interface PoolIncentivizeSelectPoolItemProps {
poolSelectItem: PoolSelectItemInfo | null;
Expand Down Expand Up @@ -43,7 +44,7 @@ const PoolIncentivizeSelectPoolItem: React.FC<PoolIncentivizeSelectPoolItemProps
if (!poolSelectItem) {
return "-";
}
return `$${poolSelectItem.liquidityAmount}`;
return `$${convertLargePrice(poolSelectItem.liquidityAmount)}`;
}, [poolSelectItem]);

const onClickItem = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,9 @@ const customSort = (a: PoolSelectItemInfo, b: PoolSelectItemInfo) => {
} else if (!isAGnotGns && isBGnotGns) {
return 1;
} else {
if (isAGnotGns && isBGnotGns) {
const feeOrder = [100, 500, 3000, 10000];
const feeA = parseInt(a.fee, 10);
const feeB = parseInt(b.fee, 10);
const indexA = feeOrder.indexOf(feeA);
const indexB = feeOrder.indexOf(feeB);
return indexA - indexB;
} else {
const liquidityA = parseFloat(a.liquidityAmount);
const liquidityB = parseFloat(b.liquidityAmount);
return liquidityB - liquidityA;
}
const liquidityA = parseFloat(a.liquidityAmount);
const liquidityB = parseFloat(b.liquidityAmount);
return liquidityB - liquidityA;
}
};

Expand All @@ -90,9 +81,11 @@ const PoolIncentivize: React.FC<PoolIncentivizeProps> = ({
const { getGnotPath } = useGnotToGnot();

const selectedItem = useMemo((): PoolSelectItemInfo | null => {
return selectedPool ? PoolMapper.toPoolSelectItemInfo(selectedPool) : null;
const temp = selectedPool ? PoolMapper.toPoolSelectItemInfo(selectedPool) : null;
return temp;
}, [selectedPool]);

console.log(selectedItem, "selectedItem");

const poolSelectItems = useMemo((): PoolSelectItemInfo[] => {
return pools.map(PoolMapper.toPoolSelectItemInfo).map((item: PoolSelectItemInfo) => {
return {
Expand All @@ -101,16 +94,19 @@ const PoolIncentivize: React.FC<PoolIncentivizeProps> = ({
...item.tokenA,
symbol: getGnotPath(item.tokenA).symbol,
logoURI: getGnotPath(item.tokenA).logoURI,
path: getGnotPath(item.tokenA).path,
},
tokenB: {
...item.tokenB,
symbol: getGnotPath(item.tokenB).symbol,
logoURI: getGnotPath(item.tokenB).logoURI,
path: getGnotPath(item.tokenB).path,
},
};
}).sort(customSort);
}, [pools]);

console.log(pools, "pools");

return (
<PoolIncentivizeWrapper>
<h3 className="title">Incentivize Pool</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ export const SelectDistributionDateInputWrapper = styled.div`
& .calendar-wrapper {
position: absolute;
height: 0;
max-height: 0;
top: 5px;
width: 100%;
min-width: 315px;
z-index: 10;
height: 0;
max-height: 0;
display: none;
${media.mobile} {
transition: height 0.5s ease;
transition: max-height 0.5s ease;
position: fixed;
top: auto;
bottom: 0;
Expand All @@ -76,9 +76,9 @@ export const SelectDistributionDateInputWrapper = styled.div`
}
& .open {
display: block;
height: 305px;
max-height: 305px;
${media.mobile} {
height: 305px;
max-height: 305px;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const PoolIncentivizeSelectPeriodBoxItem = styled.div`
flex-direction: row;
width: 100%;
padding: 8px 24px;
color: ${({ theme }) => theme.color.text03};
color: ${({ theme }) => theme.color.text02};
${fonts.body12}
align-items: center;
justify-content: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const SwapCardAutoRouterItem: React.FC<SwapCardAutoRouterItemProps> = ({
<div className="row">
<MissingLogo symbol={swapSummaryInfo.tokenA.symbol} url={swapSummaryInfo.tokenA.logoURI} className="token-logo" width={24} mobileWidth={24}/>
<div className="left-box">
<div className="left-badge">{swapRouteInfo.version}</div>
{/* {routeInfos.length < 3 && <div className="left-badge">{swapRouteInfo.version}</div>} */}
<span>{weightStr}</span>
</div>
<DotLine />
Expand All @@ -83,7 +83,7 @@ const SwapCardAutoRouterItem: React.FC<SwapCardAutoRouterItemProps> = ({
/>
<h1>{routeInfo.fee}</h1>
</div>
<DotLine />
{index < 2 && <DotLine />}
</React.Fragment>
))}
<MissingLogo symbol={swapSummaryInfo.tokenB.symbol} url={swapSummaryInfo.tokenB.logoURI} className="token-logo" width={24} mobileWidth={24}/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { PoolPositionModel } from "@models/position/pool-position-model";
import { useRouter } from "next/router";
import React, { useCallback, useEffect, useRef, useState, useMemo } from "react";
import { ValuesType } from "utility-types";
import { useAtomValue } from "jotai";
import { ThemeState } from "@states/index";

export const POSITION_CONTENT_LABEL = {
VALUE: "Value",
Expand Down Expand Up @@ -41,6 +43,7 @@ const EarnMyPositionContainer: React.FC<
const { isError, availableStake, getPositions, isFetchedPosition } = usePositionData();
const [positions, setPositions] = useState<PoolPositionModel[]>([]);
const [mobile, setMobile] = useState(false);
const themeKey = useAtomValue(ThemeState.themeKey);

const handleResize = () => {
if (typeof window !== "undefined") {
Expand Down Expand Up @@ -140,6 +143,7 @@ const EarnMyPositionContainer: React.FC<
width={width}
loadMore={page === 1}
onClickLoadMore={handleClickLoadMore}
themeKey={themeKey}
/>
);
};
Expand Down
Loading

0 comments on commit 246a1ea

Please sign in to comment.