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

EuiTab href #1

Merged

Conversation

thompsongl
Copy link

Just a little PR to help you learn what all goes into a TS conversion PR.

I'll leave comments in each file to describe what's what. I'm more than happy to walk you through anything that doesn't make sense on Zoom

@@ -37,4 +39,5 @@ declare module '@elastic/eui' {
export const EuiTabbedContent: FunctionComponent<
EuiTabbedContentProps & CommonProps & HTMLAttributes<HTMLDivElement>
>;
export const EuiTab: FunctionComponent<EuiTabProps>;
Copy link
Author

Choose a reason for hiding this comment

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

Because the tabs/ directory isn't entirely TypeScript yet, we still need to export all the components from here so they can be picked up properly when imported.

Once all of tabs/ has been converted, this file will be removed.

@@ -27,13 +26,13 @@ describe('EuiTab', () => {
describe('Props', () => {
describe('onClick', () => {
test('is called when the button is clicked', () => {
const onClickHandler = sinon.stub();
const onClickHandler = jest.fn();
Copy link
Author

Choose a reason for hiding this comment

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

When converting a component to TS, also convert the related test file.
We don't use the sinon library much, so I just replaced it with a parallel library that we do use.

@@ -17,25 +16,21 @@ export interface EuiTabProps extends CommonProps {
type EuiTabPropsForAnchor = EuiTabProps &
AnchorHTMLAttributes<HTMLAnchorElement> & {
href?: string;
onClick?: MouseEventHandler<HTMLButtonElement>;
buttonRef?: Ref<HTMLAnchorElement>;
onClick?: MouseEventHandler<HTMLAnchorElement>;
Copy link
Author

Choose a reason for hiding this comment

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

HTMLAnchorElement for the <a>

@@ -17,25 +16,21 @@ export interface EuiTabProps extends CommonProps {
type EuiTabPropsForAnchor = EuiTabProps &
AnchorHTMLAttributes<HTMLAnchorElement> & {
href?: string;
onClick?: MouseEventHandler<HTMLButtonElement>;
buttonRef?: Ref<HTMLAnchorElement>;
Copy link
Author

Choose a reason for hiding this comment

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

I think this was a leftover from a copy+paste. The component didn't use ref before, so we can just delete this part.

@@ -55,12 +50,10 @@ export const EuiTab: FunctionComponent<Props> = ({
<a
role="tab"
aria-selected={!!isSelected}
onClick={onClick as MouseEventHandler<HTMLAnchorElement>}
Copy link
Author

Choose a reason for hiding this comment

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

Just a clean up to avoid the ominous as casting. onClick is now part of ...rest, which is more of a subjective choice, but it's more in line with how we've handled other button-like components.

@elizabetdev
Copy link
Owner

Thanks @thompsongl. I was reviewing the comments and they make sense.

@elizabetdev elizabetdev merged commit 444d3aa into elizabetdev:euitab-href-prop Sep 4, 2019
elizabetdev pushed a commit that referenced this pull request Mar 5, 2020
* removed duplicate icons

* Fixing changelog and updating tests (#1)

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
elizabetdev pushed a commit that referenced this pull request Jul 19, 2021
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.

2 participants