-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: create tooltip component (#11363)
- Loading branch information
Showing
8 changed files
with
47 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Component from '@glimmer/component'; | ||
|
||
export default class Tooltip extends Component { | ||
get text() { | ||
const inputText = this.args.text; | ||
if (!inputText || inputText.length < 30) { | ||
return inputText; | ||
} | ||
|
||
const prefix = inputText.substr(0, 15).trim(); | ||
const suffix = inputText.substr(inputText.length - 10, inputText.length).trim(); | ||
return `${prefix}...${suffix}`; | ||
} | ||
} |
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,3 @@ | ||
<span class="tooltip" aria-label="{{this.text}}"> | ||
{{yield}} | ||
</span> |
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,13 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import setupGlimmerComponentFactory from 'nomad-ui/tests/helpers/glimmer-factory'; | ||
|
||
module('Unit | Component | tooltip', function(hooks) { | ||
setupTest(hooks); | ||
setupGlimmerComponentFactory(hooks, 'tooltip'); | ||
|
||
test('long texts are ellipsised in the middle', function(assert) { | ||
const tooltip = this.createComponent({ text: 'reeeeeeeeeeeeeeeeeally long text' }); | ||
assert.equal(tooltip.text, 'reeeeeeeeeeeeee...long text'); | ||
}); | ||
}); |