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

chore re-organized types #2338

Closed

Conversation

rivka-ungar
Copy link
Contributor

@rivka-ungar rivka-ungar requested a review from a team as a code owner August 8, 2024 10:56
Copy link
Contributor

@YossiSaadi YossiSaadi left a 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";
Copy link
Contributor

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";
Copy link
Contributor

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

Copy link
Contributor

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)

Copy link
Contributor

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";
Copy link
Contributor

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;
Copy link
Contributor

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;

Copy link
Contributor

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

Copy link
Contributor

@YossiSaadi YossiSaadi Aug 8, 2024

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, "/">;
Copy link
Contributor

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

Copy link
Contributor

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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type ToggleSizes = "small" | "medium";
export type ToggleSize = "small" | "medium";

wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was it unused?

@rivka-ungar rivka-ungar added breaking change vibe3 Related to 3.0 major labels Aug 11, 2024
@rivka-ungar rivka-ungar marked this pull request as draft August 15, 2024 09:16
@rivka-ungar rivka-ungar closed this Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change vibe3 Related to 3.0 major
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants