-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
Copy pathEuiTabLink.tsx
50 lines (42 loc) · 1.45 KB
/
EuiTabLink.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import cls from 'classnames';
import styled from 'styled-components';
import theme from '@elastic/eui/dist/eui_theme_light.json';
import { px, unit } from '../../style/variables';
// TODO: replace this component with EUITab w/ a href prop
// as soon as EUI is upgraded to 13.8.1
// see https://github.com/elastic/eui/pull/2275
interface Props {
isSelected: boolean;
children: React.ReactNode;
}
// We need to remove padding and add it to the link,
// to prevent the user from clicking in the tab, but outside of the link
// We also need to override the color here to subdue the color of the link
// when not selected
const Wrapper = styled.div<{ isSelected: boolean }>`
padding: 0;
a {
display: inline-block;
padding: ${px(unit * 0.75)} ${px(unit)};
${({ isSelected }) =>
!isSelected ? `color: ${theme.euiTextColor} !important;` : ''}
}
`;
const EuiTabLink = (props: Props) => {
const { isSelected, children } = props;
const className = cls('euiTab', {
'euiTab-isSelected': isSelected,
});
return (
<Wrapper className={className} isSelected={isSelected}>
<span className={'euiTab__content'}>{children}</span>
</Wrapper>
);
};
export { EuiTabLink };