From 72bd5e2a96dddd23b476288a27634831ba6d914a Mon Sep 17 00:00:00 2001 From: Sawit Trisirisatayawong Date: Thu, 23 Mar 2023 18:59:54 +0700 Subject: [PATCH 1/4] feat(components): add github link to public code and contract --- src/lib/components/links/GitHubLink.tsx | 34 +++++++++++++++++++ src/lib/components/links/index.ts | 1 + src/lib/pages/code-details/index.tsx | 4 +++ .../components/ContractTop.tsx | 4 +++ src/lib/services/contract.ts | 1 + src/lib/types/projects.ts | 1 + 6 files changed, 45 insertions(+) create mode 100644 src/lib/components/links/GitHubLink.tsx create mode 100644 src/lib/components/links/index.ts diff --git a/src/lib/components/links/GitHubLink.tsx b/src/lib/components/links/GitHubLink.tsx new file mode 100644 index 000000000..d341a62c9 --- /dev/null +++ b/src/lib/components/links/GitHubLink.tsx @@ -0,0 +1,34 @@ +import { Flex, Text } from "@chakra-ui/react"; + +import { CustomIcon } from "../icon"; + +interface GitHubLinkProps { + github: string; +} + +export const GitHubLink = ({ github }: GitHubLinkProps) => { + const [, , , org, repo] = github.split("/"); + return ( + + + GitHub: + + + + {org}/{repo} + + + + + ); +}; diff --git a/src/lib/components/links/index.ts b/src/lib/components/links/index.ts new file mode 100644 index 000000000..e4ab9e6c5 --- /dev/null +++ b/src/lib/components/links/index.ts @@ -0,0 +1 @@ +export * from "./GitHubLink"; diff --git a/src/lib/pages/code-details/index.tsx b/src/lib/pages/code-details/index.tsx index cc7c15e85..5d6be4aff 100644 --- a/src/lib/pages/code-details/index.tsx +++ b/src/lib/pages/code-details/index.tsx @@ -6,6 +6,7 @@ import { useEffect } from "react"; import { BackButton } from "lib/components/button"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; +import { GitHubLink } from "lib/components/links"; import { Loading } from "lib/components/Loading"; import PageContainer from "lib/components/PageContainer"; import { PublicDescription } from "lib/components/PublicDescription"; @@ -84,6 +85,9 @@ const CodeDetailsBody = observer( {cw2Info ?? "N/A"} + {publicProject.publicCodeData?.github && ( + + )} { )} + {publicProject.publicInfo?.github && ( + + )} Date: Fri, 24 Mar 2023 09:14:06 +0700 Subject: [PATCH 2/4] docs: append changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5341069b..ecebc2aac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features +- [#254](https://github.com/alleslabs/celatone-frontend/pull/254) Add GiHub link to public code and contract detail pages - [#230](https://github.com/alleslabs/celatone-frontend/pull/230) Add cw2info to code table ### Improvements From 1b2be25992b14c61307db06f523419ccf5c6bbeb Mon Sep 17 00:00:00 2001 From: Sawit Trisirisatayawong Date: Fri, 24 Mar 2023 10:10:10 +0700 Subject: [PATCH 3/4] fix: fix comments --- src/lib/components/links/GitHubLink.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lib/components/links/GitHubLink.tsx b/src/lib/components/links/GitHubLink.tsx index d341a62c9..cfbbe0032 100644 --- a/src/lib/components/links/GitHubLink.tsx +++ b/src/lib/components/links/GitHubLink.tsx @@ -1,6 +1,7 @@ import { Flex, Text } from "@chakra-ui/react"; import { CustomIcon } from "../icon"; +import { AmpTrackSocial } from "lib/services/amplitude"; interface GitHubLinkProps { github: string; @@ -15,6 +16,7 @@ export const GitHubLink = ({ github }: GitHubLinkProps) => { AmpTrackSocial(github)} target="_blank" rel="noreferrer" style={{ display: "flex" }} @@ -22,12 +24,7 @@ export const GitHubLink = ({ github }: GitHubLinkProps) => { {org}/{repo} - + ); From dd49667bf76f9f85e48fd3bff1ae04a5d6fb48a0 Mon Sep 17 00:00:00 2001 From: Sawit Trisirisatayawong Date: Fri, 24 Mar 2023 14:33:13 +0700 Subject: [PATCH 4/4] fix: add noopener to githublink --- src/lib/components/links/GitHubLink.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/links/GitHubLink.tsx b/src/lib/components/links/GitHubLink.tsx index cfbbe0032..6d78ce7c6 100644 --- a/src/lib/components/links/GitHubLink.tsx +++ b/src/lib/components/links/GitHubLink.tsx @@ -18,7 +18,7 @@ export const GitHubLink = ({ github }: GitHubLinkProps) => { href={github} onClick={() => AmpTrackSocial(github)} target="_blank" - rel="noreferrer" + rel="noreferrer noopener" style={{ display: "flex" }} >