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

Add typescript definitions for more components #326

Merged
merged 3 commits into from
Jan 26, 2018

Conversation

weltenwort
Copy link
Member

This adds type definitions for

  • <EuiFormRow>
  • <EuiRadioGroup>
  • <EuiSwitch>
  • <EuiLoadingSpinner>
  • <EuiLoadingChart>
  • <EuiProgress>

@weltenwort weltenwort self-assigned this Jan 19, 2018
Copy link
Contributor

@uboness uboness left a comment

Choose a reason for hiding this comment

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

overall LGTM, left a few comments

Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> & {
options?: EuiRadioGroupOption[];
idSelected?: string;
onChange: (id: string) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

should be of type EuiRadioGroupChangeCallback ?


export type EuiRadioGroupProps = CommonProps &
Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> & {
options?: EuiRadioGroupOption[];
Copy link
Contributor

Choose a reason for hiding this comment

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

should be required

Copy link
Member Author

Choose a reason for hiding this comment

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

It is listed in defaultProps though, which suggests the intention is for it to be optional.

Copy link
Contributor

Choose a reason for hiding this comment

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

good point, I didn't see the default props... it's still marked as a required propType (not sure how that behaves along with the default prop... would it still shout if one is not supplied?). In any case, we need to have a decision - it's either required or optional with a default... it make little sense to be both :)

/cc @snide ^

Copy link
Member Author

Choose a reason for hiding this comment

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

The defaultProps lead to isRequired not shouting.


export type EuiLoadingChartProps = CommonProps &
HTMLAttributes<HTMLDivElement> & {
mono?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we take this opportunity to also add mono to the propTypes?

| 'accent'
| 'danger'
| 'primary'
| 'secondar'
Copy link
Contributor

Choose a reason for hiding this comment

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

s/secondar/secondary

color?: EuiProgressColor;
position?: EuiProgressPosition;
max?: number;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we use this opportunity to remove unused indeterminate from propTypes?

Copy link
Member Author

@weltenwort weltenwort Jan 22, 2018

Choose a reason for hiding this comment

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

Looks like that should be a safe change. The tests did not cover it anyway. @snide, any objections?

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeterminate progress bars were still being used last time I checked. Why do you want to remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

The property does not seem to be used anywhere in the component itself. It is passed on to the <progress /> (as part of {...rest}), but the html specs don't recognize that attribute either. Instead the react code interprets the lack of a max property as being indeterminate and the html spec uses the value attribute for that. That's something we might want to align as well.

@weltenwort
Copy link
Member Author

@uboness, thanks for the great feedback. I made the changes except for the optional <RadioGroup> options prop (see above for the comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants