Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add open new tab functionality #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions frontend/modules/components/ResultBox/ResultBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";
import { ExternalLinkIcon } from "@chakra-ui/icons";
import { ResultBoxProps } from "./types";

const ResultBox = (props: ResultBoxProps) => {
const ristekLink = `${window.location.origin}/${props.alias}`;
if (props.isLoading) {
return (
<div className="absolute -bottom-32 w-full h-8 bg-gray-300 animate-pulse py-9 flex flex-row items-center justify-between rounded-md px-4 mt-3 shadow-lg" />
);
} else {
return (
<div className="absolute -bottom-32 w-full h-8 bg-primary py-9 flex flex-row items-center justify-between rounded-md px-4 mt-3 shadow-lg">
<a href={ristekLink} target="_blank" className="flex items-center">
<div className="text-white font-bold hover:underline">{ristekLink}</div>
<ExternalLinkIcon className="ml-2" color="white" />
</a>
<div
className="text-white cursor-pointer"
onClick={() => props.onCopy()}
>
{props.isCopied ? "Copied!" : "Copy"}
</div>
</div>
);
}
};

export default ResultBox;
32 changes: 6 additions & 26 deletions frontend/modules/components/ResultBox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
import React from "react";
import dynamic from "next/dynamic";
import { ResultBoxProps } from "./types";

type ResultBoxProps = {
onCopy?: () => any;
isCopied?: boolean;
isLoading?: boolean;
alias: string;
const DynamicResultBox = dynamic(() => import(/* webpackChunkName: "ResultBox" */"./ResultBox"));
const ResultBoxWrapper = (props: ResultBoxProps) => {
return <DynamicResultBox {...props} />;
};

const ResultBox = (props: ResultBoxProps) => {
if (props.isLoading) {
return (
<div className="absolute -bottom-32 w-full h-8 bg-gray-300 animate-pulse py-9 flex flex-row items-center justify-between rounded-md px-4 mt-3 shadow-lg" />
);
} else {
return (
<div className="absolute -bottom-32 w-full h-8 bg-primary py-9 flex flex-row items-center justify-between rounded-md px-4 mt-3 shadow-lg">
<div className="text-white font-bold truncate">{`https://ristek.link/${props.alias}`}</div>
<div
className="text-white cursor-pointer"
onClick={() => props.onCopy()}
>
{props.isCopied ? "Copied!" : "Copy"}
</div>
</div>
);
}
};

export default ResultBox;
export default ResultBoxWrapper;
6 changes: 6 additions & 0 deletions frontend/modules/components/ResultBox/types.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type ResultBoxProps = {
onCopy?: () => any;
isCopied?: boolean;
isLoading?: boolean;
alias: string;
};
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"start": "next start"
},
"dependencies": {
"@chakra-ui/icons": "^1.0.15",
"@chakra-ui/react": "^1.6.1",
"@emotion/react": "^11",
"@emotion/styled": "^11",
Expand Down