-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤝 Add TooltipLabelProvider module for building tooltip texts using va…
…rious inputs
- Loading branch information
1 parent
425cec2
commit cbf5c31
Showing
5 changed files
with
64 additions
and
21 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,43 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const tooltipL10n = new Localization(["dot/tooltips.ftl"], true); | ||
|
||
export const TooltipLabelProvider = { | ||
/** | ||
* Constructs the tooltip text using the supplied values | ||
* @param {string} label | ||
* @param {object} [options] | ||
* @param {string} [options.sublabel] | ||
* @param {string} [options.shortcut] | ||
*/ | ||
getTooltipText(label, options) { | ||
let tooltipText = []; | ||
|
||
if (options && options.shortcut) { | ||
tooltipText.push( | ||
tooltipL10n.formatValueSync("tooltip-shortcut-label", { | ||
label, | ||
shortcut: options.shortcut | ||
}) | ||
); | ||
} else { | ||
tooltipText.push( | ||
tooltipL10n.formatValueSync("tooltip-label", { | ||
label | ||
}) | ||
); | ||
} | ||
|
||
if (options && options.sublabel) { | ||
tooltipText.push( | ||
tooltipL10n.formatValueSync("tooltip-label", { | ||
label: options.sublabel | ||
}) | ||
); | ||
} | ||
|
||
return tooltipText.join("\n"); | ||
} | ||
}; |
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,11 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
tooltip-label = { $label } | ||
tooltip-shortcut-label = | ||
{ PLATFORM() -> | ||
[macos] { $label } { $shortcut } | ||
*[other] { $label } ({ $shortcut }) | ||
} |