From 61fba4ae0902298234e4358567be7ab55a4430c3 Mon Sep 17 00:00:00 2001 From: Aeron Park <21303012+AkydA@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:58:57 +0900 Subject: [PATCH] GSW-1508 Refactor governance (#513) * refactor: move components * remove: unused component * remove: unused components * refactor: clean import path --- packages/web/.env.example | 2 +- .../learn-more-modal/LearnMoreModal.spec.tsx | 18 -- .../LearnMoreModal.stories.tsx | 18 -- .../learn-more-modal/LearnMoreModal.styles.ts | 177 ------------------ .../learn-more-modal/LearnMoreModal.tsx | 172 ----------------- .../GnoswapServiceProvider.tsx | 51 ++--- .../web/src/repositories/leaderboard/index.ts | 2 + .../web/src/repositories/liquidity/index.ts | 3 - .../liquidity/liquidity-repository-mock.ts | 28 --- .../liquidity/liquidity-repository.ts | 18 -- .../request/add-liquidity-request.ts | 11 -- .../liquidity/request/claim-reward-request.ts | 3 - .../repositories/liquidity/request/index.ts | 3 - .../request/remove-liquidity-request.ts | 3 - .../response/add-liquidity-response.ts | 3 - .../response/claim-reward-response.ts | 3 - .../repositories/liquidity/response/index.ts | 6 - .../liquidity-detail-info-response.ts | 31 --- .../liquidity-detail-list-response.ts | 37 ---- .../response/liquidity-reward-response.ts | 25 --- .../response/remove-liquidity-response.ts | 3 - packages/web/src/repositories/pool/index.ts | 4 +- .../web/src/repositories/position/index.ts | 2 + .../web/src/repositories/staking/index.ts | 3 - .../src/repositories/staking/request/index.ts | 1 - .../staking/request/stake-request.ts | 5 - .../staking/request/unstake-request.ts | 3 - .../repositories/staking/response/index.ts | 2 - .../staking/response/stake-response.ts | 3 - .../staking/response/unstake-response.ts | 3 - .../staking/staking-repository-mock.ts | 17 -- .../staking/staking-repository.ts | 9 - packages/web/src/repositories/token/index.ts | 1 + packages/web/src/repositories/wallet/index.ts | 2 + .../web/src/views/governance/Governance.tsx | 4 +- .../src/views/governance/GovernanceLayout.tsx | 19 +- .../GovernanceSummary.spec.tsx | 0 .../GovernanceSummary.stories.tsx | 0 .../GovernanceSummary.styles.ts | 0 .../governance-summary/GovernanceSummary.tsx | 7 +- .../GovernanceDetail.spec.tsx | 0 .../GovernanceDetail.stories.tsx | 0 .../GovernanceDetail.styles.ts | 0 .../governance-detail/GovernanceDetail.tsx | 6 +- .../GovernanceDetailInfo.spec.tsx | 0 .../GovernanceDetailInfo.stories.tsx | 0 .../GovernanceDetailInfo.styles.ts | 0 .../GovernanceDetailInfo.tsx | 15 +- .../proposals-list/ProposalList.spec.tsx | 0 .../proposals-list/ProposalList.styles.ts | 0 .../proposals-list/ProposalList.tsx | 17 +- .../CreateProposalModal.spec.tsx | 0 .../CreateProposalModal.styles.ts | 0 .../CreateProposalModal.tsx | 31 +-- .../proposal-detail/ProposalDetail.spec.tsx | 0 .../ProposalDetail.stories.tsx | 0 .../proposal-detail/ProposalDetail.styles.ts | 0 .../proposal-detail/ProposalDetail.tsx | 20 +- .../ProposalDetailSekeleton.tsx | 0 .../proposal-header/ProposalHeader.spec.tsx | 0 .../ProposalHeader.stories.tsx | 0 .../proposal-header/ProposalHeader.styles.ts | 0 .../proposal-header/ProposalHeader.tsx | 4 +- .../ViewProposalModal.spec.tsx | 0 .../ViewProposalModal.stories.tsx | 0 .../ViewProposalModal.styles.ts | 0 .../view-proposal-modal/ViewProposalModal.tsx | 34 ++-- .../GovernanceContainer.tsx | 19 +- .../ProposalListContainer.tsx | 8 +- 69 files changed, 125 insertions(+), 731 deletions(-) delete mode 100644 packages/web/src/components/governance/learn-more-modal/LearnMoreModal.spec.tsx delete mode 100644 packages/web/src/components/governance/learn-more-modal/LearnMoreModal.stories.tsx delete mode 100644 packages/web/src/components/governance/learn-more-modal/LearnMoreModal.styles.ts delete mode 100644 packages/web/src/components/governance/learn-more-modal/LearnMoreModal.tsx create mode 100644 packages/web/src/repositories/leaderboard/index.ts delete mode 100644 packages/web/src/repositories/liquidity/index.ts delete mode 100644 packages/web/src/repositories/liquidity/liquidity-repository-mock.ts delete mode 100644 packages/web/src/repositories/liquidity/liquidity-repository.ts delete mode 100644 packages/web/src/repositories/liquidity/request/add-liquidity-request.ts delete mode 100644 packages/web/src/repositories/liquidity/request/claim-reward-request.ts delete mode 100644 packages/web/src/repositories/liquidity/request/index.ts delete mode 100644 packages/web/src/repositories/liquidity/request/remove-liquidity-request.ts delete mode 100644 packages/web/src/repositories/liquidity/response/add-liquidity-response.ts delete mode 100644 packages/web/src/repositories/liquidity/response/claim-reward-response.ts delete mode 100644 packages/web/src/repositories/liquidity/response/index.ts delete mode 100644 packages/web/src/repositories/liquidity/response/liquidity-detail-info-response.ts delete mode 100644 packages/web/src/repositories/liquidity/response/liquidity-detail-list-response.ts delete mode 100644 packages/web/src/repositories/liquidity/response/liquidity-reward-response.ts delete mode 100644 packages/web/src/repositories/liquidity/response/remove-liquidity-response.ts create mode 100644 packages/web/src/repositories/position/index.ts delete mode 100644 packages/web/src/repositories/staking/index.ts delete mode 100644 packages/web/src/repositories/staking/request/index.ts delete mode 100644 packages/web/src/repositories/staking/request/stake-request.ts delete mode 100644 packages/web/src/repositories/staking/request/unstake-request.ts delete mode 100644 packages/web/src/repositories/staking/response/index.ts delete mode 100644 packages/web/src/repositories/staking/response/stake-response.ts delete mode 100644 packages/web/src/repositories/staking/response/unstake-response.ts delete mode 100644 packages/web/src/repositories/staking/staking-repository-mock.ts delete mode 100644 packages/web/src/repositories/staking/staking-repository.ts create mode 100644 packages/web/src/repositories/wallet/index.ts rename packages/web/src/{components/governance => views/governance/components}/governance-summary/GovernanceSummary.spec.tsx (100%) rename packages/web/src/{components/governance => views/governance/components}/governance-summary/GovernanceSummary.stories.tsx (100%) rename packages/web/src/{components/governance => views/governance/components}/governance-summary/GovernanceSummary.styles.ts (100%) rename packages/web/src/{components/governance => views/governance/components}/governance-summary/GovernanceSummary.tsx (65%) rename packages/web/src/{components/governance => views/governance/components/governance-summary}/governance-detail/GovernanceDetail.spec.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/governance-summary}/governance-detail/GovernanceDetail.stories.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/governance-summary}/governance-detail/GovernanceDetail.styles.ts (100%) rename packages/web/src/{components/governance => views/governance/components/governance-summary}/governance-detail/GovernanceDetail.tsx (84%) rename packages/web/src/{components/governance => views/governance/components/governance-summary/governance-detail}/governance-detail-info/GovernanceDetailInfo.spec.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/governance-summary/governance-detail}/governance-detail-info/GovernanceDetailInfo.stories.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/governance-summary/governance-detail}/governance-detail-info/GovernanceDetailInfo.styles.ts (100%) rename packages/web/src/{components/governance => views/governance/components/governance-summary/governance-detail}/governance-detail-info/GovernanceDetailInfo.tsx (89%) rename packages/web/src/{components/governance => views/governance/components}/proposals-list/ProposalList.spec.tsx (100%) rename packages/web/src/{components/governance => views/governance/components}/proposals-list/ProposalList.styles.ts (100%) rename packages/web/src/{components/governance => views/governance/components}/proposals-list/ProposalList.tsx (82%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/create-proposal-modal/CreateProposalModal.spec.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/create-proposal-modal/CreateProposalModal.styles.ts (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/create-proposal-modal/CreateProposalModal.tsx (97%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/proposal-detail/ProposalDetail.spec.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/proposal-detail/ProposalDetail.stories.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/proposal-detail/ProposalDetail.styles.ts (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/proposal-detail/ProposalDetail.tsx (95%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/proposal-detail/ProposalDetailSekeleton.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/proposal-header/ProposalHeader.spec.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/proposal-header/ProposalHeader.stories.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/proposal-header/ProposalHeader.styles.ts (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/proposal-header/ProposalHeader.tsx (99%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/view-proposal-modal/ViewProposalModal.spec.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/view-proposal-modal/ViewProposalModal.stories.tsx (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/view-proposal-modal/ViewProposalModal.styles.ts (100%) rename packages/web/src/{components/governance => views/governance/components/proposals-list}/view-proposal-modal/ViewProposalModal.tsx (98%) rename packages/web/src/{ => views/governance}/containers/governance-container/GovernanceContainer.tsx (64%) rename packages/web/src/{ => views/governance}/containers/proposal-list-container/ProposalListContainer.tsx (98%) diff --git a/packages/web/.env.example b/packages/web/.env.example index 59af135ca..bd37e621d 100644 --- a/packages/web/.env.example +++ b/packages/web/.env.example @@ -34,7 +34,7 @@ NEXT_PUBLIC_PACKAGE_GOVERNANCE_ADDRESS="g1cu4dufdlzu0l9pekkqhw6mjnrxkp3z7ykst09d # Webpage Config -NEXT_PUBLIC_BLOCKED_PAGES="governance,leaderboard" +NEXT_PUBLIC_BLOCKED_PAGES="leaderboard" NEXT_PUBLIC_UMAMI_SCRIPT_URL="" NEXT_PUBLIC_UMAMI_WEBSITE_ID="" diff --git a/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.spec.tsx b/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.spec.tsx deleted file mode 100644 index 4ce844608..000000000 --- a/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.spec.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { render } from "@testing-library/react"; -import { Provider as JotaiProvider } from "jotai"; -import GnoswapThemeProvider from "@providers/gnoswap-theme-provider/GnoswapThemeProvider"; -import LearnMoreModal from "./LearnMoreModal"; - -describe("LearnMoreModal Component", () => { - it("LearnMoreModal render", () => { - const mockProps = {}; - - render( - - - - - , - ); - }); -}); diff --git a/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.stories.tsx b/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.stories.tsx deleted file mode 100644 index 7adf582ea..000000000 --- a/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.stories.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from "react"; -import { ComponentStory, ComponentMeta } from "@storybook/react"; -import LearnMoreModal from "./LearnMoreModal"; - -export default { - title: "governance/LearnMoreModal", - component: LearnMoreModal, -} as ComponentMeta; - -const Template: ComponentStory = args => ( - -); - -export const Default = Template.bind({}); -Default.args = {}; - -export const DefaultTooltip = Template.bind({}); -DefaultTooltip.args = {}; diff --git a/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.styles.ts b/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.styles.ts deleted file mode 100644 index b8f4a2ac7..000000000 --- a/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.styles.ts +++ /dev/null @@ -1,177 +0,0 @@ -import { fonts } from "@constants/font.constant"; -import styled from "@emotion/styled"; -import { media } from "@styles/media"; -import mixins from "@styles/mixins"; -import { Z_INDEX } from "@styles/zIndex"; -export const LearnMoreModalBackground = styled.div` - position: fixed; - overflow: scroll; - top: 0px; - bottom: 0px; - left: 0px; - right: 0px; - width: 100%; - height: 100lvh; - z-index: ${Z_INDEX.modal}; - pointer-events: none; -`; - -export const LearnMoreModalWrapper = styled.div` - pointer-events: initial; - ${mixins.flexbox("column", "flex-start", "flex-start")}; - position: absolute; - overflow: hidden; - width: 690px; - border-radius: 8px; - padding: 24px; - gap: 24px; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - box-shadow: 10px 14px 60px 0px rgba(0, 0, 0, 0.4); - border: 1px solid ${({ theme }) => theme.color.border02}; - background-color: ${({ theme }) => theme.color.background06}; - ${media.mobile} { - width: 320px; - padding: 24px; - transform: translate(-50%, -50%); - } - .modal-body { - ${mixins.flexbox("column", "flex-start", "flex-start")}; - width: 100%; - padding: 0px 24px; - gap: 16px; - ${media.mobile} { - padding: 0px; - } - } - .learn-more-btn { - height: 57px; - background-color: ${({ theme }) => theme.color.background05}; - &:hover { - background-color: ${({ theme }) => theme.color.backgroundOpacity}; - } - ${media.mobile} { - width: 272px; - height: 41px; - } - } - .active-btn { - span { - color: ${({ theme }) => theme.color.text27}; - } - background-color: ${({ theme }) => theme.color.background04}; - &:hover { - background-color: ${({ theme }) => theme.color.background04Hover}; - } - } -`; - -export const Progress = styled.div` - ${mixins.flexbox("row", "flex-start", "flex-start")}; - gap: 4px; - width: 100%; - div { - flex: 1; - height: 3px; - border-radius: 4px; - background-color: ${({ theme }) => theme.color.border02}; - } - .active-progress { - background-color: ${({ theme }) => theme.color.border03}; - } -`; - -export const Slider = styled.div` - ${mixins.flexbox("column", "flex-start", "flex-start")}; - gap: 24px; - width: 100%; -`; - -export const Title = styled.div` - ${mixins.flexbox("column", "center", "center")}; - padding: 0px 77px; - -webkit-user-drag: none; - pointer-events: none; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - ${media.mobile} { - padding: 0px; - } - width: 100%; - gap: 8px; - h3 { - ${fonts.body3} - color: ${({ theme }) => theme.color.text02}; - } - div { - color: ${({ theme }) => theme.color.text10}; - ${fonts.body12} - text-align: center; - } - ${media.mobile} { - h3 { - ${fonts.body7} - } - div { - ${fonts.p2} - br { - display: none; - } - } - } -`; - -export const BoxImage = styled.div` - margin: 0px 77px; - position: relative; - img { - -webkit-user-drag: none; - pointer-events: none; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - width: 100%; - aspect-ratio: 3/2; - object-fit: cover; - border-radius: 8px; - display: block; - border: 1px solid ${({ theme }) => theme.color.border01}; - } - .slide-icon { - position: absolute; - top: 50%; - transform: translateY(-50%); - * { - fill: ${({ theme }) => theme.color.border02}; - } - } - .left-icon { - left: -77px; - } - .right-icon { - right: -77px; - } - .active-icon { - cursor: pointer; - * { - fill: ${({ theme }) => theme.color.icon03}; - } - } - ${media.mobile} { - margin: 0px 32px; - .left-icon { - left: -40px; - } - .right-icon { - right: -40px; - } - } -`; diff --git a/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.tsx b/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.tsx deleted file mode 100644 index c24998c2b..000000000 --- a/packages/web/src/components/governance/learn-more-modal/LearnMoreModal.tsx +++ /dev/null @@ -1,172 +0,0 @@ -import Button from "@components/common/button/Button"; -import IconStrokeArrowLeft from "@components/common/icons/IconStrokeArrowLeft"; -import IconStrokeArrowRight from "@components/common/icons/IconStrokeArrowRight"; -import { Overlay } from "@components/common/modal/Modal.styles"; -import useEscCloseModal from "@hooks/common/use-esc-close-modal"; -import { ThemeState } from "@states/index"; -import { useAtomValue } from "jotai"; -import React, { - Dispatch, - SetStateAction, - useEffect, - useRef, - useState, -} from "react"; -import { - BoxImage, - LearnMoreModalBackground, - LearnMoreModalWrapper, - Progress, - Slider, - Title, -} from "./LearnMoreModal.styles"; - -interface Props { - setIsShowLearnMoreModal: Dispatch>; -} - -interface LearnMoreProps { - title: string; - description: JSX.Element; - darkImageUrl: string; - lightImageURL: string; -} - -const LEARN_MORE_DATA: LearnMoreProps[] = [ - { - title: "How to get xGNOS", - description: ( - <> - Stake liquidity from GNOT-GNS pools to earn xGNOS, -
- which represent your voting shares in the GnoSwap Governance. - - ), - lightImageURL: - "https://media.discordapp.net/attachments/1138037908482314292/1162098588118167803/image_55.png?ex=653ab3a6&is=65283ea6&hm=636cd11c78cc8c37cbddea2df74e27913b05c517a81f1222f749c315a88056aa", - darkImageUrl: - "https://media.discordapp.net/attachments/1138037908482314292/1162054336499695767/image_53.png?ex=653a8a6f&is=6528156f&hm=289336d87487c2c25490a4834333ea9663b3ed477d4ef818329bc03540a6fdfd", - }, - { - title: "Create a Proposal", - description: ( - <> - Submit a well-discussed and refined argument
- in the forum as a formal proposal. - - ), - lightImageURL: - "https://media.discordapp.net/attachments/1138037908482314292/1162098588118167803/image_55.png?ex=653ab3a6&is=65283ea6&hm=636cd11c78cc8c37cbddea2df74e27913b05c517a81f1222f749c315a88056aa", - darkImageUrl: - "https://media.discordapp.net/attachments/1138037908482314292/1162054336499695767/image_53.png?ex=653a8a6f&is=6528156f&hm=289336d87487c2c25490a4834333ea9663b3ed477d4ef818329bc03540a6fdfd", - }, - { - title: "Cast Your Votes", - description: ( - <> - Enable community ownership by voting with xGNOS,
- which represent your voting shares in the GnoSwap Governance. - - ), - lightImageURL: - "https://media.discordapp.net/attachments/1138037908482314292/1162098588118167803/image_55.png?ex=653ab3a6&is=65283ea6&hm=636cd11c78cc8c37cbddea2df74e27913b05c517a81f1222f749c315a88056aa", - darkImageUrl: - "https://media.discordapp.net/attachments/1138037908482314292/1162054336499695767/image_53.png?ex=653a8a6f&is=6528156f&hm=289336d87487c2c25490a4834333ea9663b3ed477d4ef818329bc03540a6fdfd", - }, -]; - -const LearnMoreModal: React.FC = ({ setIsShowLearnMoreModal }) => { - const [index, setIndex] = useState(0); - const themeKey = useAtomValue(ThemeState.themeKey); - const modalRef = useRef(null); - - const handleResize = () => { - if (typeof window !== "undefined" && modalRef.current) { - const height = modalRef.current.getBoundingClientRect().height; - if (height >= window?.innerHeight) { - modalRef.current.style.top = "0"; - modalRef.current.style.transform = "translateX(-50%)"; - } else { - modalRef.current.style.top = "50%"; - modalRef.current.style.transform = "translate(-50%, -50%)"; - } - } - }; - - useEscCloseModal(() => setIsShowLearnMoreModal(false)); - - useEffect(() => { - handleResize(); - window.addEventListener("resize", handleResize); - return () => { - window.removeEventListener("resize", handleResize); - }; - }, [modalRef]); - - return ( - <> - - - - {LEARN_MORE_DATA.map((_, i) => ( -
= i ? "active-progress" : ""}`} - >
- ))} -
- - e.preventDefault()}> - <h3>{LEARN_MORE_DATA[index].title}</h3> - <div>{LEARN_MORE_DATA[index].description}</div> - - - e.preventDefault()} - onMouseDown={e => e.preventDefault()} - draggable="false" - src={ - themeKey === "dark" - ? LEARN_MORE_DATA[index].darkImageUrl - : LEARN_MORE_DATA[index].lightImageURL - } - alt="logo img" - /> - - setIndex( - index < LEARN_MORE_DATA.length - 1 - ? index + 1 - : LEARN_MORE_DATA.length - 1, - ) - } - className={`slide-icon right-icon ${ - index < LEARN_MORE_DATA.length - 1 ? "active-icon" : "" - }`} - /> - setIndex(index > 0 ? index - 1 : 0)} - className={`slide-icon left-icon ${ - index > 0 ? "active-icon" : "" - }`} - /> - - -