Skip to content

Migrate EuiBreadcrumbs, EuiHeader and children, and EuiLink to TS#2391

Merged
pugnascotia merged 5 commits intoelastic:masterfrom
pugnascotia:raiders-of-the-lost-ts
Oct 4, 2019
Merged

Migrate EuiBreadcrumbs, EuiHeader and children, and EuiLink to TS#2391
pugnascotia merged 5 commits intoelastic:masterfrom
pugnascotia:raiders-of-the-lost-ts

Conversation

@pugnascotia
Copy link
Copy Markdown
Contributor

Summary

Migrate EuiBreadcrumbs, EuiHeader and children, and EuiLink to TypeScript. I had to resort to some type casts around passing props to EuiButtonEmpty, so if anyone has any better ideas, please say.

Checklist

  • Checked in dark mode
  • Checked in mobile
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • Added documentation examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

Copy link
Copy Markdown
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

Nobody beats Rory's branch names


const limitBreadcrumbs = (breadcrumbs, max, showMaxPopover, allBreadcrumbs) => {
export type Breadcrumb = CommonProps & {
text: string;
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.

This previously accepted node, so we probably want to have ReactNode here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The issue here (and I meant to mention it in the PR) is that text is also used in a title attribute, so a <span> for example is rendered as title="[object Object]", which you could see being changed in one of the snapshots.

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.

Ah right. We have a utility that'll help with this. Let me look into it

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.

Ok. Updated.

@@ -0,0 +1 @@
export { Breadcrumb, EuiBreadcrumbs } from './breadcrumbs';
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.

Let's export EuiBreadcrumbsProps also


import { CommonProps } from '../common';

export const EuiHeader: FunctionComponent<CommonProps> = ({
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.

Need to add HTMLAttributes<HTMLDivElement> since we eventually spread props onto the div

import { EuiI18n } from '../../i18n';

export const EuiHeaderAlert = ({
type EuiHeaderAlertProps = CommonProps & {
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.

Again, need to add HTMLAttributes<HTMLDivElement> since we eventually spread props onto the div (L31)

export const EuiHeaderSectionItemButton = ({
import { CommonProps } from '../../common';

type Props = CommonProps & AnchorHTMLAttributes<HTMLButtonElement>;
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.

Suggested change
type Props = CommonProps & AnchorHTMLAttributes<HTMLButtonElement>;
type Props = CommonProps & ButtonHTMLAttributes<HTMLButtonElement>;

children?: ReactNode;
}
export type EuiHeaderLogoProps = CommonProps &
HTMLAttributes<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.

Suggested change
HTMLAttributes<HTMLAnchorElement> & {
AnchorHTMLAttributes<HTMLAnchorElement> & {

import { IconType } from '../../icon';

type Props = CommonProps &
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.

Looks like this could extend EuiButtonEmptyProps instead? Wouldn't have to cast it later on (I think)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Cast is still needed, unfortunately.

import { CommonProps } from '../../common';
import { Breadcrumb, EuiBreadcrumbs } from '../../breadcrumbs';

type Props = CommonProps & {
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.

Extend EuiBreadCrumbProps also since this spreads rest later

@pugnascotia
Copy link
Copy Markdown
Contributor Author

Cool, thanks @thompsongl. Any chance of a LGTM then?

Copy link
Copy Markdown
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

LGTM after changelog update.

Tested eui.d.ts file in Kibana and have a local branch with necessary updates for when the time comes.

@pugnascotia pugnascotia changed the title Migrate EuiBreadcrumbs, EuiHeader and children, and EuiLink to TS EuiBreadcrumbs, EuiHeader and children, and EuiLink to TS Oct 4, 2019
@pugnascotia pugnascotia merged commit f829b0e into elastic:master Oct 4, 2019
@pugnascotia pugnascotia deleted the raiders-of-the-lost-ts branch October 4, 2019 11:29
@pugnascotia pugnascotia changed the title EuiBreadcrumbs, EuiHeader and children, and EuiLink to TS Migrate EuiBreadcrumbs, EuiHeader and children, and EuiLink to TS Oct 4, 2019
snide pushed a commit to snide/eui that referenced this pull request Oct 10, 2019
Migrate EuiBreadcrumbs, EuiHeader and children, and EuiLink to TypeScript.
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.

2 participants