-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adapt Floatbar to FloatElement * Implement CSS-Only Tooltip * Extract whitespace wrap into new class * Add overflow to inventory container * Move hintcss and add license * Switch to Directive for Tooltip * chore: prettier formatting * Save parent classes * Rename directive export to tooltip * Add docs for extraClasses * Integrate tooltip in FloatElement * chore: run format
- Loading branch information
Showing
7 changed files
with
537 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import {css, CSSResult} from 'lit'; | ||
import {ChildPart, directive, Directive, DirectiveParameters} from 'lit-html/directive.js'; | ||
import {hintcss} from '../../../../thirdparty/hintcss/hintcss'; | ||
|
||
class TooltipDirective extends Directive { | ||
parentNode: Element | null = null; | ||
label = ''; | ||
// Extra classes to customize the tooltip. See https://kushagra.dev/lab/hint/ for all available classes | ||
extraClasses = ''; | ||
|
||
update(part: ChildPart, [label, extraClasses]: DirectiveParameters<this>) { | ||
this.parentNode = part.parentNode as Element; | ||
this.label = label; | ||
if (extraClasses) { | ||
this.extraClasses = extraClasses; | ||
} | ||
|
||
if (!this.parentNode) { | ||
return; | ||
} | ||
|
||
const newParentClass = `${this.parentNode.getAttribute('class') || ''} hint--top hint--rounded hint--no-arrow ${ | ||
this.extraClasses | ||
}`; | ||
|
||
this.parentNode.setAttribute('class', newParentClass); | ||
this.parentNode.setAttribute('aria-label', this.label); | ||
} | ||
|
||
render(label: string, extraClasses?: string) {} | ||
} | ||
|
||
export const tooltip = directive(TooltipDirective); | ||
|
||
export const tooltipStyles: CSSResult[] = [ | ||
hintcss, | ||
css` | ||
[class*='hint--'][aria-label]:after { | ||
text-shadow: none; | ||
font-family: 'Motiva Sans', Arial, Helvetica, sans-serif; | ||
font-weight: normal; | ||
line-height: normal; | ||
text-align: center; | ||
background: #c2c2c2; | ||
color: #3d3d3f; | ||
font-size: 11px; | ||
border-radius: 3px; | ||
padding: 5px; | ||
} | ||
.hint--whitespace-pre-wrap:after, | ||
.hint--whitespace-pre-wrap:before { | ||
white-space: pre-wrap; | ||
} | ||
`, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Kushagra Gour | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.