Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(components): updates tooltip component #2394

Merged
merged 13 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/swift-tips-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@swisspost/design-system-documentation': minor
'@swisspost/design-system-components': minor
---

Update tooltip minHeight and maxWidth and added a new property arrow to tooltip that defines wheter or not the pointer arrow is displayed.
b1aserlu marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ export namespace Components {
"show": (panelName: string) => Promise<void>;
}
interface PostTooltip {
/**
* Wheter or not to display a little pointer arrow
*/
"arrow"?: boolean;
/**
* Programmatically hide this tooltip
*/
Expand Down Expand Up @@ -469,6 +473,10 @@ declare namespace LocalJSX {
"onTabChange"?: (event: PostTabsCustomEvent<HTMLPostTabPanelElement['name']>) => void;
}
interface PostTooltip {
/**
* Wheter or not to display a little pointer arrow
*/
"arrow"?: boolean;
/**
* Defines the placement of the tooltip according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement. Tooltips are automatically flipped to the opposite side if there is not enough available space and are shifted towards the viewport if they would overlap edge boundaries.
*/
Expand Down
b1aserlu marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
post-popovercontainer {
&::part(popover) {
padding: spacing.$size-micro spacing.$size-mini;
max-width: 2 * spacing.$size-bigger-giant - spacing.$size-mini;
min-height: spacing.$size-regular;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export class PostTooltip {
*/
@Prop() readonly placement?: Placement = 'top';

/**
* Wheter or not to display a little pointer arrow
*/
@Prop() readonly arrow?: boolean = false;
b1aserlu marked this conversation as resolved.
Show resolved Hide resolved

constructor() {
// Create local versions of event handlers for de-registration
// https://stackoverflow.com/questions/33859113/javascript-removeeventlistener-not-working-inside-a-class
Expand All @@ -35,6 +40,7 @@ export class PostTooltip {
connectedCallback() {
if (!this.host.id) {
throw new Error(
/*prettier-ignore*/
'No id set: <post-tooltip> must have an id, linking it to it\'s target element using the data-tooltip-target attribute.',
);
}
Expand Down Expand Up @@ -126,7 +132,7 @@ export class PostTooltip {
<post-popovercontainer
role="tooltip"
tabindex="-1"
arrow
arrow={this.arrow}
placement={this.placement}
ref={(el: HTMLPostPopovercontainerElement) => (this.popoverRef = el)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

| Property | Attribute | Description | Type | Default |
| ----------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `arrow` | `arrow` | Wheter or not to display a little pointer arrow | `boolean` | `false` |
| `placement` | `placement` | Defines the placement of the tooltip according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement. Tooltips are automatically flipped to the opposite side if there is not enough available space and are shifted towards the viewport if they would overlap edge boundaries. | `"bottom" \| "bottom-end" \| "bottom-start" \| "left" \| "left-end" \| "left-start" \| "right" \| "right-end" \| "right-start" \| "top" \| "top-end" \| "top-start"` | `'top'` |


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function render(args: Args) {
id="${args.id}"
class="hydrated bg-${args.backgroundColor}"
placement="${ifDefined(args.placement)}"
arrow="${ifDefined(args.arrow)}"
b1aserlu marked this conversation as resolved.
Show resolved Hide resolved
>
${unsafeHTML(innerHTML)}
</post-tooltip>
Expand Down
Loading