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

New Gov Actions #525

Merged
merged 5 commits into from
Mar 26, 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
11 changes: 11 additions & 0 deletions govtool/frontend/public/icons/CopyBlueThin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions govtool/frontend/public/icons/Share.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 0 additions & 30 deletions govtool/frontend/src/components/atoms/ClickOutside.tsx

This file was deleted.

10 changes: 7 additions & 3 deletions govtool/frontend/src/components/atoms/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { ICONS } from "@consts";
import { useSnackbar } from "@context";
import { useTranslation } from "@hooks";

interface Props {
type Props = {
isChecked?: boolean;
text: string;
variant?: string;
}
variant?: "blueThin" | "blue";
};

export const CopyButton = ({ isChecked, text, variant }: Props) => {
const { addSuccessAlert } = useSnackbar();
Expand All @@ -19,6 +19,10 @@ export const CopyButton = ({ isChecked, text, variant }: Props) => {
return ICONS.copyBlueIcon;
}

if (variant === "blueThin") {
return ICONS.copyBlueThinIcon;
}

if (isChecked) {
return ICONS.copyWhiteIcon;
}
Expand Down
49 changes: 49 additions & 0 deletions govtool/frontend/src/components/atoms/ExternalModalButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Typography } from "@mui/material";

import { Button } from "@atoms";
import { ICONS } from "@consts";
import { useModal } from "@context";

export const ExternalModalButton = ({
JanJaroszczak marked this conversation as resolved.
Show resolved Hide resolved
label,
url,
}: {
label: string;
url: string;
}) => {
const { openModal } = useModal();

return (
<Button
onClick={() => {
openModal({
type: "externalLink",
state: {
externalLink: url,
},
});
}}
sx={{
p: 0,
mb: 4,
":hover": {
backgroundColor: "transparent",
},
}}
disableRipple
variant="text"
data-testid="external-modal-button"
>
<Typography variant="body1" fontWeight={500} color="primary">
{label}
</Typography>
<img
alt="external link"
src={ICONS.externalLinkIcon}
height="20"
width="20"
style={{ marginLeft: "8px" }}
/>
</Button>
);
};
53 changes: 38 additions & 15 deletions govtool/frontend/src/components/atoms/Radio.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Box, Typography } from "@mui/material";
import { Box } from "@mui/material";

import { Typography } from "@atoms";
import { UseFormRegister, UseFormSetValue } from "react-hook-form";
import { theme } from "@/theme";

type RadioProps = {
isChecked: boolean;
Expand All @@ -10,11 +13,20 @@ type RadioProps = {
setValue: UseFormSetValue<any>;
register: UseFormRegister<any>;
dataTestId?: string;
disabled?: boolean;
};

export const Radio = ({ ...props }: RadioProps) => {
const { isChecked, name, setValue, title, value, dataTestId, register } =
props;
const {
isChecked,
name,
setValue,
title,
value,
dataTestId,
register,
disabled,
} = props;

const handleClick = () => {
setValue(name, value);
Expand All @@ -23,13 +35,23 @@ export const Radio = ({ ...props }: RadioProps) => {
return (
<Box
data-testid={dataTestId}
onClick={handleClick}
borderRadius={2}
p={0.2}
border={isChecked ? 1 : 0}
borderColor={isChecked ? "specialCyanBorder" : "white"}
sx={[{ "&:hover": { color: "blue", cursor: "pointer" } }]}
flex={1}
onClick={() => {
if (!disabled) handleClick();
}}
borderRadius={isChecked ? "15px" : "12px"}
p={isChecked ? "2px" : 0}
border={isChecked ? 2 : 0}
borderColor={isChecked ? "specialCyanBorder" : undefined}
sx={[
{
boxShadow: theme.shadows[1],

"&:hover": {
color: "blue",
cursor: disabled ? "default" : "pointer",
},
},
]}
>
<input
type="radio"
Expand All @@ -39,15 +61,16 @@ export const Radio = ({ ...props }: RadioProps) => {
checked={isChecked}
/>
<Box
borderRadius={1.5}
borderRadius="12px"
bgcolor={isChecked ? "specialCyan" : "white"}
py={1.5}
border={isChecked ? 0 : 1}
borderColor="lightBlue"
>
<Typography
textAlign="center"
color={isChecked ? "white" : "textBlack"}
variant="body1"
sx={{
textAlign: "center",
color: isChecked ? "white" : "textBlack",
}}
>
{title}
</Typography>
Expand Down
7 changes: 1 addition & 6 deletions govtool/frontend/src/components/atoms/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { styled } from "@mui/material";
import * as TooltipMUI from "@mui/material/Tooltip";
import Typography from "@mui/material/Typography";

type TooltipProps = Omit<TooltipMUI.TooltipProps, "title"> & {
heading?: string;
paragraphOne?: string;
paragraphTwo?: string;
};
import { TooltipProps } from "@atoms";

const StyledTooltip = styled(
({ className, ...props }: TooltipMUI.TooltipProps) => (
Expand Down
3 changes: 2 additions & 1 deletion govtool/frontend/src/components/atoms/VotePill.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Vote } from "@models";
import { Box, Typography } from "@mui/material";

import { Vote } from "@models";

export const VotePill = ({
vote,
width,
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/src/components/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ export * from "./ActionRadio";
export * from "./Background";
export * from "./Button";
export * from "./Checkbox";
export * from "./ClickOutside";
export * from "./CopyButton";
export * from "./DrawerLink";
export * from "./ExternalModalButton";
export * from "./FormErrorMessage";
export * from "./FormHelpfulText";
export * from "./HighlightedText";
Expand Down
7 changes: 7 additions & 0 deletions govtool/frontend/src/components/atoms/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TextareaAutosizeProps,
SxProps,
} from "@mui/material";
import * as TooltipMUI from "@mui/material/Tooltip";

export type ButtonProps = Omit<MUIButtonProps, "size"> & {
size?: "small" | "medium" | "large" | "extraLarge";
Expand Down Expand Up @@ -71,3 +72,9 @@ export type InfoTextProps = {
label: string;
sx?: SxProps;
};

export type TooltipProps = Omit<TooltipMUI.TooltipProps, "title"> & {
heading?: string;
paragraphOne?: string;
paragraphTwo?: string;
};
62 changes: 62 additions & 0 deletions govtool/frontend/src/components/molecules/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { NavLink, To } from "react-router-dom";
import { Box } from "@mui/material";
import Divider from "@mui/material/Divider";

import { useScreenDimension, useTranslation } from "@hooks";
import { Typography } from "@atoms";

type BreadcrumbsProps = {
elementOne: string;
elementOnePath: To;
elementTwo: string;
isDataMissing: boolean;
};

export const Breadcrumbs = ({
elementOne,
elementOnePath,
elementTwo,
isDataMissing,
}: BreadcrumbsProps) => {
const { t } = useTranslation();
const { isMobile } = useScreenDimension();

return (
<Box
sx={{
display: "flex",
alignItems: "center",
margin: `2px 0 ${isMobile ? "44px" : "24px"}`,
}}
>
<NavLink to={elementOnePath} style={{ textDecorationColor: "#0033AD" }}>
<Typography
color="primary"
variant="caption"
sx={{
whiteSpace: "nowrap",
}}
>
{elementOne}
</Typography>
</NavLink>
<Divider
orientation="vertical"
flexItem
color="textBlack"
sx={{ margin: "0 6px" }}
/>
<Typography
variant="caption"
sx={{
fontWeight: 500,
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
}}
>
{isDataMissing ? t("govActions.dataMissing") : elementTwo}
</Typography>
</Box>
);
};
41 changes: 19 additions & 22 deletions govtool/frontend/src/components/molecules/DataActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { Dispatch, FC, SetStateAction } from "react";
import { Box, InputBase } from "@mui/material";
Sworzen1 marked this conversation as resolved.
Show resolved Hide resolved
import Search from "@mui/icons-material/Search";

import { GovernanceActionsFilters, GovernanceActionsSorting } from ".";
import { GovernanceActionsFilters, GovernanceActionsSorting } from "@molecules";
import { OrderActionsChip } from "./OrderActionsChip";
import { ClickOutside } from "../atoms";

import { theme } from "@/theme";

type DataActionsBarProps = {
Expand Down Expand Up @@ -50,7 +48,7 @@ export const DataActionsBar: FC<DataActionsBarProps> = ({ ...props }) => {

return (
<>
<Box alignItems="center" display="flex" justifyContent="flex-start">
<Box alignItems="center" display="flex" justifyContent="space-between">
<InputBase
inputProps={{ "data-testid": "search-input" }}
onChange={(e) => setSearchText(e.target.value)}
Expand All @@ -76,7 +74,7 @@ export const DataActionsBar: FC<DataActionsBarProps> = ({ ...props }) => {
fontWeight: 500,
height: 48,
padding: "16px 24px",
width: 231,
width: 500,
}}
/>
<OrderActionsChip
Expand All @@ -87,24 +85,23 @@ export const DataActionsBar: FC<DataActionsBarProps> = ({ ...props }) => {
setSortOpen={setSortOpen}
sortingActive={sortingActive}
sortOpen={sortOpen}
/>
>
{filtersOpen && (
<GovernanceActionsFilters
chosenFilters={chosenFilters}
setChosenFilters={setChosenFilters}
closeFilters={closeFilters}
/>
)}
{sortOpen && (
<GovernanceActionsSorting
chosenSorting={chosenSorting}
setChosenSorting={setChosenSorting}
closeSorts={closeSorts}
/>
)}
</OrderActionsChip>
</Box>
{filtersOpen && (
<ClickOutside onClick={closeFilters}>
<GovernanceActionsFilters
chosenFilters={chosenFilters}
setChosenFilters={setChosenFilters}
/>
</ClickOutside>
)}
{sortOpen && (
<ClickOutside onClick={closeSorts}>
<GovernanceActionsSorting
chosenSorting={chosenSorting}
setChosenSorting={setChosenSorting}
/>
</ClickOutside>
)}
</>
);
};
Loading
Loading