Skip to content

Commit

Permalink
fix(ld-sidenav): show secondary icon in tooltip and use theme color o…
Browse files Browse the repository at this point in the history
…n icon
  • Loading branch information
borisdiakur authored and renet committed Apr 12, 2022
1 parent 74ba4ba commit e3153da
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 80 deletions.
13 changes: 13 additions & 0 deletions screenshot/builds/master.json
Original file line number Diff line number Diff line change
Expand Up @@ -8974,6 +8974,19 @@
"isLandscape": false,
"isMobile": false
},
{
"id": "87792f19",
"image": "a1f3e8fa5d5edca1e6011ca3fa6a5048.png",
"userAgent": "default",
"desc": "ld-sidenav with subnavigation shows tooltip with icon",
"testPath": "./src/liquid/components/ld-sidenav/test/ld-sidenav.e2e.ts",
"width": 600,
"height": 600,
"deviceScaleFactor": 1,
"hasTouch": false,
"isLandscape": false,
"isMobile": false
},
{
"id": "497f5f7d",
"image": "73c44880030f2fe1b7bb633a5b3667e5.png",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
--ld-sidenav-navitem-col-focus: var(--ld-thm-primary);
--ld-sidenav-navitem-indicator-col: transparent;
--ld-sidenav-navitem-indicator-col-focus: var(--ld-thm-primary-focus);
--ld-sidenav-navitem-secondary-icon-color: var(--ld-thm-primary);

background-color: transparent;
margin: 0 var(--ld-sidenav-padding-x);
Expand Down Expand Up @@ -340,9 +341,6 @@ That's why we set z-index 0 on the following elements.
border-radius: var(--ld-br-full);
}
}
.ld-sidenav-navitem__tooltip-content {
position: absolute;
}

.ld-sidenav-navitem__slot-container {
-webkit-box-orient: vertical;
Expand Down Expand Up @@ -377,6 +375,7 @@ That's why we set z-index 0 on the following elements.
display: flex;
flex-shrink: 0;
margin-right: var(--ld-sp-4);
color: var(--ld-sidenav-navitem-secondary-icon-color);
}

.ld-sidenav-navitem__abbr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class LdSidenavNavitem implements InnerFocusable {
@State() sidenavClosable: boolean
@State() sidenavCollapsed: boolean
@State() sidenavExpandsOnMouseEnter: boolean
@State() secondaryIconHTML: string

/**
* Sets focus on the anchor or button
Expand Down Expand Up @@ -133,6 +134,12 @@ export class LdSidenavNavitem implements InnerFocusable {
;(this.tooltipRef as unknown as LdTooltip)?.hideTooltip()
}

private updateTooltipIcon = () => {
this.secondaryIconHTML = this.el.querySelector(
'[slot="icon-secondary"]'
)?.outerHTML
}

componentWillLoad() {
this.sidenav = closest('ld-sidenav', this.el)
if (this.sidenav) {
Expand Down Expand Up @@ -210,30 +217,48 @@ export class LdSidenavNavitem implements InnerFocusable {
)}

<ld-tooltip
show-delay="250"
tag="span"
ref={(el) => (this.tooltipRef = el)}
arrow
class="ld-sidenav-navitem__tooltip"
disabled={!this.sidenavCollapsed}
arrow
ref={(el) => (this.tooltipRef = el)}
show-delay="250"
onMouseEnter={this.updateTooltipIcon}
position={
this.sidenavAlignement === 'left' ? 'right middle' : 'left middle'
}
tag="span"
>
<div
class="ld-sidenav-navitem__tooltip-trigger"
slot="trigger"
onClick={this.onClick}
slot="trigger"
/>
<div class="ld-sidenav-navitem__tooltip-content">
<div
style={{
display: 'grid',
gridAutoFlow: 'column',
alignItems: 'center',
}}
>
<ld-typo>{this.tooltipContent}</ld-typo>
{this.secondaryIconHTML && (
<span
style={{
color: 'var(--ld-thm-primary)',
display: 'inline-flex',
marginLeft: 'var(--ld-sp-6)',
}}
class="ld-sidenav-navitem__tooltip-icon"
innerHTML={this.secondaryIconHTML}
/>
)}
</div>
</ld-tooltip>
</div>
<div
ref={(el) => (this.slotContainerRef = el)}
class="ld-sidenav-navitem__slot-container"
part="slot-container"
ref={(el) => (this.slotContainerRef = el)}
>
<slot></slot>
</div>
Expand Down
Loading

0 comments on commit e3153da

Please sign in to comment.