11import { storiesOf , moduleMetadata } from "@storybook/angular" ;
22import { withNotes } from "@storybook/addon-notes" ;
33import { action } from "@storybook/addon-actions" ;
4- import { withKnobs , boolean , object } from "@storybook/addon-knobs/angular" ;
4+ import { withKnobs , text , select } from "@storybook/addon-knobs/angular" ;
55
66import { DialogModule , PlaceholderModule } from "../../" ;
77
@@ -15,35 +15,121 @@ storiesOf("Tooltip", module)
1515 )
1616 . addDecorator ( withKnobs )
1717 . add ( "Basic" , ( ) => ( {
18- template : `
19- <div>
20- <span
21- ibmTooltip="tooltip text"
22- trigger="hover"
23- placement="bottom"
24- style="cursor: pointer;">
25- Hover for tooltip
26- </span>
27- </div>
28- `
29- } ) )
30- . add ( "With Template" , ( ) => ( {
3118 template : `
3219 <div>
3320 <ng-template #template let-tooltip="tooltip">
34- <p>hello</p>
35- <div>
21+ <p>This is some tooltip text. This box shows the maximum amount of text that should appear inside.
22+ If more room is needed please use a modal instead.</p>
23+ <div class="bx--tooltip__footer">
24+ <a href="/" class="bx--link">Learn More</a>
3625 <button class="bx--btn bx--btn--primary" (click)="tooltip.doClose()">Close</button>
3726 </div>
3827 </ng-template>
39- <span
40- [ibmTooltip]="template"
41- trigger="click"
42- placement="bottom"
43- style="cursor: pointer;">
44- Click for tooltip
45- </span>
28+
29+ <div class="bx--tooltip__label">
30+ {{triggerText}}
31+ <span
32+ [ibmTooltip]="template"
33+ trigger="click"
34+ [placement]="placement">
35+ <div role="button">
36+ <svg style="vertical-align: middle;" fill-rule="evenodd" height="16" role="img" viewBox="0 0 16 16" width="16" aria-label="tooltip">
37+ <path d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 4c.6 0 1 .4 1 1s-.4 1-1 1-1-.4-1-1
38+ .4-1 1-1zm2 8H6v-1h1V8H6V7h3v4h1v1z"></path>
39+ </svg>
40+ </div>
41+ </span>
42+ </div>
4643 <ibm-placeholder></ibm-placeholder>
4744 </div>
48- `
45+ ` ,
46+ props : {
47+ placement : select ( "Tooltip direction" , [ "bottom" , "top" , "left" , "right" ] , "bottom" ) ,
48+ triggerText : text ( "Trigger text" , "Tooltip label" )
49+ }
50+ } ) )
51+ . add ( "no icon" , ( ) => ( {
52+ template : `
53+ <div>
54+ <ng-template #template let-tooltip="tooltip">
55+ <p>This is some tooltip text. This box shows the maximum amount of text that should appear inside.
56+ If more room is needed please use a modal instead.</p>
57+ <div class="bx--tooltip__footer">
58+ <a href="/" class="bx--link">Learn More</a>
59+ <button class="bx--btn bx--btn--primary" (click)="tooltip.doClose()">Close</button>
60+ </div>
61+ </ng-template>
62+
63+ <span
64+ [ibmTooltip]="template"
65+ trigger="click"
66+ [placement]="placement">
67+ {{triggerText}}
68+ </span>
69+ <ibm-placeholder></ibm-placeholder>
70+ </div>
71+ ` ,
72+ props : {
73+ placement : select ( "Tooltip direction" , [ "bottom" , "top" , "left" , "right" ] , "bottom" ) ,
74+ triggerText : text ( "Trigger text" , "Tooltip label" )
75+ }
76+ } ) )
77+ . add ( "only icon" , ( ) => ( {
78+ template : `
79+ <div>
80+ <ng-template #template let-tooltip="tooltip">
81+ <p>This is some tooltip text. This box shows the maximum amount of text that should appear inside.
82+ If more room is needed please use a modal instead.</p>
83+ <div class="bx--tooltip__footer">
84+ <a href="/" class="bx--link">Learn More</a>
85+ <button class="bx--btn bx--btn--primary" (click)="tooltip.doClose()">Close</button>
86+ </div>
87+ </ng-template>
88+
89+ <span
90+ [ibmTooltip]="template"
91+ trigger="click"
92+ [placement]="placement">
93+ <div role="button" class="bx--tooltip__trigger">
94+ <svg focusable="false" aria-label="tooltip" width="16" height="16" viewBox="0 0 16 16" role="img" style="will-change: transform;">
95+ <circle cx="8" cy="3" r="1"></circle><circle cx="8" cy="8" r="1"></circle><circle cx="8" cy="13" r="1"></circle>
96+ </svg>
97+ </div>
98+ </span>
99+ <ibm-placeholder></ibm-placeholder>
100+ </div>
101+ ` ,
102+ props : {
103+ placement : select ( "Tooltip direction" , [ "bottom" , "top" , "left" , "right" ] , "bottom" )
104+ }
105+ } ) )
106+ . add ( "Icon tooltip" , ( ) => ( {
107+ template : `
108+ <ibm-tooltip-icon [placement]="placement" [content]="content">
109+ <svg width="16" height="12" viewBox="0 0 16 12">
110+ <g fill-rule="nonzero">
111+ <path d="M8.05 2a2.5 2.5 0 0 1 4.9 0H16v1h-3.05a2.5 2.5 0 0 1-4.9 0H0V2h8.05zm2.45 2a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zM3.05
112+ 9a2.5 2.5 0 0 1 4.9 0H16v1H7.95a2.5 2.5 0 0 1-4.9 0H0V9h3.05zm2.45 2a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"></path>
113+ </g>
114+ </svg>
115+ </ibm-tooltip-icon>
116+ ` ,
117+ props : {
118+ placement : select ( "Tooltip direction" , [ "bottom" , "top" ] , "bottom" ) ,
119+ content : text ( "Tooltip content" , "Filter" )
120+ }
121+ } ) )
122+ . add ( "Definition tooltip" , ( ) => ( {
123+ template : `
124+ <ibm-tooltip-definition
125+ [content]="content"
126+ [placement]="placement">
127+ {{triggerText}}
128+ </ibm-tooltip-definition>
129+ ` ,
130+ props : {
131+ placement : select ( "Tooltip direction" , [ "bottom" , "top" ] , "bottom" ) ,
132+ triggerText : text ( "Tooltip text" , "Definition Tooltip" ) ,
133+ content : text ( "Tooltip content" , "Brief description of the dotted, underlined word above." )
134+ }
49135 } ) ) ;
0 commit comments