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 copy to clipboard button next to dbKey (#121) #133

Merged
merged 1 commit into from
Oct 17, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { GridPaperSection as DXGridPaperSection } from "@databiosphere/findable-ui/lib/components/common/Section/section.styles";
import styled from "@emotion/styled";

export const GridPaperSection = styled(DXGridPaperSection)`
min-width: 0;
`;
24 changes: 24 additions & 0 deletions app/components/common/CopyText/copyText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { CopyToClipboard } from "@databiosphere/findable-ui/lib/components/common/CopyToClipboard/copyToClipboard";
import { Grid2, Grid2Props, Typography } from "@mui/material";
import { ReactNode } from "react";

export interface CopyTextProps {
children: ReactNode;
gridProps?: Partial<Grid2Props>;
text: string;
}

export const CopyText = ({
children,
gridProps,
text,
}: CopyTextProps): JSX.Element => {
return (
<Grid2 container columnSpacing={1} wrap="nowrap" {...gridProps}>
<Typography component="span" noWrap>
{children}
</Typography>
<CopyToClipboard copyStr={text} />
</Grid2>
);
};
3 changes: 2 additions & 1 deletion app/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export {
RoundedPaper,
} from "@databiosphere/findable-ui/lib/components/common/Paper/paper.styles";
export { SectionTitle } from "@databiosphere/findable-ui/lib/components/common/Section/components/SectionTitle/sectionTitle";
export { GridPaperSection } from "@databiosphere/findable-ui/lib/components/common/Section/section.styles";
export { Stack } from "@databiosphere/findable-ui/lib/components/common/Stack/stack";
export { StaticImage } from "@databiosphere/findable-ui/lib/components/common/StaticImage/staticImage";
export {
Expand All @@ -22,8 +21,10 @@ export {
export { Logo } from "@databiosphere/findable-ui/lib/components/Layout/components/Header/components/Content/components/Logo/logo";
export { Link } from "@databiosphere/findable-ui/lib/components/Links/components/Link/link";
export { BasicCell } from "@databiosphere/findable-ui/lib/components/Table/components/TableCell/components/BasicCell/basicCell";
export { CopyText } from "./common/CopyText/copyText";
export { AnalysisMethod } from "./Entity/components/AnalysisMethod/analysisMethod";
export { AnalysisPortals } from "./Entity/components/AnalysisPortals/analysisPortals";
export { DetailViewHero } from "./Layout/components/Detail/components/DetailViewHero/detailViewHero";
export { GridPaperSection } from "./Layout/components/Detail/components/Section/section.styles";
export { Branding } from "./Layout/components/Footer/components/Branding/branding";
export { AnalyzeGenome } from "./Table/components/TableCell/components/AnalyzeGenome/analyzeGenome";
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ export const buildGenomeDetails = (
})
);
keyValuePairs.set("Strain", genome.strain);
keyValuePairs.set("Assembly Version ID", genome.genomeVersionAssemblyId);
keyValuePairs.set(
"Assembly Version ID",
C.CopyText({
children: genome.genomeVersionAssemblyId,
text: genome.genomeVersionAssemblyId,
})
);
keyValuePairs.set("VeUPathDB Project", genome.vEuPathDbProject);
keyValuePairs.set("Contigs", genome.contigs);
keyValuePairs.set("Super Contigs", genome.supercontigs);
Expand Down
Loading