From 4d4049b349ee27377ff68fdeeb64592dec231a24 Mon Sep 17 00:00:00 2001 From: Geoff Pleiss Date: Fri, 24 Oct 2014 15:14:17 -0400 Subject: [PATCH] feat(tooltip): add tooltip component BREAKING CHANGE: (css class) `.with-tooltip` is now `.button-with-tooltip-wrapper` BREAKING CHANGE: (javascript) tooltips must be explicitly initialized [Finishes #80077170] Signed-off-by: Bebe Peng --- src/pivotal-ui/components/tooltips.scss | 68 ++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/src/pivotal-ui/components/tooltips.scss b/src/pivotal-ui/components/tooltips.scss index a505b16d4..73cd3938e 100644 --- a/src/pivotal-ui/components/tooltips.scss +++ b/src/pivotal-ui/components/tooltips.scss @@ -1,4 +1,4 @@ -/*pending +/*doc --- title: Tooltip name: tooltip @@ -7,15 +7,69 @@ categories: - JavaScript --- -Tooltip styles can be applied to any element. We often apply them to disabled -buttons which require a wrapper div as the hover event will not fire. +Tooltips are used to display extra information on hover. They can be used with any hoverable element. -```haml_example -.with-tooltip{data: {title: "This is your tooltip"}} - %button.btn.btn-primary{disabled: true} Button +The `title` attribute defines the text that appears on the tooltip. +The `data-placement` attribute defines the tooltip's placement. +If `data-placement` is not specified, the tooltip is placed on top by default. + +
+ Tooltips must be initialized with javascript: $(mySelector).tooltip(); +
+ +```html_example +

+ Check out this + + tooltip on the left! + +

+ +

+ Check out this + + tooltip on the right! + +

+ +

+ +

+ +

+ +

+``` + +```js_example +$('#link-with-tooltip-1').tooltip(); +$('#link-with-tooltip-2').tooltip(); +$('#button-with-tooltip-1').tooltip(); +$('#button-with-tooltip-2').tooltip(); ``` + +
+ If you want to use a tooltip on a disabled element, place the tooltip in a wrapper div with the class .button-with-tooltip-wrapper. +
+ +```html_example +
+ +
+``` + +```js_example +$('#disabled-button-with-tooltip').tooltip(); +``` + */ -.with-tooltip { +.button-with-tooltip-wrapper { display: inline-block; }