Skip to content

Commit

Permalink
EuiHeaderLogo converted to TS (#1892)
Browse files Browse the repository at this point in the history
* `EuiHeaderLogo` converted to TS

* `EuiHeaderLogo` exported types

* `EuiHeaderLogo` code review

* `EuiHeaderLogo` snapshots
  • Loading branch information
Theofanis Despoudis authored and chandlerprall committed May 3, 2019
1 parent 55330de commit 27fd998
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ exports[`EuiHeaderLogo is rendered 1`] = `
class="euiIcon euiIcon--large euiHeaderLogo__icon"
focusable="false"
height="32"
title="Elastic"
viewBox="0 0 32 32"
width="32"
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -56,7 +55,6 @@ exports[`EuiHeaderLogo renders href 1`] = `
class="euiIcon euiIcon--large euiHeaderLogo__icon"
focusable="false"
height="32"
title="Elastic"
viewBox="0 0 32 32"
width="32"
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -102,7 +100,6 @@ exports[`EuiHeaderLogo renders optional props 1`] = `
class="euiIcon euiIcon--large euiHeaderLogo__icon"
focusable="false"
height="16"
title="Moby Dick"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
Expand Down
38 changes: 0 additions & 38 deletions src/components/header/header_logo.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test/required_props';
import { requiredProps } from '../../test';

import { EuiHeaderLogo } from './header_logo';

describe('EuiHeaderLogo', () => {
test('is rendered', () => {
const component = render(
<EuiHeaderLogo {...requiredProps} />
);
const component = render(<EuiHeaderLogo {...requiredProps} />);

expect(component)
.toMatchSnapshot();
expect(component).toMatchSnapshot();
});

test('renders href', () => {
const component = render(
<EuiHeaderLogo href="#" />
);
const component = render(<EuiHeaderLogo href="#" />);

expect(component)
.toMatchSnapshot();
expect(component).toMatchSnapshot();
});

test('renders optional props', () => {
Expand All @@ -32,7 +26,6 @@ describe('EuiHeaderLogo', () => {
/>
);

expect(component)
.toMatchSnapshot();
expect(component).toMatchSnapshot();
});
});
33 changes: 33 additions & 0 deletions src/components/header/header_logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { FunctionComponent, HTMLAttributes, ReactNode } from 'react';
import classNames from 'classnames';

import { EuiIcon, IconType } from '../icon';
import { CommonProps } from '../common';

export interface EuiHeaderLogoProps {
href?: string;
iconType?: IconType;
iconTitle?: string;
children?: ReactNode;
}

export const EuiHeaderLogo: FunctionComponent<
CommonProps & HTMLAttributes<HTMLAnchorElement> & EuiHeaderLogoProps
> = ({
iconType = 'logoElastic',
iconTitle = 'Elastic',
href,
children,
className,
...rest
}) => {
const classes = classNames('euiHeaderLogo', className);

return (
<a href={href} className={classes} {...rest}>
<EuiIcon className="euiHeaderLogo__icon" size="l" type={iconType} />

{children && <span className="euiHeaderLogo__text">{children}</span>}
</a>
);
};
14 changes: 14 additions & 0 deletions src/components/header/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
EuiHeaderLogoProps as HeaderLogoProps,
EuiHeaderLogo as HeaderLogo,
} from './header_logo';

declare module '@elastic/eui' {
/**
* header logo type defs
*
* @see './header_logo.js'
*/
export interface EuiHeaderLogoProps extends HeaderLogoProps {}
export const EuiHeaderLogo: typeof HeaderLogo;
}
1 change: 1 addition & 0 deletions src/components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/// <reference path="./focus_trap/index.d.ts" />
/// <reference path="./form/index.d.ts" />
/// <reference path="./health/index.d.ts" />
/// <reference path="./header/index.d.ts" />
/// <reference path="./key_pad_menu/index.d.ts" />
/// <reference path="./link/index.d.ts" />
/// <reference path="./modal/index.d.ts" />
Expand Down

0 comments on commit 27fd998

Please sign in to comment.