Skip to content

Commit ea07b2a

Browse files
authored
Merge pull request #2856 from Geoffrey0/icon-button-tooltip-auto-align
fix: expose experimental autoAlign input on icon button
2 parents cb12fd9 + 7d3cbe2 commit ea07b2a

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

src/button/base-icon-button.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ export class BaseIconButton {
3333
"bottom" | "bottom-left" | "bottom-right" |
3434
"left" | "left-bottom" | "left-top" |
3535
"right" | "right-bottom" | "right-top" = "bottom";
36+
/**
37+
* **Experimental**: Use floating-ui to position the tooltip
38+
* This is not toggleable - should be assigned once
39+
*/
40+
@Input() autoAlign = false;
3641
/**
3742
* Set delay before tooltip is shown
3843
*/

src/button/icon-button.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { ButtonSize, ButtonType } from "./button.types";
3333
[highContrast]="highContrast"
3434
[isOpen]="isOpen"
3535
[align]="align"
36+
[autoAlign]="autoAlign"
3637
[enterDelayMs]="enterDelayMs"
3738
[leaveDelayMs]="leaveDelayMs"
3839
(click)="emitClickEvent($event, 'tooltip')">

src/button/icon-button.stories.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export default {
2222
kind: "primary",
2323
size: "md",
2424
isExpressive: "false",
25-
disabled: false
25+
disabled: false,
26+
autoAlign: false
2627
},
2728
argTypes: {
2829
align: {
@@ -97,3 +98,40 @@ Basic.args = {
9798
"example-global-class": true
9899
}
99100
};
101+
102+
const AutoAlignTemplate = (args) => ({
103+
props: args,
104+
template: `
105+
<div style="height:3000px">
106+
Scrolling will update the position of the tooltip:
107+
<div style="position: absolute; top: 500px; left: 500px;">
108+
<cds-icon-button
109+
buttonId="icon-btn1"
110+
type="button"
111+
[kind]="kind"
112+
[size]="size"
113+
[align]="align"
114+
[autoAlign]="autoAlign"
115+
[isOpen]="isOpen"
116+
[buttonNgClass]="buttonNgClass"
117+
[buttonAttributes]="buttonAttributes"
118+
[disabled]="disabled"
119+
[description]="description"
120+
(click)="onClick($event)"
121+
(mouseenter)="onMouseEnter($event)"
122+
(mouseleave)="onMouseleave($event)"
123+
(focus)="onFocus($event)"
124+
(blur)="onBlur($event)">
125+
<svg class="cds--btn__icon" cdsIcon="copy" size="16"></svg>
126+
</cds-icon-button>
127+
</div>
128+
</div>
129+
`
130+
});
131+
export const WithAutoAlign = AutoAlignTemplate.bind({});
132+
WithAutoAlign.args = {
133+
autoAlign: true,
134+
description: "Icon Description",
135+
align: "top",
136+
isOpen: true
137+
};

0 commit comments

Comments
 (0)