Skip to content

Commit

Permalink
Add EuiButtonEmptyTo components
Browse files Browse the repository at this point in the history
This PR adds another wrapper component for internal routing, the EuiButtonEmptyTo component.
  • Loading branch information
scottybollinger committed Dec 7, 2020
1 parent a6a8cc2 commit 47bc234
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import '../../__mocks__/kea.mock';

import React from 'react';
import { shallow, mount } from 'enzyme';
import { EuiLink, EuiButton, EuiPanel } from '@elastic/eui';
import { EuiLink, EuiButton, EuiButtonEmpty, EuiPanel } from '@elastic/eui';

import { mockKibanaValues, mockHistory } from '../../__mocks__';

import { EuiLinkTo, EuiButtonTo, EuiPanelTo } from './eui_components';
import { EuiLinkTo, EuiButtonTo, EuiButtonEmptyTo, EuiPanelTo } from './eui_components';

describe('EUI & React Router Component Helpers', () => {
beforeEach(() => {
Expand All @@ -31,6 +31,12 @@ describe('EUI & React Router Component Helpers', () => {
expect(wrapper.find(EuiButton)).toHaveLength(1);
});

it('renders an EuiButtonEmpty', () => {
const wrapper = shallow(<EuiButtonEmptyTo to="/" />);

expect(wrapper.find(EuiButtonEmpty)).toHaveLength(1);
});

it('renders an EuiPanel', () => {
const wrapper = shallow(<EuiPanelTo to="/" paddingSize="l" />);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@

import React from 'react';
import { useValues } from 'kea';
import { EuiLink, EuiButton, EuiButtonProps, EuiLinkAnchorProps, EuiPanel } from '@elastic/eui';
import {
EuiLink,
EuiButton,
EuiButtonEmpty,
EuiButtonEmptyProps,
EuiButtonProps,
EuiLinkAnchorProps,
EuiPanel,
} from '@elastic/eui';
import { EuiPanelProps } from '@elastic/eui/src/components/panel/panel';

import { KibanaLogic } from '../kibana';
Expand Down Expand Up @@ -83,6 +91,18 @@ export const EuiButtonTo: React.FC<ReactRouterEuiButtonProps> = ({
</ReactRouterHelper>
);

type ReactRouterEuiButtonEmptyProps = ReactRouterProps & EuiButtonEmptyProps;
export const EuiButtonEmptyTo: React.FC<ReactRouterEuiButtonEmptyProps> = ({
to,
onClick,
shouldNotCreateHref,
...rest
}) => (
<ReactRouterHelper {...{ to, onClick, shouldNotCreateHref }}>
<EuiButtonEmpty {...rest} />
</ReactRouterHelper>
);

type ReactRouterEuiPanelProps = ReactRouterProps & EuiPanelProps;
export const EuiPanelTo: React.FC<ReactRouterEuiPanelProps> = ({
to,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

export { letBrowserHandleEvent } from './link_events';
export { createHref, CreateHrefOptions } from './create_href';
export { EuiLinkTo, EuiButtonTo, EuiPanelTo } from './eui_components';
export { EuiLinkTo, EuiButtonTo, EuiButtonEmptyTo, EuiPanelTo } from './eui_components';

0 comments on commit 47bc234

Please sign in to comment.