Skip to content

Commit 6af9d70

Browse files
authored
Merge branch 'master' into ddavidkov/treegrid
2 parents 36462ba + 1af651d commit 6af9d70

23 files changed

+1699
-8
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ All notable changes for each version of this project will be documented in this
6161
- **item** of type `IgxListItemComponent`
6262
- **direction** of type `IgxListPanState`
6363
- **keepItem** of type `boolean`
64+
- `igxTooltip` and `igxTooltipTarget` directives:
65+
- Added `IgxTooltipDirective`.
66+
- An element that uses the `igxTooltip` directive is used as a tooltip for a specific target (anchor).
67+
- Extends `IgxToggleDirective`.
68+
- Exported with the name **tooltip**.
69+
- Added `IgxTooltipTargetDirective`.
70+
- An element that uses the `igxTooltipTarget` directive is used as a target (anchor) for a specific tooltip.
71+
- Extends `IgxToggleActionDirective`.
72+
- Exported with the name **tooltipTarget**.
73+
- Both new directives are used in combination to set a tooltip to an element. For more detailed information, see the [README](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/directives/tooltip/README.md).
6474

6575
## 6.1.5
6676
- **General**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
////
2+
/// @group components
3+
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
4+
/// @requires {mixin} bem-block
5+
/// @requires {mixin} bem-elem
6+
/// @requires {mixin} bem-mod
7+
////
8+
9+
@include b(igx-tooltip) {
10+
$this: bem--selector-to-string(&);
11+
@include register-component(str-slice($this, 2, -1));
12+
13+
@extend %tooltip-display !optional;
14+
15+
@include m(desktop) {
16+
@extend %tooltip-display !optional;
17+
@extend %tooltip--desktop !optional;
18+
}
19+
20+
@include m(mobile) {
21+
@extend %tooltip-display !optional;
22+
@extend %tooltip--mobile !optional;
23+
}
24+
25+
@include m(disabled) {
26+
@extend %tooltip--disabled !optional;
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
////
2+
/// @group themes
3+
/// @access public
4+
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
5+
/// @author <a href="https://github.com/desig9stein" target="_blank">Marin Popov</a>
6+
////
7+
8+
/// Returns a map containing all style properties related to the theming the tooltip directive.
9+
/// @param {Map} $palette [$default-palette] - The palette used as basis for styling the component.
10+
/// @param {Color} $background [] - The background color of the tooltip.
11+
/// @param {Color} $text-color [] - The text color of the tooltip.
12+
/// @param {Number} $roundness [] - The border roundness of the tooltip. Smaller values mean less roundness.
13+
/// @param {String} $variant ['dark'] - Determines the default color scheme - could be either 'dark' or 'light'.
14+
/// Set to light when the surrounding area is dark.
15+
///
16+
/// @requires extend
17+
/// @requires igx-color
18+
/// @requires text-contrast
19+
///
20+
/// @example scss Change the checked fill color
21+
/// $my-checkbox-theme: igx-checkbox-theme($fill-color: magenta);
22+
/// // Pass the theme to the igx-checkbox component mixin
23+
/// @include igx-checkbox($my-checkbox-theme);
24+
@function igx-tooltip-theme(
25+
$palette: $default-palette,
26+
$background: null,
27+
$text-color: null,
28+
$roundness: null,
29+
$variant: 'dark'
30+
) {
31+
$name: 'igx-tooltip';
32+
$dark-background: hexrgba(igx-color($palette, 'grays', 700));
33+
$light-background: rgba(#fff, .94);
34+
$border-radius: rem(4px);
35+
36+
$dark-theme: (
37+
background: rgba($dark-background, .9),
38+
text-color: text-contrast($dark-background),
39+
roundness: $border-radius
40+
);
41+
42+
$light-theme: (
43+
background: $light-background,
44+
text-color: text-contrast($light-background),
45+
roundness: $border-radius
46+
);
47+
48+
$default-theme: map-get((
49+
dark: $dark-theme,
50+
light: $light-theme
51+
), $variant);
52+
53+
@if not($text-color) and $background {
54+
$text-color: text-contrast($background);
55+
}
56+
57+
@return extend($default-theme, (
58+
palette: $default-palette,
59+
name: $name,
60+
background: $background,
61+
text-color: $text-color,
62+
roundness: $roundness
63+
));
64+
}
65+
66+
/// @param {Map} $theme - The theme used to style the component.
67+
/// @requires {mixin} igx-root-css-vars
68+
/// @requires --var
69+
@mixin igx-tooltip($theme) {
70+
@include igx-root-css-vars($theme);
71+
72+
%tooltip-display {
73+
display: inline-flex;
74+
justify-content: center;
75+
flex-flow: column wrap;
76+
background-color: --var($theme, 'background');
77+
color: --var($theme, 'text-color');
78+
border-radius: --var($theme, 'roundness');
79+
margin: 0 auto;
80+
}
81+
82+
%tooltip--desktop {
83+
padding: 0 rem(8px);
84+
min-height: rem(24px);
85+
}
86+
87+
%tooltip--mobile {
88+
padding: 0 rem(16px);
89+
min-height: rem(32px);
90+
}
91+
92+
%tooltip--hidden {
93+
display: none;
94+
}
95+
}
96+
97+
/// Adds typography styles for the igx-tooltip component.
98+
/// Uses the 'body-2' category from the typographic scale for mobile tooltips and custom typography for desktop tooltips.
99+
/// @group typography
100+
/// @param {Map} $type-scale - A typographic scale as produced by igx-type-scale.
101+
/// @param {Map} $categories [(text-desktop: null, text-mobile: 'body-2')] - The categories from the typographic scale used for type styles.
102+
/// @requires rem
103+
/// @requires {mixin} igx-type-style
104+
@mixin igx-tooltip-typography(
105+
$type-scale,
106+
$categories: (text-desktop: null, text-mobile: 'body-2')
107+
) {
108+
$text-desktop: map-get($categories, 'text-desktop');
109+
$text-mobile: map-get($categories, 'text-mobile');
110+
111+
%tooltip--mobile {
112+
@include igx-type-style($type-scale, $text-mobile);
113+
}
114+
115+
@if $text-desktop != null {
116+
%tooltip--desktop {
117+
@include igx-type-style($type-scale, $text-desktop);
118+
}
119+
} @else {
120+
%tooltip--desktop {
121+
font-size: rem(10px);
122+
font-weight: 600;
123+
}
124+
}
125+
}

projects/igniteui-angular/src/lib/core/styles/themes/_core.scss

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
@import '../components/switch/switch-component';
5555
@import '../components/tabs/tabs-component';
5656
@import '../components/toast/toast-component';
57+
@import '../components/tooltip/tooltip-component';
5758
@import '../components/time-picker/time-picker-component';
5859

5960
/// Includes the base for each theme.

projects/igniteui-angular/src/lib/core/styles/themes/_index.scss

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
@import '../components/grid-toolbar/grid-toolbar-theme';
3131
@import '../components/overlay/overlay-theme';
3232
@import '../components/toast/toast-theme';
33+
@import '../components/tooltip/tooltip-theme';
3334
@import '../components/tabs/tabs-theme';
3435
@import '../components/switch/switch-theme';
3536
@import '../components/snackbar/snackbar-theme';
@@ -243,6 +244,10 @@
243244
@include igx-toast($theme: igx-toast-theme());
244245
}
245246

247+
@if not(index($exclude, 'igx-tooltip')) {
248+
@include igx-tooltip($theme: igx-tooltip-theme());
249+
}
250+
246251
@if not(index($exclude, 'igx-time-picker')) {
247252
@include igx-time-picker($theme: igx-time-picker-theme());
248253
}

projects/igniteui-angular/src/lib/core/styles/typography/_typography.scss

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@import '../components/tabs/tabs-theme';
2727
@import '../components/time-picker/time-picker-theme';
2828
@import '../components/toast/toast-theme';
29+
@import '../components/tooltip/tooltip-theme';
2930

3031
/// Adds typography styles for h1-h6, paragraph and creates
3132
/// custom typography class selectors. The produces styles
@@ -112,4 +113,5 @@
112113
@include igx-tabs-typography($type-scale);
113114
@include igx-time-picker-typography($type-scale);
114115
@include igx-toast-typography($type-scale);
116+
@include igx-tooltip-typography($type-scale);
115117
}

projects/igniteui-angular/src/lib/directives/toggle/toggle.directive.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
138138
* @hidden
139139
*/
140140
@HostBinding('class.igx-toggle--hidden')
141+
@HostBinding('attr.aria-hidden')
141142
public get hiddenClass() {
142143
return this.collapsed;
143144
}
@@ -260,7 +261,7 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
260261
selector: '[igxToggleAction]'
261262
})
262263
export class IgxToggleActionDirective implements OnInit {
263-
private _overlayDefaults: OverlaySettings;
264+
protected _overlayDefaults: OverlaySettings;
264265

265266
/**
266267
* Provide settings that control the toggle overlay positioning, interaction and scroll behavior.
@@ -335,7 +336,7 @@ export class IgxToggleActionDirective implements OnInit {
335336
return this._target;
336337
}
337338

338-
private _target: IToggleView | string;
339+
protected _target: IToggleView | string;
339340

340341
constructor(private element: ElementRef, @Optional() private navigationService: IgxNavigationService) { }
341342

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Igx-Tooltip
2+
3+
#### Category
4+
_Directives_
5+
6+
## Description
7+
The **IgxTooltip** directive provides us a way to make a given element a tooltip. Then we can assign it to be a tooltip for another element (for example a button) by using the **IgxTooltipTarget** directive.
8+
A walkthrough of how to get started can be found [here](https://www.infragistics.com/products/ignite-ui-angular/angular/components/tooltip.html).
9+
10+
## Usage
11+
First we will have to import the IgxTooltipModule.
12+
```typescript
13+
import { IgxTooltipModule } from "igniteui-angular";
14+
```
15+
16+
- The **IgxTooltip** directive is used to make a given element a tooltip. (exported with the name **tooltip**) This directive extends the **IgxToggle** directive and shares its functionality, since the tooltip is basically a togglable element.
17+
- The **IgxTooltipTarget** directive is used to mark an element as one that has a tooltip. (exported with the name **tooltipTarget**) This directive extends the **IgxToggleAction** directive and shares most of its functionality as well as adding some of its own (for example the hover/unhover behavior which is tooltip specific).
18+
19+
By exporting the IgxTooltip directive and assigning it to the IgxTooltipTarget property, we assign the tooltip to a specific element.
20+
21+
22+
### Simple tooltip
23+
24+
Let's say we have a button and we would like it to have a tooltip that provides some additional text information.
25+
```html
26+
<button [igxTooltipTarget]="tooltipRef">
27+
Hover me
28+
</button>
29+
30+
<div #tooltipRef="tooltip" igxTooltip>
31+
Hello there, this is a tooltip!
32+
</div>
33+
```
34+
35+
### Content rich tooltip
36+
37+
Since the tooltip itself is a simple DOM element, we can inject whatever content we want inside of it and it will be displayed as an ordinary tooltip.
38+
39+
```html
40+
<button [igxTooltipTarget]="tooltipRef">
41+
Hover me
42+
</button>
43+
44+
<div #tooltipRef="tooltip" igxTooltip>
45+
<div>tooltip's header.</div>
46+
<custom-component></custom-component>
47+
<div>tooltip's footer</div>
48+
</div>
49+
```
50+
51+
## Configuration
52+
53+
### Delay settings
54+
The **IgxTooltipTarget** directive exposes `showDelay` and `hideDelay` inputs, which can be used to set the amount of time (in milliseconds) that has to pass before showing and hiding the tooltip respectively.
55+
56+
```html
57+
<button [igxTooltipTarget]="tooltipRef" showDelay="1500" hideDelay="1500">
58+
Hover me
59+
</button>
60+
61+
<div #tooltipRef="tooltip" igxTooltip>
62+
Hello there, this is a tooltip!
63+
</div>
64+
```
65+
66+
### Manually showing and hiding the tooltip
67+
While the tooltip's default behavior is to show when its target is hovered and hide when its target is unhovered, we can also do this manually by using the `showTooltip` and the `hideTooltip` methods of the IgxTooltipTarget directive.
68+
69+
```html
70+
<button (click)="targetBtn.showTooltip()">Show tooltip</button>
71+
<button (click)="targetBtn.hideTooltip()">Hide tooltip</button>
72+
73+
<button #targetBtn="tooltipTarget" [igxTooltipTarget]="tooltipRef">
74+
Hover me
75+
</button>
76+
77+
<div #tooltipRef="tooltip" igxTooltip>
78+
Hello there, this is a tooltip!
79+
</div>
80+
```
81+
82+
## API Summary
83+
84+
## IgxTooltipDirective
85+
86+
### Properties
87+
| Name | Type | Description |
88+
| :--- |:--- | :--- |
89+
| context | any | Specifies the context of the tooltip. (Used to store and access any tooltip related data.) |
90+
91+
Since the **IgxTooltip** directive extends the **IgxToggle** directive and there is no specific functionality it adds apart from some styling classes and attributes in combination with the properties from above, you can refer to the [IgxToggle API](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/directives/toggle/README.md) for additional details.
92+
93+
## IgxTooltipTargetDirective
94+
95+
### Properties
96+
| Name | Type | Description |
97+
| :--- |:--- | :--- |
98+
| showDelay | number | Specifies the amount of milliseconds that should pass before showing the tooltip. |
99+
| hideDelay | number | Specifies the amount of milliseconds that should pass before hiding the tooltip. |
100+
| tooltipDisabled | boolean | Specifies if the tooltip should not show when hovering its target with the mouse. (defaults to false) |
101+
| tooltipHidden | boolean | Indicates if the tooltip is currently hidden. |
102+
| nativeElement | any | Reference to the native element of the directive. |
103+
104+
### Methods
105+
| Name | Type | Arguments | Description |
106+
| :--- |:--- | :--- | :--- |
107+
| showTooltip | void | N/A | Shows the tooltip after the amount of ms specified by the `showDelay` property. |
108+
| hideTooltip | void | N/A | Hides the tooltip after the amount of ms specified by the `hideDelay` property. |
109+
110+
### Events
111+
|Name|Description|Cancelable|Event arguments|
112+
|--|--|--|--|
113+
| onTooltipShow | Emitted when the tooltip starts showing. (This event is fired before the start of the countdown to showing the tooltip.) | True | ITooltipShowEventArgs |
114+
| onTooltipHide | Emitted when the tooltip starts hiding. (This event is fired before the start of the countdown to hiding the tooltip.) | True | ITooltipHideEventArgs |

0 commit comments

Comments
 (0)