Skip to content

Commit 2d2ddbe

Browse files
Allow setting notification indicator position on split button
1 parent 3db1487 commit 2d2ddbe

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/platform/packages/private/kbn-split-button/src/split_button.stories.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,14 @@ export const WithNotificationIndicator = {
193193
showNotificationIndicator: true,
194194
notifcationIndicatorTooltipContent: 'You have unsaved changes',
195195
notificationIndicatorColor: 'primary',
196-
notificationIndicatorSize: 'l',
197-
size: 'm',
196+
notificationIndicatorSize: 'm',
197+
notificationIndicatorPosition: {
198+
top: 2,
199+
left: 25,
200+
},
201+
size: 's',
202+
color: 'text',
203+
iconType: 'save',
198204
},
199205
render: (args: {
200206
showNotificationIndicator: boolean;
@@ -205,6 +211,12 @@ export const WithNotificationIndicator = {
205211
notificationIndicatorSize: React.ComponentProps<
206212
typeof SplitButtonWithNotification
207213
>['notificationIndicatorSize'];
214+
notificationIndicatorPosition?: {
215+
top?: number;
216+
right?: number;
217+
};
218+
color: React.ComponentProps<typeof SplitButton>['color'];
219+
iconType: React.ComponentProps<typeof SplitButton>['iconType'];
208220
size: React.ComponentProps<typeof SplitButton>['size'];
209221
}) => (
210222
<SplitButtonWithNotification secondaryButtonIcon="arrowDown" {...args}>

src/platform/packages/private/kbn-split-button/src/split_button_with_notification.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,22 @@ export type SplitButtonWithNotificationProps = SplitButtonProps & {
2323
notificationIndicatorColor?: IconColor;
2424
notificationIndicatorSize?: IconSize;
2525
notifcationIndicatorTooltipContent?: string;
26+
notificationIndicatorPosition?: {
27+
top?: number;
28+
right?: number;
29+
left?: number;
30+
bottom?: number;
31+
};
32+
notificationIndicatorHasStroke?: boolean;
2633
};
2734

2835
export const SplitButtonWithNotification = ({
2936
showNotificationIndicator = false,
3037
notificationIndicatorColor = 'primary',
3138
notificationIndicatorSize = 'l',
3239
notifcationIndicatorTooltipContent,
40+
notificationIndicatorPosition,
41+
notificationIndicatorHasStroke = true,
3342
...splitButtonProps
3443
}: SplitButtonWithNotificationProps) => {
3544
const euiThemeContext = useEuiTheme();
@@ -52,9 +61,18 @@ export const SplitButtonWithNotification = ({
5261
data-test-subj="split-button-notification-indicator"
5362
css={{
5463
position: 'absolute' as const,
55-
top: '-10px',
56-
right: secondaryButtonWidth,
64+
top: notificationIndicatorPosition?.top ?? -10,
65+
right: notificationIndicatorPosition?.right ?? secondaryButtonWidth,
66+
left: notificationIndicatorPosition?.left,
67+
bottom: notificationIndicatorPosition?.bottom,
5768
zIndex: 1,
69+
...(notificationIndicatorHasStroke && {
70+
'& svg': {
71+
stroke: 'white',
72+
strokeWidth: '2px',
73+
paintOrder: 'stroke fill',
74+
},
75+
}),
5876
}}
5977
>
6078
<EuiIconTip

0 commit comments

Comments
 (0)