Migrate EuiBreadcrumbs, EuiHeader and children, and EuiLink to TS#2391
Migrate EuiBreadcrumbs, EuiHeader and children, and EuiLink to TS#2391pugnascotia merged 5 commits intoelastic:masterfrom
Conversation
thompsongl
left a comment
There was a problem hiding this comment.
Nobody beats Rory's branch names
|
|
||
| const limitBreadcrumbs = (breadcrumbs, max, showMaxPopover, allBreadcrumbs) => { | ||
| export type Breadcrumb = CommonProps & { | ||
| text: string; |
There was a problem hiding this comment.
This previously accepted node, so we probably want to have ReactNode here.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Ah right. We have a utility that'll help with this. Let me look into it
src/components/breadcrumbs/index.ts
Outdated
| @@ -0,0 +1 @@ | |||
| export { Breadcrumb, EuiBreadcrumbs } from './breadcrumbs'; | |||
There was a problem hiding this comment.
Let's export EuiBreadcrumbsProps also
src/components/header/header.tsx
Outdated
|
|
||
| import { CommonProps } from '../common'; | ||
|
|
||
| export const EuiHeader: FunctionComponent<CommonProps> = ({ |
There was a problem hiding this comment.
Need to add HTMLAttributes<HTMLDivElement> since we eventually spread props onto the div
| import { EuiI18n } from '../../i18n'; | ||
|
|
||
| export const EuiHeaderAlert = ({ | ||
| type EuiHeaderAlertProps = CommonProps & { |
There was a problem hiding this comment.
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>; |
There was a problem hiding this comment.
| type Props = CommonProps & AnchorHTMLAttributes<HTMLButtonElement>; | |
| type Props = CommonProps & ButtonHTMLAttributes<HTMLButtonElement>; |
| children?: ReactNode; | ||
| } | ||
| export type EuiHeaderLogoProps = CommonProps & | ||
| HTMLAttributes<HTMLAnchorElement> & { |
There was a problem hiding this comment.
| HTMLAttributes<HTMLAnchorElement> & { | |
| AnchorHTMLAttributes<HTMLAnchorElement> & { |
| import { IconType } from '../../icon'; | ||
|
|
||
| type Props = CommonProps & | ||
| AnchorHTMLAttributes<HTMLAnchorElement> & { |
There was a problem hiding this comment.
Looks like this could extend EuiButtonEmptyProps instead? Wouldn't have to cast it later on (I think)
There was a problem hiding this comment.
Cast is still needed, unfortunately.
| import { CommonProps } from '../../common'; | ||
| import { Breadcrumb, EuiBreadcrumbs } from '../../breadcrumbs'; | ||
|
|
||
| type Props = CommonProps & { |
There was a problem hiding this comment.
Extend EuiBreadCrumbProps also since this spreads rest later
|
Cool, thanks @thompsongl. Any chance of a LGTM then? |
thompsongl
left a comment
There was a problem hiding this comment.
LGTM after changelog update.
Tested eui.d.ts file in Kibana and have a local branch with necessary updates for when the time comes.
Migrate EuiBreadcrumbs, EuiHeader and children, and EuiLink to TypeScript.
Summary
Migrate
EuiBreadcrumbs,EuiHeaderand children, andEuiLinkto TypeScript. I had to resort to some type casts around passing props toEuiButtonEmpty, so if anyone has any better ideas, please say.Checklist