Skip to content

Commit

Permalink
Merge branch 'mvp-2.1.0' of https://github.com/CBIIT/crdc-datahub-ui
Browse files Browse the repository at this point in the history
…into CRDCDH-552
  • Loading branch information
Alejandro-Vega committed Dec 11, 2023
2 parents 1c64ef5 + 1bb62a8 commit b8248f6
Show file tree
Hide file tree
Showing 24 changed files with 1,478 additions and 706 deletions.
1,012 changes: 460 additions & 552 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"@mui/icons-material": "^5.11.16",
"@mui/lab": "^5.0.0-alpha.130",
"@mui/material": "^5.13.1",
"@mui/x-charts": "^6.0.0-alpha.12",
"@mui/x-date-pickers": "^6.8.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
Expand All @@ -23,8 +22,10 @@
"react-dom": "^18.2.0",
"react-helmet-async": "^1.3.0",
"react-hook-form": "^7.45.4",
"react-multi-carousel": "^2.8.4",
"react-router-dom": "^6.11.2",
"react-scripts": "5.0.1",
"recharts": "^2.10.3",
"redux": "^4.2.1",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.4.2",
Expand Down Expand Up @@ -70,6 +71,7 @@
"@types/node": "^20.4.0",
"@types/react": "^18.2.42",
"@types/react-dom": "^18.2.17",
"@types/recharts": "^1.8.29",
"@types/redux": "^3.6.0",
"@types/redux-logger": "^3.0.10",
"@types/redux-thunk": "^2.1.0",
Expand Down
78 changes: 78 additions & 0 deletions src/components/Carousel/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { FC } from 'react';
import { styled } from '@mui/material';
import Carousel, { CarouselProps } from 'react-multi-carousel';
import 'react-multi-carousel/lib/styles.css';

type Props = {
children: React.ReactNode;
} & Partial<CarouselProps>;

const sizing = {
desktop: {
breakpoint: { max: 5000, min: 0 },
items: 3,
partialVisibilityGutter: 40
},
};

const StyledWrapper = styled('div')({
maxWidth: "700px",
minWidth: "464px", // NOTE: Without a min-width, the carousel collapses to 0px wide
width: "100%",
margin: "0 auto",
"& .react-multi-carousel-list": {
height: "206px",
},
"& .react-multi-carousel-track": {
margin: "0 auto", // NOTE: This centers the carousel when there are fewer than 2 items
},
"& .react-multi-carousel-item": {
width: "200px !important",
},
"& .react-multi-carousel-list::after": {
content: "''",
position: "absolute",
left: "calc(100% - 162px)",
top: "0",
bottom: "0",
width: "162px",
background: "linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 50%)",
zIndex: 9,
},
"& .react-multi-carousel-list::before": {
content: "''",
position: "absolute",
right: "calc(100% - 162px)",
top: "0",
bottom: "0",
width: "162px",
background: "linear-gradient(to left, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 50%)",
zIndex: 9,
},
});

/**
* Provides a general carousel component for displaying multiple items
* at the same time.
*
* @param Props
* @returns {JSX.Element}
*/
const ContentCarousel: FC<Props> = ({ children, ...props }: Props) => (
<StyledWrapper>
<Carousel
responsive={sizing}
swipeable
draggable
infinite
centerMode
arrows
focusOnSelect
{...props}
>
{children}
</Carousel>
</StyledWrapper>
);

export default ContentCarousel;
7 changes: 4 additions & 3 deletions src/components/DataSubmissions/DataSubmissionUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const StyledMetadataText = styled(StyledUploadTypeText)(() => ({
const StyledUploadFilesButton = styled(LoadingButton)(() => ({
display: "flex",
flexDirection: "column",
padding: "12px 22px",
padding: "12px 20px",
justifyContent: "center",
alignItems: "center",
borderRadius: "8px",
Expand All @@ -46,7 +46,8 @@ const StyledUploadFilesButton = styled(LoadingButton)(() => ({
textTransform: "none",
"&.MuiButtonBase-root": {
marginLeft: "auto",
marginRight: "21.5px"
marginRight: "21.5px",
minWidth: "137px",
}
}));

Expand Down Expand Up @@ -336,7 +337,7 @@ const DataSubmissionUpload = ({ submitterID, readOnly, onUpload }: Props) => {
disableRipple
disableTouchRipple
>
Upload Files
Upload
</StyledUploadFilesButton>
</StyledUploadWrapper>
);
Expand Down
46 changes: 46 additions & 0 deletions src/components/DataSubmissions/LegendItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { FC } from 'react';
import { Box, Stack, Typography, styled } from '@mui/material';

type Props = {
color: string;
label: string;
};

const StyledStack = styled(Stack)({
marginRight: "20px",
"&:last-child": {
marginRight: "0",
},
});

const StyledLabel = styled(Typography)({
color: "#383838",
fontSize: "13px",
fontWeight: 300,
fontFamily: "'Nunito Sans', 'Rubik', sans-serif",
});

const StyledColorBox = styled(Box, { shouldForwardProp: (p) => p !== "color" })<{ color: string }>(({ color }) => ({
width: "22px",
height: "9px",
background: color,
marginRight: "11px",
borderRadius: "1.5px",
}));

/**
* Represents an item in the legend of a chart
*
* e.g. [color box] [label]
*
* @param {Props} props
* @returns {React.FC<Props>}
*/
const LegendItem: FC<Props> = ({ color, label }: Props) => (
<StyledStack direction="row" alignItems="center">
<StyledColorBox color={color} />
<StyledLabel>{label}</StyledLabel>
</StyledStack>
);

export default LegendItem;
38 changes: 0 additions & 38 deletions src/components/DataSubmissions/PieChart.tsx

This file was deleted.

55 changes: 2 additions & 53 deletions src/components/DataSubmissions/RadioInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ import {
Grid,
FormControl,
FormControlLabel,
Radio,
RadioGroup,
RadioProps,
RadioGroupProps,
FormHelperText,
Stack,
styled,
GridProps,
} from "@mui/material";
import { updateInputValidity } from "../../utils";
import StyledRadioButton from '../Questionnaire/StyledRadioButton';

const GridStyled = styled(Grid, {
shouldForwardProp: (prop) => prop !== "containerWidth",
Expand Down Expand Up @@ -47,31 +46,6 @@ const GridStyled = styled(Grid, {
},
}));

const BpIcon = styled("span")(() => ({
borderRadius: "50%",
width: 24,
height: 24,
outline: "6px auto #1D91AB",
"input:hover ~ &": {
outlineOffset: "2px",
},
}));

const BpCheckedIcon = styled(BpIcon)({
backgroundImage:
"linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))",
"&:before": {
borderRadius: "50%",
display: "block",
marginTop: "4px",
marginLeft: "4px",
width: 16,
height: 16,
backgroundImage: "radial-gradient(#1D91AB, #1D91AB)",
content: '""',
},
});

const StyledFormLabel = styled("label")(() => ({
fontWeight: 700,
fontSize: "16px",
Expand All @@ -85,15 +59,6 @@ const StyledAsterisk = styled("span")(() => ({
color: "#D54309",
}));

const StyledRadio = styled(Radio)((props) => ({
"& input": {
cursor: props.readOnly ? "not-allowed" : "pointer",
},
"& .radio-icon": {
backgroundColor: props.readOnly ? "#D2DFE9 !important" : "initial",
},
}));

const StyledFormControlLabel = styled(FormControlLabel)(() => ({
"&.MuiFormControlLabel-root": {
paddingRight: "10px",
Expand All @@ -109,22 +74,6 @@ const StyledFormControlLabel = styled(FormControlLabel)(() => ({
},
}));

// Inspired by blueprintjs
const BpRadio = (props: RadioProps) => (
<StyledRadio
disableRipple
color="default"
checkedIcon={<BpCheckedIcon className="radio-icon" />}
icon={<BpIcon className="radio-icon" />}
inputProps={
{
"data-type": "auto",
} as unknown
}
{...props}
/>
);

type Option = {
label: string;
value: string;
Expand Down Expand Up @@ -231,7 +180,7 @@ const RadioYesNoInput: FC<Props> = ({
label={option.label}
color="#1D91AB"
control={(
<BpRadio
<StyledRadioButton
id={id.concat(`-${option.label}-radio-button`)}
readOnly={readOnly || option.disabled}
disabled={option.disabled}
Expand Down
42 changes: 42 additions & 0 deletions src/components/DataSubmissions/StatisticLegend.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { FC } from 'react';
import { Box, Stack, Typography, styled } from '@mui/material';
import LegendItem from './LegendItem';

const StyledContainer = styled(Box)({
borderRadius: "8px",
background: "#F5F8F9",
border: "1px solid #939393",
width: "600px",
paddingLeft: "18px",
paddingRight: "18px",
paddingTop: "3px",
paddingBottom: "7px",
marginTop: "20px",
});

const StyledLegendTitle = styled(Typography)({
color: "#005EA2",
fontFamily: "'Nunito Sans', 'Rubik', sans-serif",
fontSize: "14px",
fontWeight: 600,
lineHeight: "27px",
});

/**
* A color code legend for the Data Submissions statistics chart(s)
*
* @returns {React.FC}
*/
const StatisticLegend: FC = () => (
<StyledContainer>
<StyledLegendTitle>Color Key</StyledLegendTitle>
<Stack direction="row" justifyItems="center" alignItems="center">
<LegendItem color="#4D90D3" label="New Counts" />
<LegendItem color="#32E69A" label="Passed Counts" />
<LegendItem color="#D65219" label="Failed Counts" />
<LegendItem color="#FFD700" label="Warning Counts" />
</Stack>
</StyledContainer>
);

export default StatisticLegend;
Loading

0 comments on commit b8248f6

Please sign in to comment.