Skip to content

Commit

Permalink
Add iconGap to TopNavControlButtonData abd TopNavControlLinkData
Browse files Browse the repository at this point in the history
Signed-off-by: Miki <[email protected]>
  • Loading branch information
AMoo-Miki committed Aug 22, 2024
1 parent aca559a commit 2cf9017
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type TopNavControlLinkData = TopNavControlButtonOrLinkOrIconData &
run?: TopNavControlAction;
iconType?: EuiHeaderLinkProps['iconType'];
iconSide?: EuiHeaderLinkProps['iconSide'];
iconGap?: EuiHeaderLinkProps['iconGap'];
color?: EuiHeaderLinkProps['color'];
controlType: 'link';
},
Expand All @@ -48,6 +49,7 @@ export type TopNavControlButtonData = TopNavControlButtonOrLinkOrIconData &
run?: TopNavControlAction;
iconType?: EuiButtonProps['iconType'];
iconSide?: EuiButtonProps['iconSide'];
iconGap?: EuiHeaderLinkProps['iconGap'];
color?: EuiButtonProps['color'];
fill?: EuiButtonProps['fill'];
controlType?: 'button';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@
* under the License.
*/

import { EuiButton, EuiHeaderLink, EuiButtonIcon, EuiText, EuiToolTip } from '@elastic/eui';
import {
EuiButton,
EuiHeaderLink,
EuiButtonIcon,
EuiText,
EuiToolTip,
EuiHeaderLinkProps,
} from '@elastic/eui';
import { upperFirst } from 'lodash';
import React, { MouseEvent } from 'react';
import { TopNavControlData } from './top_nav_control_data';
Expand Down Expand Up @@ -103,12 +110,21 @@ export function TopNavControlItem(props: TopNavControlData) {
break;

case 'link':
let { iconType, iconSide } = props;
let iconGap: EuiHeaderLinkProps['iconGap'];
if (props.target === '_blank') {
iconType = 'popout';
iconSide = 'right';
iconGap = 's';
}

component = (
<EuiHeaderLink
// @ts-ignore using an undefined property to prevent abuse
size={props.sizeOverride || 's'}
iconType={props.iconType}
iconSide={props.iconSide}
iconType={iconType}
iconSide={iconSide}
iconGap={iconGap}
iconSize={props.iconSize}
color={props.color}
className={props.className}
Expand Down

0 comments on commit 2cf9017

Please sign in to comment.