Skip to content

Commit 1f26de9

Browse files
committed
fix: expose experimental autoAlign input on icon button
1 parent 27e4e6c commit 1f26de9

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-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: 38 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,39 @@ 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+
[buttonNgClass]="buttonNgClass"
116+
[buttonAttributes]="buttonAttributes"
117+
[disabled]="disabled"
118+
[description]="description"
119+
(click)="onClick($event)"
120+
(mouseenter)="onMouseEnter($event)"
121+
(mouseleave)="onMouseleave($event)"
122+
(focus)="onFocus($event)"
123+
(blur)="onBlur($event)">
124+
<svg class="cds--btn__icon" cdsIcon="copy" size="16"></svg>
125+
</cds-icon-button>
126+
</div>
127+
</div>
128+
`
129+
});
130+
export const WithAutoAlign = AutoAlignTemplate.bind({});
131+
WithAutoAlign.args = {
132+
autoAlign: true,
133+
description: "Icon Description",
134+
align: "top",
135+
isOpen: true
136+
};

0 commit comments

Comments
 (0)