Skip to content

Commit

Permalink
[#514] chore: format all using prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Mar 21, 2024
1 parent 4fa2dc0 commit 8841a24
Show file tree
Hide file tree
Showing 100 changed files with 1,150 additions and 1,169 deletions.
3 changes: 1 addition & 2 deletions govtool/frontend/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 80,
"",
"printWidth": 80
}
13 changes: 7 additions & 6 deletions govtool/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"build-storybook": "storybook build",
"chromatic": "chromatic",
"dev": "vite",
"format": "prettier --write src",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"tsc": "npx tsc --noEmit --skipLibCheck",
"postinstall": "patch-package",
"preview": "vite preview",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test-storybook": "test-storybook",
"chromatic": "chromatic",
"test": "vitest",
"test-storybook": "test-storybook",
"test:watch": "vitest watch",
"postinstall": "patch-package"
"tsc": "npx tsc --noEmit --skipLibCheck"
},
"dependencies": {
"@emotion/react": "^11.11.1",
Expand Down
10 changes: 5 additions & 5 deletions govtool/frontend/src/components/atoms/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Button as MUIButton } from '@mui/material';
import { ButtonProps } from '.';
import { Button as MUIButton } from "@mui/material";
import { ButtonProps } from ".";

export const Button = ({
size = 'large',
variant = 'contained',
size = "large",
variant = "contained",
sx,
...props
}: ButtonProps) => {
Expand All @@ -17,7 +17,7 @@ export const Button = ({
return (
<MUIButton
sx={{
fontSize: size === 'extraLarge' ? 16 : 14,
fontSize: size === "extraLarge" ? 16 : 14,
height: buttonHeight,
...sx,
}}
Expand Down
12 changes: 6 additions & 6 deletions govtool/frontend/src/components/atoms/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useId } from 'react';
import { Checkbox as MUICheckbox } from '@mui/material';
import { useId } from "react";
import { Checkbox as MUICheckbox } from "@mui/material";

import { CheckboxProps } from './types';
import { CheckboxProps } from "./types";

export const Checkbox = ({
dataTestId,
Expand All @@ -16,12 +16,12 @@ export const Checkbox = ({
id={id}
inputProps={
{
'data-testid': dataTestId,
"data-testid": dataTestId,
} as React.InputHTMLAttributes<HTMLInputElement>
}
sx={{
'& .MuiSvgIcon-root': { fontSize: 18 },
color: errorMessage ? 'red' : '#0033AD',
"& .MuiSvgIcon-root": { fontSize: 18 },
color: errorMessage ? "red" : "#0033AD",
...sx,
}}
{...props}
Expand Down
14 changes: 7 additions & 7 deletions govtool/frontend/src/components/atoms/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useMemo } from 'react';
import { useMemo } from "react";

import { ICONS } from '@consts';
import { useSnackbar } from '@context';
import { useTranslation } from '@hooks';
import { ICONS } from "@consts";
import { useSnackbar } from "@context";
import { useTranslation } from "@hooks";

interface Props {
isChecked?: boolean;
Expand All @@ -15,7 +15,7 @@ export const CopyButton = ({ isChecked, text, variant }: Props) => {
const { t } = useTranslation();

const iconSrc = useMemo(() => {
if (variant === 'blue') {
if (variant === "blue") {
return ICONS.copyBlueIcon;
}

Expand All @@ -32,11 +32,11 @@ export const CopyButton = ({ isChecked, text, variant }: Props) => {
alt="copy"
onClick={(e) => {
navigator.clipboard.writeText(text);
addSuccessAlert(t('alerts.copiedToClipboard'));
addSuccessAlert(t("alerts.copiedToClipboard"));
e.stopPropagation();
}}
src={iconSrc}
style={{ cursor: 'pointer' }}
style={{ cursor: "pointer" }}
/>
);
};
29 changes: 14 additions & 15 deletions govtool/frontend/src/components/atoms/FormErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { Typography } from '@mui/material';
import { Typography } from "@mui/material";

import { FormErrorMessageProps } from './types';
import { FormErrorMessageProps } from "./types";

export const FormErrorMessage = ({
errorMessage,
errorStyles,
}: FormErrorMessageProps) => (
}: FormErrorMessageProps) =>
errorMessage && (
<Typography
color="red"
data-testid={`${errorMessage.replace(/\s+/g, '-').toLowerCase()}-error`}
fontSize={12}
fontWeight={400}
sx={{ mt: 0.25 }}
{...errorStyles}
>
{errorMessage}
</Typography>
)
);
<Typography
color="red"
data-testid={`${errorMessage.replace(/\s+/g, "-").toLowerCase()}-error`}
fontSize={12}
fontWeight={400}
sx={{ mt: 0.25 }}
{...errorStyles}
>
{errorMessage}
</Typography>
);
29 changes: 14 additions & 15 deletions govtool/frontend/src/components/atoms/FormHelpfulText.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { Typography } from '@mui/material';
import { Typography } from "@mui/material";

import { FormHelpfulTextProps } from './types';
import { FormHelpfulTextProps } from "./types";

export const FormHelpfulText = ({
helpfulText,
helpfulTextStyle,
}: FormHelpfulTextProps) => (
}: FormHelpfulTextProps) =>
helpfulText && (
<Typography
color="#9792B5"
data-testid={`${helpfulText.replace(/\s+/g, '-').toLowerCase()}-error`}
fontSize={12}
fontWeight={400}
sx={{ mt: 0.5 }}
{...helpfulTextStyle}
>
{helpfulText}
</Typography>
)
);
<Typography
color="#9792B5"
data-testid={`${helpfulText.replace(/\s+/g, "-").toLowerCase()}-error`}
fontSize={12}
fontWeight={400}
sx={{ mt: 0.5 }}
{...helpfulTextStyle}
>
{helpfulText}
</Typography>
);
2 changes: 1 addition & 1 deletion govtool/frontend/src/components/atoms/InfoText.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InfoTextProps, Typography } from '.';
import { InfoTextProps, Typography } from ".";

export const InfoText = ({ label, sx }: InfoTextProps) => (
<Typography color="#FF833B" sx={sx} variant="body1">
Expand Down
15 changes: 7 additions & 8 deletions govtool/frontend/src/components/atoms/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import { InputBase } from "@mui/material";
import { InputProps } from "./types";

export const Input = forwardRef<HTMLInputElement, InputProps>(
({
errorMessage, dataTestId, onBlur, onFocus, sx, ...rest
}, ref) => {
({ errorMessage, dataTestId, onBlur, onFocus, sx, ...rest }, ref) => {
const id = useId();
const inputRef = useRef<HTMLInputElement>(null);

Expand All @@ -28,11 +26,12 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(

useImperativeHandle(
ref,
() => ({
focus: handleFocus,
blur: handleBlur,
...inputRef.current,
} as unknown as HTMLInputElement),
() =>
({
focus: handleFocus,
blur: handleBlur,
...inputRef.current,
} as unknown as HTMLInputElement),
[handleBlur, handleFocus],
);

Expand Down
8 changes: 4 additions & 4 deletions govtool/frontend/src/components/atoms/LoadingButton.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Button, CircularProgress } from '@mui/material';
import { Button, CircularProgress } from "@mui/material";

import { LoadingButtonProps } from './types';
import { LoadingButtonProps } from "./types";

export const LoadingButton = ({
isLoading,
disabled,
children,
size = 'large',
size = "large",
sx,
...rest
}: LoadingButtonProps) => {
Expand All @@ -24,7 +24,7 @@ export const LoadingButton = ({
{...rest}
>
{isLoading && (
<CircularProgress size={26} sx={{ position: 'absolute' }} />
<CircularProgress size={26} sx={{ position: "absolute" }} />
)}
{children}
</Button>
Expand Down
4 changes: 2 additions & 2 deletions govtool/frontend/src/components/atoms/Spacer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box } from '@mui/material';
import { SpacerProps } from '.';
import { Box } from "@mui/material";
import { SpacerProps } from ".";

export const Spacer = ({ x, y }: SpacerProps) => <Box pt={y} pr={x} />;
11 changes: 4 additions & 7 deletions govtool/frontend/src/components/atoms/StakeRadio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ type StakeRadioProps = {
};

export const StakeRadio: FC<StakeRadioProps> = ({ ...props }) => {
const {
dataTestId, isChecked = false, stakeKey, onChange,
} = props;
const { dataTestId, isChecked = false, stakeKey, onChange } = props;
const {
palette: { boxShadow1 },
} = theme;
const { isMobile } = useScreenDimension();
const { powerIsLoading, votingPower } = useGetAdaHolderVotingPowerQuery(stakeKey);
const { powerIsLoading, votingPower } =
useGetAdaHolderVotingPowerQuery(stakeKey);
const { t } = useTranslation();

return (
Expand Down Expand Up @@ -83,9 +82,7 @@ export const StakeRadio: FC<StakeRadioProps> = ({ ...props }) => {
fontWeight={600}
marginLeft="4px"
>
{" "}
{correctAdaFormat(votingPower) ?? 0}
{correctAdaFormat(votingPower) ?? 0}
</Typography>
)}
</Box>
Expand Down
19 changes: 8 additions & 11 deletions govtool/frontend/src/components/atoms/TextArea.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
forwardRef, useCallback, useImperativeHandle, useRef,
} from "react";
import { forwardRef, useCallback, useImperativeHandle, useRef } from "react";
import { TextareaAutosize, styled } from "@mui/material";

import { useScreenDimension } from "@hooks";
Expand All @@ -22,9 +20,7 @@ const TextAreaBase = styled(TextareaAutosize)(
);

export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
({
errorMessage, maxLength = 500, onBlur, onFocus, ...props
}, ref) => {
({ errorMessage, maxLength = 500, onBlur, onFocus, ...props }, ref) => {
const { isMobile } = useScreenDimension();
const textAraeRef = useRef<HTMLTextAreaElement>(null);

Expand All @@ -46,11 +42,12 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(

useImperativeHandle(
ref,
() => ({
focus: handleFocus,
blur: handleBlur,
...textAraeRef.current,
} as unknown as HTMLTextAreaElement),
() =>
({
focus: handleFocus,
blur: handleBlur,
...textAraeRef.current,
} as unknown as HTMLTextAreaElement),
[handleBlur, handleFocus],
);

Expand Down
26 changes: 13 additions & 13 deletions govtool/frontend/src/components/atoms/Typography.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Typography as MUITypography } from '@mui/material';
import { TypographyProps } from './types';
import { Typography as MUITypography } from "@mui/material";
import { TypographyProps } from "./types";

export const Typography = ({
color,
variant = 'body1',
variant = "body1",
...props
}: TypographyProps) => {
const fontSize = {
Expand Down Expand Up @@ -33,16 +33,16 @@ export const Typography = ({
}[variant];

const lineHeight = {
headline1: '110px',
headline2: '57px',
headline3: '44px',
headline4: '40px',
headline5: '36px',
title1: '32px',
title2: '28px',
body1: '24px',
body2: '20px',
caption: '16px',
headline1: "110px",
headline2: "57px",
headline3: "44px",
headline4: "40px",
headline5: "36px",
title1: "32px",
title2: "28px",
body1: "24px",
body2: "20px",
caption: "16px",
}[variant];

return (
Expand Down
12 changes: 6 additions & 6 deletions govtool/frontend/src/components/atoms/VotePill.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Vote } from '@models';
import { Box, Typography } from '@mui/material';
import { Vote } from "@models";
import { Box, Typography } from "@mui/material";

export const VotePill = ({
vote,
Expand All @@ -17,16 +17,16 @@ export const VotePill = ({
px={2.25}
border={1}
borderColor={
VOTE === 'yes' ? '#C0E4BA' : VOTE === 'no' ? '#EDACAC' : '#99ADDE'
VOTE === "yes" ? "#C0E4BA" : VOTE === "no" ? "#EDACAC" : "#99ADDE"
}
bgcolor={
VOTE === 'yes' ? '#F0F9EE' : VOTE === 'no' ? '#FBEBEB' : '#E6EBF7'
VOTE === "yes" ? "#F0F9EE" : VOTE === "no" ? "#FBEBEB" : "#E6EBF7"
}
borderRadius={100}
textAlign="center"
minWidth="50px"
maxWidth={maxWidth ? `${maxWidth}px` : 'auto'}
width={width ? `${width}px` : 'auto'}
maxWidth={maxWidth ? `${maxWidth}px` : "auto"}
width={width ? `${width}px` : "auto"}
maxHeight="14px"
>
<Typography
Expand Down
Loading

0 comments on commit 8841a24

Please sign in to comment.