From 12beea8f810d940f029d84f47c6a76a0a6771cb1 Mon Sep 17 00:00:00 2001 From: jtpark Date: Thu, 17 Aug 2023 17:32:27 +0900 Subject: [PATCH] feat: Develop swap pages components --- .../components/common/button/Button.spec.tsx | 2 +- .../components/common/button/Button.styles.ts | 2 + .../src/components/common/button/Button.tsx | 1 + .../src/components/common/icons/IconLink.tsx | 19 ++ .../src/components/common/icons/IconNote.tsx | 16 +- .../components/common/icons/IconRouter.tsx | 17 ++ .../common/icons/IconStrokeArrowDown.tsx | 9 +- .../common/icons/IconStrokeArrowUp.tsx | 9 +- .../components/common/icons/IconVector.tsx | 20 ++ .../common/tooltip/Tooltip.styles.ts | 2 +- .../src/components/common/tooltip/Tooltip.tsx | 1 + .../SwapButtonTooltip.spec.tsx | 23 ++ .../SwapButtonTooltip.stories.tsx | 44 ++++ .../SwapButtonTooltip.styles.ts | 20 ++ .../swap-button-tooltip/SwapButtonTooltip.tsx | 38 ++++ .../SwapCardAutoRouter.spec.tsx | 47 ++++ .../SwapCardAutoRouter.stories.tsx | 62 ++++++ .../SwapCardAutoRouter.styles.ts | 103 +++++++++ .../SwapCardAutoRouter.tsx | 115 ++++++++++ .../SwapCardContentDetail.spec.tsx | 51 +++++ .../SwapCardContentDetail.stories.tsx | 62 ++++++ .../SwapCardContentDetail.styles.ts | 208 ++++++++++++++++++ .../SwapCardContentDetail.tsx | 82 +++++++ .../SwapCardContent.spec.tsx | 51 +++++ .../SwapCardContent.stories.tsx | 66 ++++++ .../SwapCardContent.styles.ts | 104 +++++++++ .../swap-card-content/SwapCardContent.tsx | 114 ++++++++++ .../SwapCardFeeInfo.spec.tsx | 23 ++ .../SwapCardFeeInfo.stories.tsx | 38 ++++ .../SwapCardFeeInfo.styles.ts | 155 +++++++++++++ .../swap-card-fee-info/SwapCardFeeInfo.tsx | 56 +++++ .../swap-card-header/SwapCardHeader.spec.tsx | 18 ++ .../SwapCardHeader.stories.tsx | 32 +++ .../swap-card-header/SwapCardHeader.styles.ts | 27 +++ .../swap/swap-card-header/SwapCardHeader.tsx | 18 ++ .../swap/swap-card/SwapCard.spec.tsx | 57 +++++ .../swap/swap-card/SwapCard.stories.tsx | 72 ++++++ .../swap/swap-card/SwapCard.styles.ts | 32 +++ .../components/swap/swap-card/SwapCard.tsx | 124 +++++++++++ .../swap-liquidity/SwapLiquidity.spec.tsx | 21 ++ .../swap-liquidity/SwapLiquidity.stories.tsx | 36 +++ .../swap-liquidity/SwapLiquidity.styles.ts | 147 +++++++++++++ .../swap/swap-liquidity/SwapLiquidity.tsx | 76 +++++++ .../src/components/swap/swap/Swap.styles.ts | 6 - .../web/src/components/swap/swap/Swap.tsx | 8 - packages/web/src/constants/theme.constant.ts | 7 + .../swap-container/SwapContainer.tsx | 90 +++++++- .../SwapLiquidityContainer.tsx | 51 +++++ .../layouts/swap-layout/SwapLayout.styles.ts | 87 ++++++-- .../src/layouts/swap-layout/SwapLayout.tsx | 28 ++- packages/web/src/pages/swap.tsx | 2 + packages/web/src/styles/ThemeTypes.ts | 2 + 52 files changed, 2442 insertions(+), 59 deletions(-) create mode 100644 packages/web/src/components/common/icons/IconLink.tsx create mode 100644 packages/web/src/components/common/icons/IconRouter.tsx create mode 100644 packages/web/src/components/common/icons/IconVector.tsx create mode 100644 packages/web/src/components/swap/swap-button-tooltip/SwapButtonTooltip.spec.tsx create mode 100644 packages/web/src/components/swap/swap-button-tooltip/SwapButtonTooltip.stories.tsx create mode 100644 packages/web/src/components/swap/swap-button-tooltip/SwapButtonTooltip.styles.ts create mode 100644 packages/web/src/components/swap/swap-button-tooltip/SwapButtonTooltip.tsx create mode 100644 packages/web/src/components/swap/swap-card-auto-router/SwapCardAutoRouter.spec.tsx create mode 100644 packages/web/src/components/swap/swap-card-auto-router/SwapCardAutoRouter.stories.tsx create mode 100644 packages/web/src/components/swap/swap-card-auto-router/SwapCardAutoRouter.styles.ts create mode 100644 packages/web/src/components/swap/swap-card-auto-router/SwapCardAutoRouter.tsx create mode 100644 packages/web/src/components/swap/swap-card-content-detail/SwapCardContentDetail.spec.tsx create mode 100644 packages/web/src/components/swap/swap-card-content-detail/SwapCardContentDetail.stories.tsx create mode 100644 packages/web/src/components/swap/swap-card-content-detail/SwapCardContentDetail.styles.ts create mode 100644 packages/web/src/components/swap/swap-card-content-detail/SwapCardContentDetail.tsx create mode 100644 packages/web/src/components/swap/swap-card-content/SwapCardContent.spec.tsx create mode 100644 packages/web/src/components/swap/swap-card-content/SwapCardContent.stories.tsx create mode 100644 packages/web/src/components/swap/swap-card-content/SwapCardContent.styles.ts create mode 100644 packages/web/src/components/swap/swap-card-content/SwapCardContent.tsx create mode 100644 packages/web/src/components/swap/swap-card-fee-info/SwapCardFeeInfo.spec.tsx create mode 100644 packages/web/src/components/swap/swap-card-fee-info/SwapCardFeeInfo.stories.tsx create mode 100644 packages/web/src/components/swap/swap-card-fee-info/SwapCardFeeInfo.styles.ts create mode 100644 packages/web/src/components/swap/swap-card-fee-info/SwapCardFeeInfo.tsx create mode 100644 packages/web/src/components/swap/swap-card-header/SwapCardHeader.spec.tsx create mode 100644 packages/web/src/components/swap/swap-card-header/SwapCardHeader.stories.tsx create mode 100644 packages/web/src/components/swap/swap-card-header/SwapCardHeader.styles.ts create mode 100644 packages/web/src/components/swap/swap-card-header/SwapCardHeader.tsx create mode 100644 packages/web/src/components/swap/swap-card/SwapCard.spec.tsx create mode 100644 packages/web/src/components/swap/swap-card/SwapCard.stories.tsx create mode 100644 packages/web/src/components/swap/swap-card/SwapCard.styles.ts create mode 100644 packages/web/src/components/swap/swap-card/SwapCard.tsx create mode 100644 packages/web/src/components/swap/swap-liquidity/SwapLiquidity.spec.tsx create mode 100644 packages/web/src/components/swap/swap-liquidity/SwapLiquidity.stories.tsx create mode 100644 packages/web/src/components/swap/swap-liquidity/SwapLiquidity.styles.ts create mode 100644 packages/web/src/components/swap/swap-liquidity/SwapLiquidity.tsx delete mode 100644 packages/web/src/components/swap/swap/Swap.styles.ts delete mode 100644 packages/web/src/components/swap/swap/Swap.tsx create mode 100644 packages/web/src/containers/swap-liquidity-container/SwapLiquidityContainer.tsx diff --git a/packages/web/src/components/common/button/Button.spec.tsx b/packages/web/src/components/common/button/Button.spec.tsx index d77e818c6..c561990e7 100644 --- a/packages/web/src/components/common/button/Button.spec.tsx +++ b/packages/web/src/components/common/button/Button.spec.tsx @@ -36,7 +36,7 @@ describe("Button Component", () => { height: 50, justify: "space-between", padding: "0px 10px", - textColor: "", + textColor: "text01", }} /> diff --git a/packages/web/src/components/common/button/Button.styles.ts b/packages/web/src/components/common/button/Button.styles.ts index b755b9bcd..2d276982c 100644 --- a/packages/web/src/components/common/button/Button.styles.ts +++ b/packages/web/src/components/common/button/Button.styles.ts @@ -40,6 +40,7 @@ export const ButtonWrapper = styled.button` transition: background-color 0.3s ease; background-color: ${({ hierarchy, bgColor, theme }) => { if (hierarchy === ButtonHierarchy.Primary) return theme.color.background04; + if (hierarchy === ButtonHierarchy.Gray) return theme.color.background17; if (hierarchy === ButtonHierarchy.Dark) return theme.color.background05; return theme.color[bgColor ?? "background04"]; }}; @@ -80,6 +81,7 @@ export const StyledText = styled.span` ${({ fontType }) => fonts[fontType ?? "body9"]}; color: ${({ theme, textColor, hierarchy }) => { if (hierarchy === ButtonHierarchy.Primary) return theme.color.text09; + if (hierarchy === ButtonHierarchy.Gray) return theme.color.text20; return theme.color[textColor ?? "text03"]; }}; `; diff --git a/packages/web/src/components/common/button/Button.tsx b/packages/web/src/components/common/button/Button.tsx index b28570600..285b7391b 100644 --- a/packages/web/src/components/common/button/Button.tsx +++ b/packages/web/src/components/common/button/Button.tsx @@ -12,6 +12,7 @@ interface ButtonProps { export enum ButtonHierarchy { Primary = "Primary", + Gray = "Gray", Dark = "Dark", } diff --git a/packages/web/src/components/common/icons/IconLink.tsx b/packages/web/src/components/common/icons/IconLink.tsx new file mode 100644 index 000000000..61036c8a6 --- /dev/null +++ b/packages/web/src/components/common/icons/IconLink.tsx @@ -0,0 +1,19 @@ +const IconLink = ({ className }: { className?: string }) => ( + + + +); + +export default IconLink; diff --git a/packages/web/src/components/common/icons/IconNote.tsx b/packages/web/src/components/common/icons/IconNote.tsx index 327505a11..af947fa1d 100644 --- a/packages/web/src/components/common/icons/IconNote.tsx +++ b/packages/web/src/components/common/icons/IconNote.tsx @@ -1,17 +1,17 @@ -const Icon = ({ className }: { className?: string }) => ( +const IconNote = ({ className }: { className?: string }) => ( ); -export default Icon; +export default IconNote; diff --git a/packages/web/src/components/common/icons/IconRouter.tsx b/packages/web/src/components/common/icons/IconRouter.tsx new file mode 100644 index 000000000..cddc63ca2 --- /dev/null +++ b/packages/web/src/components/common/icons/IconRouter.tsx @@ -0,0 +1,17 @@ +const IconRouter = ({ className }: { className?: string }) => ( + + + +); + +export default IconRouter; diff --git a/packages/web/src/components/common/icons/IconStrokeArrowDown.tsx b/packages/web/src/components/common/icons/IconStrokeArrowDown.tsx index 14137dbb1..c794aebeb 100644 --- a/packages/web/src/components/common/icons/IconStrokeArrowDown.tsx +++ b/packages/web/src/components/common/icons/IconStrokeArrowDown.tsx @@ -1,4 +1,10 @@ -const IconStrokeArrowDown = ({ className }: { className?: string }) => ( +const IconStrokeArrowDown = ({ + className, + onClick, +}: { + className?: string; + onClick?: () => void; +}) => ( ( fill="none" xmlns="http://www.w3.org/2000/svg" className={className} + onClick={onClick} > ( +const IconStrokeArrowUp = ({ + className, + onClick, +}: { + className?: string; + onClick?: () => void; +}) => ( ( fill="none" xmlns="http://www.w3.org/2000/svg" className={className} + onClick={onClick} > ( + + + +); + +export default IconVector; diff --git a/packages/web/src/components/common/tooltip/Tooltip.styles.ts b/packages/web/src/components/common/tooltip/Tooltip.styles.ts index 2a058b28f..b63ef1f1a 100644 --- a/packages/web/src/components/common/tooltip/Tooltip.styles.ts +++ b/packages/web/src/components/common/tooltip/Tooltip.styles.ts @@ -7,5 +7,5 @@ export const Content = styled.div` border-radius: 8px; box-sizing: border-box; width: max-content; - max-width: calc(100vw - 10px); + // max-width: calc(100vw - 10px); `; diff --git a/packages/web/src/components/common/tooltip/Tooltip.tsx b/packages/web/src/components/common/tooltip/Tooltip.tsx index 1ac8a732a..ee8180455 100644 --- a/packages/web/src/components/common/tooltip/Tooltip.tsx +++ b/packages/web/src/components/common/tooltip/Tooltip.tsx @@ -91,6 +91,7 @@ const Tooltip: React.FC> = ({ data-state={open ? "open" : "closed"} style={{ display: "flex", + width: "100%", }} > {children} diff --git a/packages/web/src/components/swap/swap-button-tooltip/SwapButtonTooltip.spec.tsx b/packages/web/src/components/swap/swap-button-tooltip/SwapButtonTooltip.spec.tsx new file mode 100644 index 000000000..689360aff --- /dev/null +++ b/packages/web/src/components/swap/swap-button-tooltip/SwapButtonTooltip.spec.tsx @@ -0,0 +1,23 @@ +import { render } from "@testing-library/react"; +import { Provider as JotaiProvider } from "jotai"; +import GnoswapThemeProvider from "@providers/gnoswap-theme-provider/GnoswapThemeProvider"; +import SwapButtonTooltip from "./SwapButtonTooltip"; +import { dummySwapGasInfo } from "@containers/swap-container/SwapContainer"; +import Button from "@components/common/button/Button"; + +describe("SwapButtonTooltip Component", () => { + it("SwapButtonTooltip render", () => { + const mockProps = { + swapGasInfo: dummySwapGasInfo, + children: , + }; + + render( + + + + + , + ); + }); +}); diff --git a/packages/web/src/components/swap/swap-button-tooltip/SwapButtonTooltip.stories.tsx b/packages/web/src/components/swap/swap-button-tooltip/SwapButtonTooltip.stories.tsx new file mode 100644 index 000000000..60dfa7c57 --- /dev/null +++ b/packages/web/src/components/swap/swap-button-tooltip/SwapButtonTooltip.stories.tsx @@ -0,0 +1,44 @@ +import React from "react"; +import { ComponentStory, ComponentMeta } from "@storybook/react"; +import SwapButtonTooltip from "./SwapButtonTooltip"; +import { css, Theme } from "@emotion/react"; +import { dummySwapGasInfo } from "@containers/swap-container/SwapContainer"; +import Button, { ButtonHierarchy } from "@components/common/button/Button"; + +export default { + title: "swap/SwapButtonTooltip", + component: SwapButtonTooltip, +} as ComponentMeta; + +const Template: ComponentStory = args => ( +
+
+ +
+
+); + +export const Default = Template.bind({}); +Default.args = { + swapGasInfo: dummySwapGasInfo, + children: ( +