@alegendstale/holly-components 1.4.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +9 -5
  2. package/dist/components/absolute-container/absolute-container.d.ts +17 -3
  3. package/dist/components/absolute-container/absolute-container.d.ts.map +1 -1
  4. package/dist/components/absolute-container/absolute-container.js +22 -25
  5. package/dist/components/absolute-container/absolute-container.stories.d.ts +3 -1
  6. package/dist/components/absolute-container/absolute-container.stories.d.ts.map +1 -1
  7. package/dist/components/absolute-container/absolute-container.stories.js +35 -7
  8. package/dist/components/absolute-container/absolute-container.styles.d.ts +3 -0
  9. package/dist/components/absolute-container/absolute-container.styles.d.ts.map +1 -0
  10. package/dist/components/absolute-container/absolute-container.styles.js +18 -0
  11. package/dist/components/bottom-sheet/bottom-sheet.d.ts +25 -0
  12. package/dist/components/bottom-sheet/bottom-sheet.d.ts.map +1 -1
  13. package/dist/components/bottom-sheet/bottom-sheet.js +29 -127
  14. package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts +5 -2
  15. package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts.map +1 -1
  16. package/dist/components/bottom-sheet/bottom-sheet.stories.js +31 -7
  17. package/dist/components/bottom-sheet/bottom-sheet.styles.d.ts +3 -0
  18. package/dist/components/bottom-sheet/bottom-sheet.styles.d.ts.map +1 -0
  19. package/dist/components/bottom-sheet/bottom-sheet.styles.js +115 -0
  20. package/dist/components/canvas/canvas-base.d.ts +8 -1
  21. package/dist/components/canvas/canvas-base.d.ts.map +1 -1
  22. package/dist/components/canvas/canvas-base.js +14 -11
  23. package/dist/components/canvas/canvas-base.stories.d.ts +7 -0
  24. package/dist/components/canvas/canvas-base.stories.d.ts.map +1 -0
  25. package/dist/components/canvas/canvas-base.stories.js +24 -0
  26. package/dist/components/canvas/canvas-gradient.d.ts +10 -3
  27. package/dist/components/canvas/canvas-gradient.d.ts.map +1 -1
  28. package/dist/components/canvas/canvas-gradient.js +13 -9
  29. package/dist/components/canvas/canvas-gradient.stories.d.ts +14 -0
  30. package/dist/components/canvas/canvas-gradient.stories.d.ts.map +1 -0
  31. package/dist/components/canvas/canvas-gradient.stories.js +46 -0
  32. package/dist/components/canvas/canvas-image.d.ts +25 -16
  33. package/dist/components/canvas/canvas-image.d.ts.map +1 -1
  34. package/dist/components/canvas/canvas-image.js +84 -72
  35. package/dist/components/canvas/canvas-image.stories.d.ts +13 -0
  36. package/dist/components/canvas/canvas-image.stories.d.ts.map +1 -0
  37. package/dist/components/canvas/canvas-image.stories.js +49 -0
  38. package/dist/components/canvas/canvas-image.styles.d.ts +3 -0
  39. package/dist/components/canvas/canvas-image.styles.d.ts.map +1 -0
  40. package/dist/components/canvas/canvas-image.styles.js +21 -0
  41. package/dist/components/carousel-scroller/carousel-scroller.d.ts +23 -6
  42. package/dist/components/carousel-scroller/carousel-scroller.d.ts.map +1 -1
  43. package/dist/components/carousel-scroller/carousel-scroller.js +32 -80
  44. package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts +4 -2
  45. package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts.map +1 -1
  46. package/dist/components/carousel-scroller/carousel-scroller.stories.js +22 -6
  47. package/dist/components/carousel-scroller/carousel-scroller.styles.d.ts +3 -0
  48. package/dist/components/carousel-scroller/carousel-scroller.styles.d.ts.map +1 -0
  49. package/dist/components/carousel-scroller/carousel-scroller.styles.js +66 -0
  50. package/dist/components/color-palette/color-palette-utils.d.ts.map +1 -1
  51. package/dist/components/color-palette/color-palette.d.ts +53 -16
  52. package/dist/components/color-palette/color-palette.d.ts.map +1 -1
  53. package/dist/components/color-palette/color-palette.js +72 -126
  54. package/dist/components/color-palette/color-palette.styles.d.ts +3 -0
  55. package/dist/components/color-palette/color-palette.styles.d.ts.map +1 -0
  56. package/dist/components/color-palette/color-palette.styles.js +90 -0
  57. package/dist/components/color-palette/component/color-palette-component.d.ts +16 -2
  58. package/dist/components/color-palette/component/color-palette-component.d.ts.map +1 -1
  59. package/dist/components/color-palette/component/color-palette-component.js +18 -19
  60. package/dist/components/color-palette/component/color-palette-component.stories.d.ts +4 -2
  61. package/dist/components/color-palette/component/color-palette-component.stories.d.ts.map +1 -1
  62. package/dist/components/color-palette/component/color-palette-component.stories.js +34 -36
  63. package/dist/components/color-palette/component/color-palette-component.styles.d.ts +3 -0
  64. package/dist/components/color-palette/component/color-palette-component.styles.d.ts.map +1 -0
  65. package/dist/components/color-palette/component/color-palette-component.styles.js +10 -0
  66. package/dist/components/color-palette/editor/color-palette-editor.d.ts +28 -14
  67. package/dist/components/color-palette/editor/color-palette-editor.d.ts.map +1 -1
  68. package/dist/components/color-palette/editor/color-palette-editor.js +30 -216
  69. package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts +9 -2
  70. package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts.map +1 -1
  71. package/dist/components/color-palette/editor/color-palette-editor.stories.js +32 -4
  72. package/dist/components/color-palette/editor/color-palette-editor.styles.d.ts +3 -0
  73. package/dist/components/color-palette/editor/color-palette-editor.styles.d.ts.map +1 -0
  74. package/dist/components/color-palette/editor/color-palette-editor.styles.js +147 -0
  75. package/dist/components/color-palette/editor/settings-item.d.ts +20 -0
  76. package/dist/components/color-palette/editor/settings-item.d.ts.map +1 -0
  77. package/dist/components/color-palette/editor/settings-item.js +43 -0
  78. package/dist/components/color-palette/editor/settings-item.styles.d.ts +3 -0
  79. package/dist/components/color-palette/editor/settings-item.styles.d.ts.map +1 -0
  80. package/dist/components/color-palette/editor/settings-item.styles.js +34 -0
  81. package/dist/components/color-palette/item/color-palette-item-edit.d.ts +9 -2
  82. package/dist/components/color-palette/item/color-palette-item-edit.d.ts.map +1 -1
  83. package/dist/components/color-palette/item/color-palette-item-edit.js +12 -57
  84. package/dist/components/color-palette/item/color-palette-item-edit.styles.d.ts +3 -0
  85. package/dist/components/color-palette/item/color-palette-item-edit.styles.d.ts.map +1 -0
  86. package/dist/components/color-palette/item/color-palette-item-edit.styles.js +51 -0
  87. package/dist/components/color-palette/item/color-palette-item.d.ts +21 -2
  88. package/dist/components/color-palette/item/color-palette-item.d.ts.map +1 -1
  89. package/dist/components/color-palette/item/color-palette-item.js +23 -89
  90. package/dist/components/color-palette/item/color-palette-item.styles.d.ts +3 -0
  91. package/dist/components/color-palette/item/color-palette-item.styles.d.ts.map +1 -0
  92. package/dist/components/color-palette/item/color-palette-item.styles.js +83 -0
  93. package/dist/components/color-palette/menu/color-palette-menu.d.ts +15 -3
  94. package/dist/components/color-palette/menu/color-palette-menu.d.ts.map +1 -1
  95. package/dist/components/color-palette/menu/color-palette-menu.js +15 -54
  96. package/dist/components/color-palette/menu/color-palette-menu.styles.d.ts +3 -0
  97. package/dist/components/color-palette/menu/color-palette-menu.styles.d.ts.map +1 -0
  98. package/dist/components/color-palette/menu/color-palette-menu.styles.js +49 -0
  99. package/dist/components/color-palette/menu/color-palette-reorder.d.ts +8 -1
  100. package/dist/components/color-palette/menu/color-palette-reorder.d.ts.map +1 -1
  101. package/dist/components/color-palette/menu/color-palette-reorder.js +11 -36
  102. package/dist/components/color-palette/menu/color-palette-reorder.styles.d.ts +3 -0
  103. package/dist/components/color-palette/menu/color-palette-reorder.styles.d.ts.map +1 -0
  104. package/dist/components/color-palette/menu/color-palette-reorder.styles.js +31 -0
  105. package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts +26 -8
  106. package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts.map +1 -1
  107. package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +10 -39
  108. package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts +26 -8
  109. package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts.map +1 -1
  110. package/dist/components/color-palette/storybook/color-palette-valid.stories.js +30 -58
  111. package/dist/components/color-palette/storybook/color-palette.stories.d.ts +18 -4
  112. package/dist/components/color-palette/storybook/color-palette.stories.d.ts.map +1 -1
  113. package/dist/components/color-palette/storybook/color-palette.stories.js +65 -14
  114. package/dist/components/draw-svg/draw-svg.d.ts +11 -0
  115. package/dist/components/draw-svg/draw-svg.d.ts.map +1 -1
  116. package/dist/components/draw-svg/draw-svg.js +15 -45
  117. package/dist/components/draw-svg/draw-svg.stories.d.ts +2 -14
  118. package/dist/components/draw-svg/draw-svg.stories.d.ts.map +1 -1
  119. package/dist/components/draw-svg/draw-svg.stories.js +21 -97
  120. package/dist/components/draw-svg/draw-svg.styles.d.ts +3 -0
  121. package/dist/components/draw-svg/draw-svg.styles.d.ts.map +1 -0
  122. package/dist/components/draw-svg/draw-svg.styles.js +39 -0
  123. package/dist/components/responsive-svg/responsive-svg.d.ts +35 -15
  124. package/dist/components/responsive-svg/responsive-svg.d.ts.map +1 -1
  125. package/dist/components/responsive-svg/responsive-svg.js +59 -97
  126. package/dist/components/responsive-svg/responsive-svg.stories.d.ts +5 -4
  127. package/dist/components/responsive-svg/responsive-svg.stories.d.ts.map +1 -1
  128. package/dist/components/responsive-svg/responsive-svg.stories.js +93 -109
  129. package/dist/components/responsive-svg/responsive-svg.styles.d.ts +3 -0
  130. package/dist/components/responsive-svg/responsive-svg.styles.d.ts.map +1 -0
  131. package/dist/components/responsive-svg/responsive-svg.styles.js +46 -0
  132. package/dist/components/tool-tip/tool-tip.d.ts +24 -9
  133. package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
  134. package/dist/components/tool-tip/tool-tip.js +49 -90
  135. package/dist/components/tool-tip/tool-tip.stories.d.ts +4 -1
  136. package/dist/components/tool-tip/tool-tip.stories.d.ts.map +1 -1
  137. package/dist/components/tool-tip/tool-tip.stories.js +35 -5
  138. package/dist/components/tool-tip/tool-tip.styles.d.ts +3 -0
  139. package/dist/components/tool-tip/tool-tip.styles.d.ts.map +1 -0
  140. package/dist/components/tool-tip/tool-tip.styles.js +58 -0
  141. package/package.json +23 -19
  142. package/dist/components/bottom-sheet/bottom-sheet.test.d.ts +0 -2
  143. package/dist/components/bottom-sheet/bottom-sheet.test.d.ts.map +0 -1
  144. package/dist/components/bottom-sheet/bottom-sheet.test.js +0 -15
  145. package/dist/components/tool-tip/Tooltip2.d.ts +0 -17
  146. package/dist/components/tool-tip/Tooltip2.d.ts.map +0 -1
  147. package/dist/components/tool-tip/Tooltip2.js +0 -104
@@ -5,111 +5,90 @@ import ServicesBottomRaw from '../../assets/services-bottom.svg?raw';
5
5
  import GotLeakz from '../../assets/GotLeakz.svg?raw';
6
6
  import ComicBackground from '../../assets/comic-background.svg?raw';
7
7
  import { preserveAspectRatioOptions } from './responsive-svg.js';
8
- const meta = {
9
- title: 'Responsive SVG',
10
- tags: ['autodocs'],
11
- component: 'responsive-svg',
12
- argTypes: {
13
- fontSize: {
14
- control: {
15
- type: 'number',
16
- step: 8
17
- },
18
- description: 'Set the font size in pixels the SVG will scale to (provided autofit is not being used)',
19
- table: {
20
- defaultValue: { summary: '128' }
21
- }
8
+ import { expect } from 'storybook/test';
9
+ const argTypes = {
10
+ fontSize: {
11
+ control: {
12
+ type: 'number',
13
+ step: 8,
22
14
  },
23
- stroke: {
24
- control: {
25
- type: 'color',
26
- presetColors: [
27
- 'rebeccapurple', 'black'
28
- ]
29
- },
30
- description: 'Set the Path stroke color',
31
- table: {
32
- defaultValue: { summary: 'rebeccapurple' }
33
- }
15
+ description: 'Set the font size in pixels the SVG will scale to (provided autofit is not being used)',
16
+ table: {
17
+ defaultValue: { summary: '128' },
34
18
  },
35
- fill: {
36
- control: {
37
- type: 'color',
38
- presetColors: [
39
- 'rebeccapurple', 'black'
40
- ]
41
- },
42
- description: 'Set the SVG and Path fill color',
43
- table: {
44
- defaultValue: { summary: 'black' }
45
- }
19
+ },
20
+ stroke: {
21
+ control: {
22
+ type: 'color',
23
+ presetColors: ['rebeccapurple', 'black'],
46
24
  },
47
- autofit: {
48
- control: {
49
- type: 'boolean'
50
- },
51
- description: 'Set whether the SVG will fill the container or available space',
52
- table: {
53
- defaultValue: { summary: 'false' }
54
- },
25
+ description: 'Set the Path stroke color',
26
+ table: {
27
+ defaultValue: { summary: 'rebeccapurple' },
55
28
  },
56
- svgColors: {
57
- control: {
58
- type: 'boolean',
59
- },
60
- description: 'Uses the colors from the SVG input',
61
- table: {
62
- defaultValue: { summary: 'false' }
63
- }
29
+ },
30
+ fill: {
31
+ control: {
32
+ type: 'color',
33
+ presetColors: ['rebeccapurple', 'black'],
64
34
  },
65
- height: {
66
- control: {
67
- type: 'number',
68
- },
69
- description: 'Set the SVG height',
70
- table: {
71
- defaultValue: { summary: '0' }
72
- }
35
+ description: 'Set the SVG and Path fill color',
36
+ table: {
37
+ defaultValue: { summary: 'black' },
73
38
  },
74
- width: {
75
- control: {
76
- type: 'number',
77
- },
78
- description: 'Set the SVG width',
79
- table: {
80
- defaultValue: { summary: '0' }
81
- }
39
+ },
40
+ autofit: { control: 'boolean' },
41
+ svgColors: { control: 'boolean' },
42
+ preserveAspectRatio: {
43
+ control: 'select',
44
+ options: preserveAspectRatioOptions,
45
+ },
46
+ viewBox: { control: false },
47
+ '--svg-height': {
48
+ control: 'text',
49
+ table: {
50
+ defaultValue: { summary: '0em' },
82
51
  },
83
- svg: {
84
- control: {
85
- type: 'text',
86
- },
87
- description: 'Input a string representing an SVG'
52
+ },
53
+ '--svg-width': {
54
+ control: 'text',
55
+ table: {
56
+ defaultValue: { summary: '0em' },
88
57
  },
89
- preserveAspectRatio: {
90
- control: 'select',
91
- options: preserveAspectRatioOptions,
92
- description: 'Set whether SVG preserves its aspect ratio alignment or spacing',
93
- table: {
94
- defaultValue: { summary: 'xMidYMid meet' }
95
- }
58
+ },
59
+ '--scale': {
60
+ control: 'number',
61
+ description: 'Scale of the SVG',
62
+ table: {
63
+ defaultValue: { summary: '1' },
96
64
  },
97
- }
65
+ },
66
+ '--svg-height-fallback': { control: false },
67
+ '--svg-width-fallback': { control: false },
68
+ __svg: { control: false },
69
+ __path: { control: false },
70
+ };
71
+ const meta = {
72
+ title: 'SVG/Responsive SVG',
73
+ tags: ['autodocs'],
74
+ component: 'responsive-svg',
75
+ argTypes,
98
76
  };
99
77
  export default meta;
100
- const Template = {
101
- render: ({ fontSize, stroke, fill, autofit, svgColors, height, width, svg, preserveAspectRatio }) => {
78
+ const template = {
79
+ render: ({ fontSize, stroke, fill, autofit, svgColors, svg, preserveAspectRatio, "--svg-height": height = '0em', "--svg-width": width = '0em', "--scale": scale }) => {
102
80
  const styles = {
103
81
  'font-size': `${fontSize}px`,
104
82
  stroke,
105
- fill
83
+ fill,
84
+ '--svg-height': height !== '0em' ? height : null,
85
+ '--svg-width': width !== '0em' ? width : null,
86
+ '--scale': scale
106
87
  };
107
88
  return html `
108
89
  <responsive-svg
109
90
  ?autofit=${autofit}
110
91
  ?svgColors=${svgColors}
111
- height=${height}
112
- width=${width}
113
92
  .preserveAspectRatio=${preserveAspectRatio}
114
93
  .svg=${svg}
115
94
  style=${styleMap(styles)}
@@ -119,91 +98,96 @@ const Template = {
119
98
  },
120
99
  };
121
100
  export const SVG = {
122
- ...Template,
101
+ ...template,
123
102
  args: {
124
103
  fontSize: 128,
125
104
  stroke: 'rebeccapurple',
126
105
  fill: 'black',
127
106
  autofit: false,
128
107
  svgColors: false,
129
- height: 0,
130
- width: 0,
131
- svg: ResponsiveSVGRaw
108
+ svg: ResponsiveSVGRaw,
109
+ "--scale": 1
132
110
  },
133
111
  };
134
112
  export const TemplateResult2 = {
135
- ...Template,
113
+ ...template,
136
114
  args: {
137
115
  fontSize: 128,
138
116
  stroke: 'rebeccapurple',
139
117
  fill: 'black',
140
118
  autofit: false,
141
119
  svgColors: false,
142
- height: 128,
143
- width: 128,
144
- svg: svg `<path part="path" d="M 30 50 h 60 a 1 1 0 0 1 0 20 h -60 a 1 1 0 0 1 0 -40 h 30 v 70"/>`
120
+ svg: svg `<path d="M 30 50 h 60 a 1 1 0 0 1 0 20 h -60 a 1 1 0 0 1 0 -40 h 30 v 70"/>`,
121
+ "--svg-height": '120em',
122
+ "--svg-width": '120em'
145
123
  }
146
124
  };
147
125
  export const ServicesBottom = {
148
- ...Template,
126
+ ...template,
149
127
  args: {
150
128
  fontSize: 128,
151
129
  stroke: 'rebeccapurple',
152
130
  fill: 'black',
153
131
  autofit: false,
154
132
  svgColors: false,
155
- height: 128,
156
- width: 128,
157
133
  svg: ServicesBottomRaw
158
134
  }
159
135
  };
160
136
  export const EmptyString = {
161
- ...Template,
137
+ ...template,
162
138
  args: {
163
139
  fontSize: 128,
164
140
  stroke: 'rebeccapurple',
165
141
  fill: 'black',
166
142
  autofit: false,
167
143
  svgColors: false,
168
- height: 0,
169
- width: 0,
170
144
  svg: ''
171
145
  },
146
+ play: async ({ canvasElement }) => {
147
+ const component = canvasElement.querySelector('responsive-svg');
148
+ const svgElement = component?.querySelector('svg');
149
+ // Check if element exists
150
+ await expect(component).not.toBeNull();
151
+ // Make sure element didn't render an SVG
152
+ await expect(svgElement).toBeNull();
153
+ }
172
154
  };
173
155
  export const Invalid = {
174
- ...Template,
156
+ ...template,
175
157
  args: {
176
158
  fontSize: 128,
177
159
  stroke: 'rebeccapurple',
178
160
  fill: 'black',
179
161
  autofit: false,
180
162
  svgColors: false,
181
- height: 0,
182
- width: 0,
183
163
  svg: 'test'
184
164
  },
165
+ play: async ({ canvasElement }) => {
166
+ const component = canvasElement.querySelector('responsive-svg');
167
+ const svgElement = component?.querySelector('svg');
168
+ // Check if element exists
169
+ await expect(component).not.toBeNull();
170
+ // Make sure element didn't render an SVG
171
+ await expect(svgElement).toBeNull();
172
+ }
185
173
  };
186
174
  export const SVGWithoutViewBox = {
187
- ...Template,
175
+ ...template,
188
176
  args: {
189
177
  fontSize: 128,
190
178
  stroke: 'rebeccapurple',
191
179
  fill: 'black',
192
180
  autofit: false,
193
181
  svgColors: false,
194
- height: 0,
195
- width: 0,
196
182
  svg: GotLeakz
197
183
  },
198
184
  };
199
185
  export const SVGWithoutWidthHeight = {
200
- ...Template,
186
+ ...template,
201
187
  args: {
202
188
  fontSize: 128,
203
189
  autofit: false,
204
190
  svgColors: true,
205
- height: 0,
206
- width: 0,
207
191
  svg: ComicBackground,
208
192
  preserveAspectRatio: 'none'
209
193
  },
@@ -0,0 +1,3 @@
1
+ declare const _default: import("lit").CSSResult;
2
+ export default _default;
3
+ //# sourceMappingURL=responsive-svg.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responsive-svg.styles.d.ts","sourceRoot":"","sources":["../../../src/components/responsive-svg/responsive-svg.styles.ts"],"names":[],"mappings":";AAEA,wBA4CE"}
@@ -0,0 +1,46 @@
1
+ import { css } from 'lit';
2
+ export default css `
3
+ :host {
4
+ display: block;
5
+ --scale: 1;
6
+ }
7
+
8
+ :host([autofit]),
9
+ :host([autofit]) svg {
10
+ width: 100%;
11
+ height: 100%;
12
+ }
13
+
14
+ /* Size scaling based on font-size */
15
+ :host(:not([autofit])) {
16
+ /* Removes extra space from under SVG */
17
+ display: flex;
18
+ }
19
+
20
+ :host(:not([autofit])) svg {
21
+ /* Allow SVG to be manipulated by font size */
22
+ display: inline-block;
23
+ /* Change SVG size using font-size */
24
+ font-size: inherit;
25
+ /* Remove extra vertical space in inline element reserved for character descenders */
26
+ vertical-align: top;
27
+
28
+ width: calc(var(--svg-width, var(--svg-width-fallback)) / 100 * var(--scale));
29
+ height: calc(var(--svg-height, var(--svg-height-fallback)) / 100 * var(--scale));
30
+ }
31
+
32
+ :host(:not([svgColors])) svg {
33
+ /* Inherit fill to bypass default */
34
+ fill: inherit;
35
+ }
36
+
37
+ :host(:not([svgColors])) path {
38
+ fill: inherit;
39
+ stroke: inherit;
40
+ }
41
+
42
+ svg {
43
+ max-width: 100%;
44
+ max-height: 100%;
45
+ }
46
+ `;
@@ -1,27 +1,42 @@
1
1
  import { LitElement } from "lit";
2
2
  import { client } from "../../utils/types.js";
3
- export type TriggerTypes = 'hover' | 'click' | 'manual';
4
- export declare const styles: import("lit").CSSResult;
3
+ export declare const triggerTypes: readonly ["hover", "click", "manual"];
4
+ export type TriggerTypes = typeof triggerTypes[number];
5
+ /**
6
+ * A tooltip that can display information on hover or click
7
+ *
8
+ * @cssprop {<length>} --tooltip-x - The x position of the tooltip.
9
+ * @cssprop {<length>} --tooltip-y - The y position of the tooltip.
10
+ */
5
11
  export declare class ToolTip extends LitElement {
6
- static styles: import("lit").CSSResult;
7
- private _trigger;
12
+ static styles: import("lit").CSSResult[];
13
+ /** @internal */
8
14
  textEl?: HTMLParagraphElement;
15
+ /** Whether the tooltip can be visible. */
9
16
  display: boolean;
17
+ /** @internal */
18
+ private _trigger;
19
+ /**
20
+ * Which type of trigger the tool-tip will use.
21
+ * @type {TriggerTypes}
22
+ * @default manual
23
+ */
10
24
  set trigger(val: TriggerTypes);
11
25
  get trigger(): TriggerTypes;
26
+ /** The text to display on the tool-tip. */
12
27
  text: string;
13
28
  render(): import("lit-html").TemplateResult<1>;
14
- /**
15
- * Clamps the tooltip position to within the bounds
16
- */
17
- clampPosition: (pos: {
29
+ /** Clamps the tooltip position to within the bounds. */
30
+ protected clampPosition(pos: {
18
31
  x: number;
19
32
  y: number;
20
- }, bounds: DOMRect) => {
33
+ }, bounds: DOMRect): {
21
34
  x: number;
22
35
  y: number;
23
36
  };
37
+ /** Sets the tooltip position, clamped to a set of bounds. */
24
38
  setClampedPosition({ x, y }: client, bounds: DOMRect): void;
39
+ /** Sets the tooltip position. */
25
40
  setPosition({ x, y }: client): void;
26
41
  }
27
42
  declare global {
@@ -1 +1 @@
1
- {"version":3,"file":"tool-tip.d.ts","sourceRoot":"","sources":["../../../src/components/tool-tip/tool-tip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAkB,MAAM,KAAK,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,MAAM,MAAM,YAAY,GACtB,OAAO,GACP,OAAO,GACP,QAAQ,CAAA;AAEV,eAAO,MAAM,MAAM,yBAwDlB,CAAA;AAED,qBACa,OAAQ,SAAQ,UAAU;IACtC,MAAM,CAAC,MAAM,0BAAU;IAEvB,OAAO,CAAC,QAAQ,CAA0B;IAG1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAG9B,OAAO,UAAS;IAEhB,IACI,OAAO,CAAC,GAAG,EAAE,YAAY,EAG5B;IACD,IAAI,OAAO,IAJM,YAAY,CAM5B;IAGD,IAAI,SAAM;IAEV,MAAM;IAYN;;OAEG;IACH,aAAa,GAAI,KAAK;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,QAAQ,OAAO;;;MAsB7D;IAEK,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAIpD,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM;CAInC;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,UAAU,EAAE,OAAO,CAAC;KACpB;CACD"}
1
+ {"version":3,"file":"tool-tip.d.ts","sourceRoot":"","sources":["../../../src/components/tool-tip/tool-tip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,eAAO,MAAM,YAAY,uCAAwC,CAAC;AAElE,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAEvD;;;;;GAKG;AACH,qBACa,OAAQ,SAAQ,UAAU;IACtC,MAAM,CAAC,MAAM,4BAAY;IAEzB,gBAAgB;IAET,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAErC,0CAA0C;IAEnC,OAAO,EAAE,OAAO,CAAS;IAEhC,gBAAgB;IAChB,OAAO,CAAC,QAAQ,CAA0B;IAC1C;;;;OAIG;IACH,IACI,OAAO,CAAC,GAAG,EAAE,YAAY,EAG5B;IACD,IAAI,OAAO,IAJM,YAAY,CAM5B;IAED,2CAA2C;IAE3C,IAAI,EAAE,MAAM,CAAM;IAElB,MAAM;IAYN,yDAAyD;IACzD,SAAS,CAAC,aAAa,CAAE,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,MAAM,EAAE,OAAO;;;;IAwBvE,6DAA6D;IACtD,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAI3D,iCAAiC;IAC1B,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM;CAInC;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,UAAU,EAAE,OAAO,CAAC;KACpB;CACD"}
@@ -4,100 +4,32 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { css, html, LitElement } from "lit";
8
- import { property, query } from "lit/decorators.js";
9
- import { condCustomElement } from "../../decorators/condCustomElement.js";
10
- export const styles = css `
11
- :host {
12
- display: block;
13
- position: relative;
14
- --tooltip-x: 0;
15
- --tooltip-y: 0;
16
- }
17
-
18
- /* Manual or Click appear when display is true */
19
- :host(:not([trigger="hover"])[display]) p {
20
- display: flex;
21
- }
22
-
23
- /* Hover appears when display is true and user is hovering */
24
- :host([trigger="hover"][display]:hover) p {
25
- display: flex;
26
- }
27
-
28
- /* Display nothing when there is no text */
29
- :host([text=""]) #tip {
30
- display: none;
31
- }
32
-
33
- p {
34
- display: none;
35
- align-items: center;
36
- justify-content: center;
37
-
38
- position: absolute;
39
- background: #000000C0;
40
- width: max-content;
41
- min-width: 100px;
42
- height: 40px;
43
- text-align: center;
44
- vertical-align: middle;
45
- font-size: 18px;
46
- font-weight: var(--font-medium);
47
- color: #FAFAFA;
48
- padding: 0;
49
- margin: 0;
50
- transform: translateX(-50%);
51
-
52
- left: var(--tooltip-x);
53
- top: var(--tooltip-y);
54
-
55
- /* Obsidian Styling */
56
- box-sizing: border-box;
57
- animation: pop-down 200ms forwards ease-in-out;
58
- box-shadow: 0 2px 8px var(--background-modifier-box-shadow);
59
- border-radius: var(--radius-s);
60
- line-height: var(--line-height-tight);
61
- z-index: var(--layer-tooltip);
62
- pointer-events: none;
63
- word-break: normal;
64
- overflow-wrap: anywhere;
65
- }
66
- `;
7
+ import { html, LitElement } from "lit";
8
+ import { customElement, property, query } from "lit/decorators.js";
9
+ import styles from './tool-tip.styles.js';
10
+ export const triggerTypes = ['hover', 'click', 'manual'];
11
+ /**
12
+ * A tooltip that can display information on hover or click
13
+ *
14
+ * @cssprop {<length>} --tooltip-x - The x position of the tooltip.
15
+ * @cssprop {<length>} --tooltip-y - The y position of the tooltip.
16
+ */
67
17
  let ToolTip = class ToolTip extends LitElement {
68
18
  constructor() {
69
19
  super(...arguments);
70
- this._trigger = "manual";
20
+ /** Whether the tooltip can be visible. */
71
21
  this.display = false;
22
+ /** @internal */
23
+ this._trigger = "manual";
24
+ /** The text to display on the tool-tip. */
72
25
  this.text = '';
73
- /**
74
- * Clamps the tooltip position to within the bounds
75
- */
76
- this.clampPosition = (pos, bounds) => {
77
- if (!this.textEl || !bounds)
78
- return { x: 0, y: 0 };
79
- // Get tooltip bounds
80
- let tooltipWidth = this.textEl.offsetWidth;
81
- let tooltipHeight = this.textEl.offsetHeight;
82
- // Set tooltip position left or right side of mouse based on whether cursor is halfway
83
- let leftPosition = pos.x - bounds.left > bounds.width / 2 ? pos.x - bounds.left - 56 : pos.x - bounds.left + 64;
84
- let halfTooltipWidth = tooltipWidth / 2;
85
- // Clamp to left edge
86
- if (leftPosition < 0 + halfTooltipWidth)
87
- leftPosition = 0 + halfTooltipWidth;
88
- else if (leftPosition + tooltipWidth > bounds.width + halfTooltipWidth)
89
- leftPosition = bounds.width - tooltipWidth + halfTooltipWidth;
90
- // Get cursor position & align tooltip centered to cursor (1/4 tooltip height)
91
- let topPosition = pos.y - bounds.top - tooltipHeight / 4;
92
- // Clamp to top edge
93
- if (topPosition < 0)
94
- topPosition = 0;
95
- // Clamp to bottom edge
96
- else if (topPosition + tooltipHeight > bounds.height)
97
- topPosition = bounds.height - tooltipHeight;
98
- return { x: leftPosition, y: topPosition };
99
- };
100
26
  }
27
+ static { this.styles = [styles]; }
28
+ /**
29
+ * Which type of trigger the tool-tip will use.
30
+ * @type {TriggerTypes}
31
+ * @default manual
32
+ */
101
33
  set trigger(val) {
102
34
  this._trigger = val;
103
35
  if (val === 'hover')
@@ -117,15 +49,42 @@ let ToolTip = class ToolTip extends LitElement {
117
49
  </p>
118
50
  `;
119
51
  }
52
+ /** Clamps the tooltip position to within the bounds. */
53
+ clampPosition(pos, bounds) {
54
+ if (!this.textEl || !bounds)
55
+ return { x: 0, y: 0 };
56
+ // Get tooltip bounds
57
+ let tooltipWidth = this.textEl.offsetWidth;
58
+ let tooltipHeight = this.textEl.offsetHeight;
59
+ // Set tooltip position left or right side of mouse based on whether cursor is halfway
60
+ let leftPosition = pos.x - bounds.left > bounds.width / 2 ? pos.x - bounds.left - 56 : pos.x - bounds.left + 64;
61
+ let halfTooltipWidth = tooltipWidth / 2;
62
+ // Clamp to left edge
63
+ if (leftPosition < 0 + halfTooltipWidth)
64
+ leftPosition = 0 + halfTooltipWidth;
65
+ else if (leftPosition + tooltipWidth > bounds.width + halfTooltipWidth)
66
+ leftPosition = bounds.width - tooltipWidth + halfTooltipWidth;
67
+ // Get cursor position & align tooltip centered to cursor (1/4 tooltip height)
68
+ let topPosition = pos.y - bounds.top - tooltipHeight / 4;
69
+ // Clamp to top edge
70
+ if (topPosition < 0)
71
+ topPosition = 0;
72
+ // Clamp to bottom edge
73
+ else if (topPosition + tooltipHeight > bounds.height)
74
+ topPosition = bounds.height - tooltipHeight;
75
+ return { x: leftPosition, y: topPosition };
76
+ }
77
+ ;
78
+ /** Sets the tooltip position, clamped to a set of bounds. */
120
79
  setClampedPosition({ x, y }, bounds) {
121
80
  this.setPosition(this.clampPosition({ x, y }, bounds));
122
81
  }
82
+ /** Sets the tooltip position. */
123
83
  setPosition({ x, y }) {
124
84
  this.style.setProperty('--tooltip-x', `${x}px`);
125
85
  this.style.setProperty('--tooltip-y', `${y}px`);
126
86
  }
127
87
  };
128
- ToolTip.styles = styles;
129
88
  __decorate([
130
89
  query('p')
131
90
  ], ToolTip.prototype, "textEl", void 0);
@@ -139,6 +98,6 @@ __decorate([
139
98
  property({ type: String, reflect: true })
140
99
  ], ToolTip.prototype, "text", void 0);
141
100
  ToolTip = __decorate([
142
- condCustomElement('tool-tip')
101
+ customElement('tool-tip')
143
102
  ], ToolTip);
144
103
  export { ToolTip };
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryObj } from '@storybook/web-components';
1
+ import type { Meta, StoryObj } from '@storybook/web-components-vite';
2
2
  import { TriggerTypes } from './tool-tip.js';
3
3
  declare const meta: Meta;
4
4
  export default meta;
@@ -6,8 +6,11 @@ type Props = {
6
6
  text: string;
7
7
  trigger: TriggerTypes;
8
8
  display: boolean;
9
+ '--tooltip-x': string;
10
+ '--tooltip-y': string;
9
11
  };
10
12
  type Story = StoryObj<Props>;
13
+ export declare const Default: Story;
11
14
  export declare const Hover: Story;
12
15
  export declare const Click: Story;
13
16
  //# sourceMappingURL=tool-tip.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-tip.stories.d.ts","sourceRoot":"","sources":["../../../src/components/tool-tip/tool-tip.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAEvE,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAY7B,eAAO,MAAM,KAAK,EAAE,KAOnB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAOnB,CAAC"}
1
+ {"version":3,"file":"tool-tip.stories.d.ts","sourceRoot":"","sources":["../../../src/components/tool-tip/tool-tip.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,IAAI,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAAgB,YAAY,EAAE,MAAM,eAAe,CAAC;AAc3D,QAAA,MAAM,IAAI,EAAE,IAKX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAA;CACrB,CAAC;AAEF,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAsB7B,eAAO,MAAM,OAAO,EAAE,KAOrB,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,KAOnB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAOnB,CAAC"}
@@ -1,21 +1,51 @@
1
1
  import { html } from 'lit';
2
+ import { triggerTypes } from './tool-tip.js';
3
+ import { styleMap } from 'lit/directives/style-map.js';
4
+ const argTypes = {
5
+ text: { control: 'text' },
6
+ trigger: {
7
+ control: 'select',
8
+ options: triggerTypes,
9
+ },
10
+ display: { control: 'boolean' },
11
+ '--tooltip-x': { control: 'text' },
12
+ '--tooltip-y': { control: 'text' }
13
+ };
2
14
  const meta = {
3
15
  title: 'Tool Tip',
4
16
  tags: ['autodocs'],
5
17
  component: 'tool-tip',
18
+ argTypes
6
19
  };
7
20
  export default meta;
8
- const Template = {
9
- render: ({ text, trigger, display }) => {
21
+ const template = {
22
+ render: ({ text, trigger, display, "--tooltip-x": toolTipX, "--tooltip-y": toolTipY }) => {
23
+ const styles = {
24
+ '--tooltip-x': toolTipX,
25
+ '--tooltip-y': toolTipY
26
+ };
10
27
  return html `
11
- <tool-tip text=${text} trigger=${trigger} ?display=${display}>
28
+ <tool-tip
29
+ text=${text}
30
+ trigger=${trigger}
31
+ ?display=${display}
32
+ style=${styleMap(styles)}
33
+ >
12
34
  <button>${trigger} me</button>
13
35
  </tool-tip>
14
36
  `;
15
37
  },
16
38
  };
39
+ export const Default = {
40
+ ...template,
41
+ args: {
42
+ text: 'Default Story',
43
+ trigger: 'manual',
44
+ display: true
45
+ }
46
+ };
17
47
  export const Hover = {
18
- ...Template,
48
+ ...template,
19
49
  args: {
20
50
  text: 'hovered tooltip',
21
51
  trigger: 'hover',
@@ -23,7 +53,7 @@ export const Hover = {
23
53
  }
24
54
  };
25
55
  export const Click = {
26
- ...Template,
56
+ ...template,
27
57
  args: {
28
58
  text: 'clicked tooltip',
29
59
  trigger: 'click',