Skip to content

Commit

Permalink
refactor -> Move types closer to the comp and rm utils folders
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeparticle committed Nov 4, 2023
1 parent a23a143 commit f7da5cf
Show file tree
Hide file tree
Showing 38 changed files with 193 additions and 245 deletions.
8 changes: 7 additions & 1 deletion ui/src/components/General/ClipboardButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { ResponsiveButton } from "components/General/FormComponents";
import style from "./ClipboardButton.module.scss";
import { ClipboardButtonProps } from "./utils/types";
import Icon from "components/General/Icon";

interface ClipboardButtonProps {
copyToClipboard: (text: string) => void;
copied: boolean;
text: string;
label?: boolean;
}

const ClipboardButton: React.FC<ClipboardButtonProps> = ({
copyToClipboard,
copied,
Expand Down
8 changes: 0 additions & 8 deletions ui/src/components/General/ClipboardButton/utils/types.ts

This file was deleted.

9 changes: 8 additions & 1 deletion ui/src/components/General/CodeEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import useMode from "hooks/useMode";
import { Form } from "antd";
import style from "./CodeEditor.module.scss";
import ValidateStatus from "./components/ValidateStatus";
import { CodeEditorProps } from "./utils/types";

interface CodeEditorProps {
handleCode: (code: string | undefined) => void;
language: string;
code: string;
label: string;
status?: string;
}

const CodeEditor: React.FC<CodeEditorProps> = ({
handleCode,
Expand Down
9 changes: 0 additions & 9 deletions ui/src/components/General/CodeEditor/utils/types.ts

This file was deleted.

6 changes: 5 additions & 1 deletion ui/src/components/General/CodeHighlightWithCopy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import {
obsidian,
stackoverflowLight,
} from "react-syntax-highlighter/dist/esm/styles/hljs";
import { CodeHighlightWithCopyProps } from "./utils/types";
import style from "./CodeHighlightwithCopy.module.scss";
import useMode from "hooks/useMode";

interface CodeHighlightWithCopyProps {
codeString: string;
language: string;
}

const CodeHighlightWithCopy: React.FC<CodeHighlightWithCopyProps> = ({
codeString,
language,
Expand Down

This file was deleted.

8 changes: 7 additions & 1 deletion ui/src/components/General/ColorPickerWithInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { Card } from "antd";
import { ResponsiveInputWithLabel } from "components/General/FormComponents";
import { ColorPicker as CP } from "@mantine/core";
import style from "./ColorPickerWithInput.module.scss";
import { ColorPickerWithInputProps } from "./utils/constants";

interface ColorPickerWithInputProps {
value: string;
label: string;
setValue: (e: React.ChangeEvent<HTMLInputElement>) => void;
setColor: (color: string) => void;
}

const ColorPickerWithInput: React.FC<ColorPickerWithInputProps> = ({
value,
Expand Down

This file was deleted.

23 changes: 21 additions & 2 deletions ui/src/components/General/DropdownDownloadButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
import React from "react";
import { ResponsiveDropdownButton } from "components/General/FormComponents";
import Icon from "components/General/Icon";
import { DropdownDownloadButtonProps } from "./utils/types";
import { IMAGE_TYPE, items } from "./utils/constants";
import { MenuProps } from "antd";

const IMAGE_TYPE = {
jpeg: ".jpeg",
png: ".png",
};

const items: MenuProps["items"] = [
{
label: "Download JPEG",
key: IMAGE_TYPE.jpeg,
},
{
label: "Download PNG",
key: IMAGE_TYPE.png,
},
];

interface DropdownDownloadButtonProps {
handleDownload: (val: string) => void;
}

const DropdownDownloadButton: React.FC<DropdownDownloadButtonProps> = ({
handleDownload,
Expand Down

This file was deleted.

This file was deleted.

62 changes: 55 additions & 7 deletions ui/src/components/General/FormComponents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,66 @@ import {
Segmented,
Select,
Button as AntButton,
ButtonProps,
Dropdown,
} from "antd";
import React from "react";
import React, { ReactNode } from "react";
import withLabelSize from "components/Hoc/withLabelSize/withLabelSize";
import {
InputComponentProps,
SegmentComponentProps,
SelectComponentProps,
} from "./utils/types";
import withSize from "components/Hoc/withSize/withSize";
import { DropdownButtonProps } from "antd/es/dropdown";
interface Option {
value: string;
label: string;
}

interface SelectComponentProps {
label?: string;
value?: string;
defaultActiveFirstOption?: boolean;
onSelect?: (value: string, option: Option) => void;
options: Option[];
}

interface SegmentComponentProps {
label?: string;
value: string;
onChange: (value: string | number) => void;
options: Option[];
}

type NumberType = {
type: "number";
value: number;
onChange: (value: number | null) => void;
};

type TextType = {
type: "text";
value: string;
onChange: (value: React.ChangeEvent<HTMLInputElement>) => void;
};

type InputComponentProps = {
label: string;
precision?: number;
min?: number;
max?: number;
step?: number;
tooltip?: string;
placeholder?: string;
addonBefore?: ReactNode;
addonAfter?: ReactNode;
style?: React.CSSProperties;
} & (NumberType | TextType);

interface ButtonProps {
children?: React.ReactNode;
disabled?: boolean;
onClick?: () => void;
className?: string;
icon?: React.ReactNode;
shape?: "circle" | "round" | undefined;
type?: "link" | "text" | "default" | "dashed" | "primary" | undefined;
}

const ResponsiveSelect: React.FC<SelectComponentProps> = (props) => {
return <Select {...props} />;
Expand Down
61 changes: 0 additions & 61 deletions ui/src/components/General/FormComponents/utils/types.ts

This file was deleted.

10 changes: 8 additions & 2 deletions ui/src/components/General/ListItems/News/News.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { NewsType } from "./utils/types";
import { Card, Image, Skeleton, Space, Typography } from "antd";
import { ListItemProps } from "components/RenderProps/List/utils/types";
import { ListItemProps } from "components/RenderProps/List";
const { Title } = Typography;

export interface NewsType {
title: string;
content: string;
url: string;
image?: string;
}

const News: React.FC<ListItemProps<NewsType>> = ({
resource,
handleOnClick,
Expand Down
8 changes: 0 additions & 8 deletions ui/src/components/General/ListItems/News/utils/types.ts

This file was deleted.

18 changes: 16 additions & 2 deletions ui/src/components/General/ListItems/Resource/Resource.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import { Avatar, Card, Skeleton, Space, Tag, Typography } from "antd";
import style from "./Resource.module.scss";
import { ResourceType } from "./utils/types";
import { ListItemProps } from "components/RenderProps/List/utils/types";
import Clipboard from "components/RenderProps/Clipboard";
import ClipboardButton from "components/General/ClipboardButton";
import { ListItemProps } from "components/RenderProps/List";

const { Title } = Typography;

export type SocialName = "github" | "youtube" | "website";

interface Social {
name: SocialName;
url: string;
}

export interface ResourceType {
name: string;
category: string;
subCategory: string[];
socials: Social[];
url: string;
}

const Resource: React.FC<ListItemProps<ResourceType>> = ({
resource,
handleOnClick,
Expand Down
16 changes: 0 additions & 16 deletions ui/src/components/General/ListItems/Resource/utils/types.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ import { Button, Skeleton } from "antd";
import { Typography, Tag, Dropdown } from "antd";
import Icon from "components/General/Icon";
import { classNames } from "utils/helper-functions/string";
import { NotificationListProps } from "components/General/Notification/utils/types";
import { Markdown } from "components/General/Notification/types";
const { Title } = Typography;

interface NotificationListProps {
notifications: Markdown[] | undefined;
showRedFlag: boolean;
isLoading: boolean;
isError: boolean;
handleRedFlagNotification: () => void;
}

const NotificationList: React.FC<NotificationListProps> = ({
notifications,
isLoading,
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/General/Notification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import {
NOTIFICATION_KEY,
NOTIFICATION_RED_FLAG_KEY,
NOTIFICATION_URL,
} from "./utils/constants";
} from "./constants";
import useGetNotifications from "hooks/useGetNotifications";
import NotificationList from "./components/NotificationList";
import {
getLocalstorageValue,
setLocalstorageValue,
} from "utils/helper-functions/storage";
import { compareDate } from "./utils/helper";
import { compareDate } from "./helper";

const Notification: React.FC = () => {
const { notifications, isLoading, isError } = useGetNotifications(
Expand Down
Loading

0 comments on commit f7da5cf

Please sign in to comment.