-
Notifications
You must be signed in to change notification settings - Fork 322
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
chore re-organized types #2338
chore re-organized types #2338
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about some of the stuff
let's talk about it, unless it was already discussed and decided
import Text from "../Text/Text"; | ||
import Flex from "../Flex/Flex"; | ||
import styles from "./AttentionBox.module.scss"; | ||
import { SubIcon } from "../Icon"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it out of "types" in purpose?
import styles from "./Avatar.module.scss"; | ||
import { SubIcon } from "../Icon"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, and for the rest usages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is a bit weird it is inside Box, isn't it? because in theory it is a very general type (we should maybe try to make this kind of general types file, to save us redundant re-writing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file also exports a function, do you think it can benefit to have a utils file as well and send it to there? so we would better separate types from utils
@@ -3,11 +3,11 @@ import cx from "classnames"; | |||
import React, { CSSProperties, forwardRef, Ref } from "react"; | |||
import useMergeRef from "../../hooks/useMergeRef"; | |||
import { IconType as IconTypeEnum } from "./IconConstants"; | |||
import { IconType } from "./Icon.types"; | |||
import { IconType, MouseEventCallBack, SubIcon } from "./Icon.types"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also sound like something very generic that should be in types rather in Icon.types (MouseEventCallBack)
export type IconType = "svg" | "font" | "src"; | ||
|
||
// Custom type for all mouse event callbacks | ||
export type MouseEventCallBack = (event: React.MouseEvent<HTMLElement | SVGElement>) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it shouldn't be a different type. I think this should be inlined:
onClick?: (event: React.MouseEvent<HTMLElement | SVGElement>) => void;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since it is being used only once I don't see much value in making a type for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe even better, and make this type even more redundant:
onClick?: MouseEventHandler<HTMLElement | SVGElement>
|
||
type IconPath = `/icons/${keyof typeof allIcons}`; | ||
type SplittedIconPath = SplitString<IconPath, "/">; | ||
type SplittedIconPath = Helpers<IconPath, "/">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this intended? should it be called Helpers? I don't understand what exactly the helpers type does, but maybe a more meaningful name like SplitString can better explain what it does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not actually familiar with what's going on there, but Helpers sound too generic
@@ -1 +1 @@ | |||
export type Sizes = "small" | "medium"; | |||
export type ToggleSizes = "small" | "medium"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export type ToggleSizes = "small" | "medium"; | |
export type ToggleSize = "small" | "medium"; |
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was it unused?
https://monday.monday.com/boards/3532714909/views/80492480/pulses/7160133818