Skip to content

EasyDropdown => TypeScript#225

Merged
bkonuwa merged 7 commits intomasterfrom
easy-dropdown-ts
Oct 14, 2020
Merged

EasyDropdown => TypeScript#225
bkonuwa merged 7 commits intomasterfrom
easy-dropdown-ts

Conversation

@mdespuits
Copy link
Copy Markdown
Contributor

Fixes #196

Copy link
Copy Markdown
Contributor

@pixelbandito pixelbandito left a comment

Choose a reason for hiding this comment

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

I only have some suggestions for typing, so I'll go ahead and approve it.

group?: string;
/** This will be the array key and the fallback contents */
label: string;
onClick?: () => void;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You might be able to omit children and onClick from this definition, since those types should be defined already in the ItemProps (composed from ButtonProps, etc.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

removed.. tested in storybook and local dev environment and everything works as expected.

onClick?: () => void;
};

interface EasyDropdownProps extends DropdownProps {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here too, you might be able to omit many of these props, since they're already provided by DropdownProps
At least, these look redundant: children, className, disabled, isOpen

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done.


// Group menu items while preserving their order.
const menuItemGroups = useMemo(
const menuItemGroups = useMemo<Record<string, MenuItem[]>>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Super minor: You might not need to define the type here, since TS is sometimes pretty smart about inferring types.
I think it's worth trying, but not a big deal if TS demands you leave it in.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done.

export type ButtonElementProps = React.ButtonHTMLAttributes<
HTMLButtonElement
> & {
href?: undefined;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hmm, I'm coming in without a lot of context here, but why are we creating Button and Div types that have href props?

Copy link
Copy Markdown
Contributor

@pixelbandito pixelbandito left a comment

Choose a reason for hiding this comment

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

One little comment, but I'll pre-approve. Thank you for taking care of this!

className?: string;
export type ButtonElementProps = React.ButtonHTMLAttributes<HTMLButtonElement>;

type AnchorElementProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious: Anchor elements should already have href - did it need to be added here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😬 It was not needed. I removed it.

@bkonuwa bkonuwa merged commit f766d63 into master Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert EasyPill to TypeScript

4 participants