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

CRDCDH-988 Enforce consistent link styling #330

Merged
merged 1 commit into from
Apr 3, 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
37 changes: 23 additions & 14 deletions src/components/Questionnaire/SectionGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ import {
Typography, styled
} from "@mui/material";

type Props = {
children: React.ReactNode;
title?: string;
description?: string | React.ReactNode;
endButton?: React.ReactNode;
beginButton?: React.ReactNode;
required?: boolean;
error?: string;
};

const StyledGrid = styled(Grid)({
marginTop: "46px",
"&:first-of-type": {
Expand Down Expand Up @@ -42,13 +32,19 @@ export const StyledTitle = styled(Typography)({
export const StyledDescription = styled(Typography)({
fontWeight: 400,
color: "#2A836D",
marginTop: "16px",
marginTop: "24px",
fontSize: "16px",
"& a": {
color: "inherit",
fontWeight: "700",
textDecoration: "underline",
},
});

const StyledEndAdornment = styled(Box)({
marginLeft: "auto",
});

const StyledBeginAdornment = styled(Box)({
marginRight: "12px",
marginTop: "auto",
Expand All @@ -60,6 +56,7 @@ const StyledAsterisk = styled('span')({
color: "#C93F08",
marginLeft: "2px",
});

const StyledError = styled('div')({
color: "#C93F08",
textTransform: "none",
Expand All @@ -73,13 +70,27 @@ const StyledError = styled('div')({
marginBottom: '0',
minHeight: '20px',
});

type Props = {
children: React.ReactNode;
title?: string;
description?: React.ReactNode;
endButton?: React.ReactNode;
beginButton?: React.ReactNode;
required?: boolean;
error?: string;
};

/**
* Generic Form Input Section Group
*
* @param {Props} props
* @returns {React.ReactNode}
*/
const SectionGroup: FC<Props> = ({ title, description, children, endButton, beginButton, required, error }) => (
const SectionGroup: FC<Props> = ({
children,
title, description, endButton, beginButton, required, error,
}) => (
<StyledGrid container rowSpacing={0} columnSpacing={1.5}>
<StyledHeader xs={12} item>
<Stack direction="column" alignItems="flex-start">
Expand All @@ -88,7 +99,6 @@ const SectionGroup: FC<Props> = ({ title, description, children, endButton, begi
{title}
{required ? <StyledAsterisk className="asterisk">*</StyledAsterisk> : ""}
{error ? <StyledError className="asterisk">{error}</StyledError> : ""}

</StyledTitle>
)}
<Stack direction="row" alignItems="flex-start" justifyContent="space-between" width="100%">
Expand All @@ -99,7 +109,6 @@ const SectionGroup: FC<Props> = ({ title, description, children, endButton, begi
)}
{beginButton && <StyledBeginAdornment>{beginButton}</StyledBeginAdornment>}
</Stack>

</Stack>
</StyledHeader>
{children}
Expand Down
13 changes: 3 additions & 10 deletions src/config/SectionMetadata.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { Link } from "react-router-dom";
import { styled } from "@mui/material";

const StyledLink = styled(Link)(() => ({
textDecoration: "none",
color: "inherit"
}));
import { Link } from 'react-router-dom';

/**
* Metadata for Questionnaire Sections
*
*
* @see SectionConfig
*/
const sectionMetadata = {
Expand Down Expand Up @@ -75,14 +68,14 @@ const sectionMetadata = {
<>
Informed consent is the basis for institutions submitting data to determine the appropriateness of submitting human data to open or controlled-access NIH/NCI data repositories. This refers to how CRDC data repositories distribute scientific data to the public. The controlled-access studies are required to submit an Institutional Certification to NIH. Learn about this at
{" "}
<StyledLink
<Link
to="https://sharing.nih.gov/genomic-data-sharing-policy/institutional-certifications"
target="_blank"
>
https://sharing.nih.gov/
<wbr />
genomic-data-sharing-policy/institutional-certifications
</StyledLink>
</Link>
</>
),
},
Expand Down
Loading