Skip to content

Commit

Permalink
feat(tooltip): shadow parts and css variables (#1072)
Browse files Browse the repository at this point in the history
  • Loading branch information
nowseemee authored May 24, 2022
1 parent cf037b3 commit 2232164
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
10 changes: 7 additions & 3 deletions packages/components/src/components/tooltip/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ Type: `Promise<void>`

## Shadow Parts

| Part | Description |
| -------- | ----------- |
| `"base"` | |
| Part | Description |
| ---------------------- | ----------- |
| `"base"` | |
| `"content-wrapper"` | |
| `"host-container"` | |
| `"slot-container"` | |
| `"tooltip-positioner"` | |


----------------------------------------------
Expand Down
10 changes: 7 additions & 3 deletions packages/components/src/components/tooltip/tooltip.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
--transition-timing-function-show: var(--telekom-motion-easing-standard);
--z-index: var(--scl-z-index-70);

/*slot-container */
--width-slot-container: max-content;
--height-slot-container: max-content;

display: contents;
position: relative;
box-sizing: border-box;
Expand All @@ -44,9 +48,9 @@
z-index: var(--z-index);
}

.slot-container {
width: max-content;
height: max-content;
[part='slot-container'] {
width: var(--width-slot-container);
height: var(--height-slot-container);
}

.tooltip {
Expand Down
8 changes: 5 additions & 3 deletions packages/components/src/components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class Tooltip {

getTarget() {
const target = this.host.shadowRoot.querySelector(
'.slot-container'
'[part="slot-container"]'
) as HTMLElement;

if (!target) {
Expand Down Expand Up @@ -239,17 +239,19 @@ export class Tooltip {
return (
<Host
class="host-container"
part="host-container"
onKeyDown={this.handleKeyDown}
onMouseOver={this.handleMouseOver}
onMouseOut={this.handleMouseOut}
>
{this.styles && <style>{this.styles}</style>}
<div class="slot-container">
<div part="slot-container">
<slot onSlotchange={this.handleSlotChange}></slot>
</div>
{!this.disabled && (
<div
class="tooltip-positioner"
part="tooltip-positioner"
ref={(el) => (this.tooltipPositioner = el)}
onMouseOver={this.handleTooltipMouseOver}
>
Expand All @@ -265,7 +267,7 @@ export class Tooltip {
role="tooltip"
aria-hidden={this.open ? 'false' : 'true'}
>
<div class="content-wrapper" tabindex={0}>
<div class="content-wrapper" part="content-wrapper" tabindex={0}>
<slot name="content">{this.content}</slot>
</div>
</div>
Expand Down

0 comments on commit 2232164

Please sign in to comment.