@alegendstale/holly-components 1.3.1 → 2.0.1
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.
- package/README.md +9 -5
- package/dist/components/absolute-container/absolute-container.d.ts +17 -3
- package/dist/components/absolute-container/absolute-container.d.ts.map +1 -1
- package/dist/components/absolute-container/absolute-container.js +21 -24
- package/dist/components/absolute-container/absolute-container.stories.d.ts +3 -1
- package/dist/components/absolute-container/absolute-container.stories.d.ts.map +1 -1
- package/dist/components/absolute-container/absolute-container.stories.js +35 -7
- package/dist/components/absolute-container/absolute-container.styles.d.ts +3 -0
- package/dist/components/absolute-container/absolute-container.styles.d.ts.map +1 -0
- package/dist/components/absolute-container/absolute-container.styles.js +18 -0
- package/dist/components/bottom-sheet/bottom-sheet.d.ts +25 -0
- package/dist/components/bottom-sheet/bottom-sheet.d.ts.map +1 -1
- package/dist/components/bottom-sheet/bottom-sheet.js +27 -125
- package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts +5 -2
- package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts.map +1 -1
- package/dist/components/bottom-sheet/bottom-sheet.stories.js +31 -7
- package/dist/components/bottom-sheet/bottom-sheet.styles.d.ts +3 -0
- package/dist/components/bottom-sheet/bottom-sheet.styles.d.ts.map +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.styles.js +115 -0
- package/dist/components/canvas/canvas-base.d.ts +8 -1
- package/dist/components/canvas/canvas-base.d.ts.map +1 -1
- package/dist/components/canvas/canvas-base.js +14 -11
- package/dist/components/canvas/canvas-base.stories.d.ts +7 -0
- package/dist/components/canvas/canvas-base.stories.d.ts.map +1 -0
- package/dist/components/canvas/canvas-base.stories.js +24 -0
- package/dist/components/canvas/canvas-gradient.d.ts +10 -3
- package/dist/components/canvas/canvas-gradient.d.ts.map +1 -1
- package/dist/components/canvas/canvas-gradient.js +13 -9
- package/dist/components/canvas/canvas-gradient.stories.d.ts +14 -0
- package/dist/components/canvas/canvas-gradient.stories.d.ts.map +1 -0
- package/dist/components/canvas/canvas-gradient.stories.js +46 -0
- package/dist/components/canvas/canvas-image.d.ts +25 -16
- package/dist/components/canvas/canvas-image.d.ts.map +1 -1
- package/dist/components/canvas/canvas-image.js +84 -72
- package/dist/components/canvas/canvas-image.stories.d.ts +13 -0
- package/dist/components/canvas/canvas-image.stories.d.ts.map +1 -0
- package/dist/components/canvas/canvas-image.stories.js +49 -0
- package/dist/components/canvas/canvas-image.styles.d.ts +3 -0
- package/dist/components/canvas/canvas-image.styles.d.ts.map +1 -0
- package/dist/components/canvas/canvas-image.styles.js +21 -0
- package/dist/components/carousel-scroller/carousel-scroller.d.ts +23 -6
- package/dist/components/carousel-scroller/carousel-scroller.d.ts.map +1 -1
- package/dist/components/carousel-scroller/carousel-scroller.js +32 -80
- package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts +4 -2
- package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts.map +1 -1
- package/dist/components/carousel-scroller/carousel-scroller.stories.js +22 -6
- package/dist/components/carousel-scroller/carousel-scroller.styles.d.ts +3 -0
- package/dist/components/carousel-scroller/carousel-scroller.styles.d.ts.map +1 -0
- package/dist/components/carousel-scroller/carousel-scroller.styles.js +66 -0
- package/dist/components/color-palette/color-palette-utils.d.ts.map +1 -1
- package/dist/components/color-palette/color-palette.d.ts +53 -16
- package/dist/components/color-palette/color-palette.d.ts.map +1 -1
- package/dist/components/color-palette/color-palette.js +72 -126
- package/dist/components/color-palette/color-palette.styles.d.ts +3 -0
- package/dist/components/color-palette/color-palette.styles.d.ts.map +1 -0
- package/dist/components/color-palette/color-palette.styles.js +90 -0
- package/dist/components/color-palette/component/color-palette-component.d.ts +16 -2
- package/dist/components/color-palette/component/color-palette-component.d.ts.map +1 -1
- package/dist/components/color-palette/component/color-palette-component.js +18 -19
- package/dist/components/color-palette/component/color-palette-component.stories.d.ts +4 -2
- package/dist/components/color-palette/component/color-palette-component.stories.d.ts.map +1 -1
- package/dist/components/color-palette/component/color-palette-component.stories.js +34 -36
- package/dist/components/color-palette/component/color-palette-component.styles.d.ts +3 -0
- package/dist/components/color-palette/component/color-palette-component.styles.d.ts.map +1 -0
- package/dist/components/color-palette/component/color-palette-component.styles.js +10 -0
- package/dist/components/color-palette/editor/color-palette-editor.d.ts +28 -14
- package/dist/components/color-palette/editor/color-palette-editor.d.ts.map +1 -1
- package/dist/components/color-palette/editor/color-palette-editor.js +30 -216
- package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts +9 -2
- package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts.map +1 -1
- package/dist/components/color-palette/editor/color-palette-editor.stories.js +32 -4
- package/dist/components/color-palette/editor/color-palette-editor.styles.d.ts +3 -0
- package/dist/components/color-palette/editor/color-palette-editor.styles.d.ts.map +1 -0
- package/dist/components/color-palette/editor/color-palette-editor.styles.js +147 -0
- package/dist/components/color-palette/editor/settings-item.d.ts +20 -0
- package/dist/components/color-palette/editor/settings-item.d.ts.map +1 -0
- package/dist/components/color-palette/editor/settings-item.js +43 -0
- package/dist/components/color-palette/editor/settings-item.styles.d.ts +3 -0
- package/dist/components/color-palette/editor/settings-item.styles.d.ts.map +1 -0
- package/dist/components/color-palette/editor/settings-item.styles.js +34 -0
- package/dist/components/color-palette/item/color-palette-item-edit.d.ts +9 -2
- package/dist/components/color-palette/item/color-palette-item-edit.d.ts.map +1 -1
- package/dist/components/color-palette/item/color-palette-item-edit.js +12 -57
- package/dist/components/color-palette/item/color-palette-item-edit.styles.d.ts +3 -0
- package/dist/components/color-palette/item/color-palette-item-edit.styles.d.ts.map +1 -0
- package/dist/components/color-palette/item/color-palette-item-edit.styles.js +51 -0
- package/dist/components/color-palette/item/color-palette-item.d.ts +21 -2
- package/dist/components/color-palette/item/color-palette-item.d.ts.map +1 -1
- package/dist/components/color-palette/item/color-palette-item.js +23 -89
- package/dist/components/color-palette/item/color-palette-item.styles.d.ts +3 -0
- package/dist/components/color-palette/item/color-palette-item.styles.d.ts.map +1 -0
- package/dist/components/color-palette/item/color-palette-item.styles.js +83 -0
- package/dist/components/color-palette/menu/color-palette-menu.d.ts +15 -3
- package/dist/components/color-palette/menu/color-palette-menu.d.ts.map +1 -1
- package/dist/components/color-palette/menu/color-palette-menu.js +15 -54
- package/dist/components/color-palette/menu/color-palette-menu.styles.d.ts +3 -0
- package/dist/components/color-palette/menu/color-palette-menu.styles.d.ts.map +1 -0
- package/dist/components/color-palette/menu/color-palette-menu.styles.js +49 -0
- package/dist/components/color-palette/menu/color-palette-reorder.d.ts +8 -1
- package/dist/components/color-palette/menu/color-palette-reorder.d.ts.map +1 -1
- package/dist/components/color-palette/menu/color-palette-reorder.js +11 -36
- package/dist/components/color-palette/menu/color-palette-reorder.styles.d.ts +3 -0
- package/dist/components/color-palette/menu/color-palette-reorder.styles.d.ts.map +1 -0
- package/dist/components/color-palette/menu/color-palette-reorder.styles.js +31 -0
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts +26 -8
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts.map +1 -1
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +10 -39
- package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts +26 -8
- package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts.map +1 -1
- package/dist/components/color-palette/storybook/color-palette-valid.stories.js +30 -58
- package/dist/components/color-palette/storybook/color-palette.stories.d.ts +18 -4
- package/dist/components/color-palette/storybook/color-palette.stories.d.ts.map +1 -1
- package/dist/components/color-palette/storybook/color-palette.stories.js +65 -14
- package/dist/components/draw-svg/draw-svg.d.ts +11 -0
- package/dist/components/draw-svg/draw-svg.d.ts.map +1 -1
- package/dist/components/draw-svg/draw-svg.js +15 -45
- package/dist/components/draw-svg/draw-svg.stories.d.ts +2 -14
- package/dist/components/draw-svg/draw-svg.stories.d.ts.map +1 -1
- package/dist/components/draw-svg/draw-svg.stories.js +21 -97
- package/dist/components/draw-svg/draw-svg.styles.d.ts +3 -0
- package/dist/components/draw-svg/draw-svg.styles.d.ts.map +1 -0
- package/dist/components/draw-svg/draw-svg.styles.js +39 -0
- package/dist/components/responsive-svg/responsive-svg.d.ts +35 -15
- package/dist/components/responsive-svg/responsive-svg.d.ts.map +1 -1
- package/dist/components/responsive-svg/responsive-svg.js +50 -92
- package/dist/components/responsive-svg/responsive-svg.stories.d.ts +5 -4
- package/dist/components/responsive-svg/responsive-svg.stories.d.ts.map +1 -1
- package/dist/components/responsive-svg/responsive-svg.stories.js +90 -108
- package/dist/components/responsive-svg/responsive-svg.styles.d.ts +3 -0
- package/dist/components/responsive-svg/responsive-svg.styles.d.ts.map +1 -0
- package/dist/components/responsive-svg/responsive-svg.styles.js +46 -0
- package/dist/components/tool-tip/tool-tip.d.ts +24 -9
- package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
- package/dist/components/tool-tip/tool-tip.js +49 -90
- package/dist/components/tool-tip/tool-tip.stories.d.ts +4 -1
- package/dist/components/tool-tip/tool-tip.stories.d.ts.map +1 -1
- package/dist/components/tool-tip/tool-tip.stories.js +35 -5
- package/dist/components/tool-tip/tool-tip.styles.d.ts +3 -0
- package/dist/components/tool-tip/tool-tip.styles.d.ts.map +1 -0
- package/dist/components/tool-tip/tool-tip.styles.js +58 -0
- package/dist/utils/ResponsiveController.d.ts +11 -0
- package/dist/utils/ResponsiveController.d.ts.map +1 -0
- package/dist/utils/ResponsiveController.js +19 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/package.json +23 -19
- package/dist/components/bottom-sheet/bottom-sheet.test.d.ts +0 -2
- package/dist/components/bottom-sheet/bottom-sheet.test.d.ts.map +0 -1
- package/dist/components/bottom-sheet/bottom-sheet.test.js +0 -15
- package/dist/components/tool-tip/Tooltip2.d.ts +0 -17
- package/dist/components/tool-tip/Tooltip2.d.ts.map +0 -1
- 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
table: {
|
|
62
|
-
defaultValue: { summary: 'false' }
|
|
63
|
-
}
|
|
29
|
+
},
|
|
30
|
+
fill: {
|
|
31
|
+
control: {
|
|
32
|
+
type: 'color',
|
|
33
|
+
presetColors: ['rebeccapurple', 'black'],
|
|
64
34
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
52
|
+
},
|
|
53
|
+
'--svg-width': {
|
|
54
|
+
control: 'text',
|
|
55
|
+
table: {
|
|
56
|
+
defaultValue: { summary: '0em' },
|
|
88
57
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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-auto-height': { control: false },
|
|
67
|
+
'--svg-auto-width': { 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
|
|
101
|
-
render: ({ fontSize, stroke, fill, autofit, svgColors,
|
|
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,94 @@ const Template = {
|
|
|
119
98
|
},
|
|
120
99
|
};
|
|
121
100
|
export const SVG = {
|
|
122
|
-
...
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
svg: ResponsiveSVGRaw
|
|
108
|
+
svg: ResponsiveSVGRaw,
|
|
109
|
+
"--scale": 1
|
|
132
110
|
},
|
|
133
111
|
};
|
|
134
112
|
export const TemplateResult2 = {
|
|
135
|
-
...
|
|
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
120
|
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"/>`
|
|
145
121
|
}
|
|
146
122
|
};
|
|
147
123
|
export const ServicesBottom = {
|
|
148
|
-
...
|
|
124
|
+
...template,
|
|
149
125
|
args: {
|
|
150
126
|
fontSize: 128,
|
|
151
127
|
stroke: 'rebeccapurple',
|
|
152
128
|
fill: 'black',
|
|
153
129
|
autofit: false,
|
|
154
130
|
svgColors: false,
|
|
155
|
-
height: 128,
|
|
156
|
-
width: 128,
|
|
157
131
|
svg: ServicesBottomRaw
|
|
158
132
|
}
|
|
159
133
|
};
|
|
160
134
|
export const EmptyString = {
|
|
161
|
-
...
|
|
135
|
+
...template,
|
|
162
136
|
args: {
|
|
163
137
|
fontSize: 128,
|
|
164
138
|
stroke: 'rebeccapurple',
|
|
165
139
|
fill: 'black',
|
|
166
140
|
autofit: false,
|
|
167
141
|
svgColors: false,
|
|
168
|
-
height: 0,
|
|
169
|
-
width: 0,
|
|
170
142
|
svg: ''
|
|
171
143
|
},
|
|
144
|
+
play: async ({ canvasElement }) => {
|
|
145
|
+
const component = canvasElement.querySelector('responsive-svg');
|
|
146
|
+
const svgElement = component?.querySelector('svg');
|
|
147
|
+
// Check if element exists
|
|
148
|
+
await expect(component).not.toBeNull();
|
|
149
|
+
// Make sure element didn't render an SVG
|
|
150
|
+
await expect(svgElement).toBeNull();
|
|
151
|
+
}
|
|
172
152
|
};
|
|
173
153
|
export const Invalid = {
|
|
174
|
-
...
|
|
154
|
+
...template,
|
|
175
155
|
args: {
|
|
176
156
|
fontSize: 128,
|
|
177
157
|
stroke: 'rebeccapurple',
|
|
178
158
|
fill: 'black',
|
|
179
159
|
autofit: false,
|
|
180
160
|
svgColors: false,
|
|
181
|
-
height: 0,
|
|
182
|
-
width: 0,
|
|
183
161
|
svg: 'test'
|
|
184
162
|
},
|
|
163
|
+
play: async ({ canvasElement }) => {
|
|
164
|
+
const component = canvasElement.querySelector('responsive-svg');
|
|
165
|
+
const svgElement = component?.querySelector('svg');
|
|
166
|
+
// Check if element exists
|
|
167
|
+
await expect(component).not.toBeNull();
|
|
168
|
+
// Make sure element didn't render an SVG
|
|
169
|
+
await expect(svgElement).toBeNull();
|
|
170
|
+
}
|
|
185
171
|
};
|
|
186
172
|
export const SVGWithoutViewBox = {
|
|
187
|
-
...
|
|
173
|
+
...template,
|
|
188
174
|
args: {
|
|
189
175
|
fontSize: 128,
|
|
190
176
|
stroke: 'rebeccapurple',
|
|
191
177
|
fill: 'black',
|
|
192
178
|
autofit: false,
|
|
193
179
|
svgColors: false,
|
|
194
|
-
height: 0,
|
|
195
|
-
width: 0,
|
|
196
180
|
svg: GotLeakz
|
|
197
181
|
},
|
|
198
182
|
};
|
|
199
183
|
export const SVGWithoutWidthHeight = {
|
|
200
|
-
...
|
|
184
|
+
...template,
|
|
201
185
|
args: {
|
|
202
186
|
fontSize: 128,
|
|
203
187
|
autofit: false,
|
|
204
188
|
svgColors: true,
|
|
205
|
-
height: 0,
|
|
206
|
-
width: 0,
|
|
207
189
|
svg: ComicBackground,
|
|
208
190
|
preserveAspectRatio: 'none'
|
|
209
191
|
},
|
|
@@ -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-auto-width)) / 100 * var(--scale));
|
|
29
|
+
height: calc(var(--svg-height, var(--svg-auto-height)) / 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
|
|
4
|
-
export
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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 {
|
|
8
|
-
import { property, query } from "lit/decorators.js";
|
|
9
|
-
import
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
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
|
|
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
|
-
...
|
|
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
|
-
...
|
|
56
|
+
...template,
|
|
27
57
|
args: {
|
|
28
58
|
text: 'clicked tooltip',
|
|
29
59
|
trigger: 'click',
|