@gitlab/ui 69.0.0 → 70.0.0
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/CHANGELOG.md +20 -0
- package/dist/components/charts/area/area.js +3 -30
- package/dist/components/charts/bar/bar.js +2 -2
- package/dist/components/charts/column/column.js +2 -2
- package/dist/components/charts/discrete_scatter/discrete_scatter.js +1 -0
- package/dist/components/charts/heatmap/heatmap.js +2 -2
- package/dist/components/charts/line/line.js +3 -3
- package/dist/components/charts/stacked_column/stacked_column.js +2 -2
- package/dist/components/charts/tooltip/tooltip.js +121 -12
- package/dist/tokens/css/tokens.css +1 -1
- package/dist/tokens/css/tokens.dark.css +1 -1
- package/dist/tokens/js/tokens.dark.js +1 -1
- package/dist/tokens/js/tokens.js +1 -1
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/dist/utils/charts/constants.js +4 -12
- package/dist/utils/charts/theme.js +2 -3
- package/dist/utils/constants.js +1 -3
- package/package.json +8 -10
- package/src/components/charts/area/area.spec.js +2 -19
- package/src/components/charts/area/area.vue +3 -40
- package/src/components/charts/bar/bar.vue +2 -2
- package/src/components/charts/column/column.vue +2 -6
- package/src/components/charts/discrete_scatter/discrete_scatter.vue +1 -0
- package/src/components/charts/heatmap/heatmap.spec.js +1 -2
- package/src/components/charts/heatmap/heatmap.vue +2 -2
- package/src/components/charts/line/line.vue +2 -4
- package/src/components/charts/sparkline/sparkline.spec.js +6 -6
- package/src/components/charts/stacked_column/stacked_column.vue +1 -2
- package/src/components/charts/tooltip/tooltip.spec.js +158 -11
- package/src/components/charts/tooltip/tooltip.vue +117 -23
- package/src/scss/utilities.scss +20 -0
- package/src/scss/utility-mixins/spacing.scss +12 -0
- package/src/utils/charts/constants.js +3 -11
- package/src/utils/charts/theme.js +3 -2
- package/src/utils/constants.js +1 -3
- package/scss_to_js/scss_variables.js +0 -386
- package/scss_to_js/scss_variables.json +0 -2192
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<!-- eslint-disable vue/multi-word-component-names -->
|
|
2
2
|
<script>
|
|
3
3
|
import * as echarts from 'echarts';
|
|
4
|
-
import { uid } from '../../../utils/utils';
|
|
4
|
+
import { uid, debounceByAnimationFrame } from '../../../utils/utils';
|
|
5
5
|
import GlPopover from '../../base/popover/popover.vue';
|
|
6
6
|
import { popoverPlacements } from '../../../utils/constants';
|
|
7
|
+
import { TOOLTIP_LEFT_OFFSET, TOOLTIP_TOP_OFFSET } from '../../../utils/charts/constants';
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
name: 'GlChartTooltip',
|
|
@@ -24,74 +25,167 @@ export default {
|
|
|
24
25
|
required: false,
|
|
25
26
|
default: () => uid(),
|
|
26
27
|
},
|
|
28
|
+
/**
|
|
29
|
+
* Position of the popover respective to the chart.
|
|
30
|
+
* Sets the `top` style property.
|
|
31
|
+
*/
|
|
27
32
|
top: {
|
|
28
33
|
type: String,
|
|
29
34
|
required: false,
|
|
30
35
|
default: null,
|
|
31
36
|
},
|
|
37
|
+
/**
|
|
38
|
+
* Position of the popover respective to the chart.
|
|
39
|
+
* Sets the `bottom` style property.
|
|
40
|
+
*/
|
|
32
41
|
bottom: {
|
|
33
42
|
type: String,
|
|
34
43
|
required: false,
|
|
35
44
|
default: null,
|
|
36
45
|
},
|
|
46
|
+
/**
|
|
47
|
+
* Position of the popover respective to the chart.
|
|
48
|
+
* Sets the `left` style property.
|
|
49
|
+
*/
|
|
37
50
|
left: {
|
|
38
51
|
type: String,
|
|
39
52
|
required: false,
|
|
40
53
|
default: null,
|
|
41
54
|
},
|
|
55
|
+
/**
|
|
56
|
+
* Position of the popover respective to the chart.
|
|
57
|
+
* Sets the `right` style property.
|
|
58
|
+
*/
|
|
42
59
|
right: {
|
|
43
60
|
type: String,
|
|
44
61
|
required: false,
|
|
45
62
|
default: null,
|
|
46
63
|
},
|
|
64
|
+
/**
|
|
65
|
+
* Set to `true` to show, set to `false` to not show.
|
|
66
|
+
* Set to `null` to show only when the mouse is in the chart.
|
|
67
|
+
*/
|
|
68
|
+
show: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
required: false,
|
|
71
|
+
default: null,
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* Popover placement
|
|
75
|
+
*/
|
|
47
76
|
placement: {
|
|
48
77
|
type: String,
|
|
49
78
|
required: false,
|
|
50
79
|
default: popoverPlacements.right,
|
|
51
80
|
},
|
|
81
|
+
/**
|
|
82
|
+
* Distance between the popover and the pointer when
|
|
83
|
+
* no position is defined
|
|
84
|
+
*/
|
|
85
|
+
xOffset: {
|
|
86
|
+
type: Number,
|
|
87
|
+
required: false,
|
|
88
|
+
default: TOOLTIP_LEFT_OFFSET,
|
|
89
|
+
validator(value) {
|
|
90
|
+
// popover target must have a size of at least 1
|
|
91
|
+
return value >= 1;
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* Distance between the popover and the pointer when
|
|
96
|
+
* no position is defined
|
|
97
|
+
*/
|
|
98
|
+
yOffset: {
|
|
99
|
+
type: Number,
|
|
100
|
+
required: false,
|
|
101
|
+
default: TOOLTIP_TOP_OFFSET,
|
|
102
|
+
validator(value) {
|
|
103
|
+
// popover target must have a size of at least 1
|
|
104
|
+
return value >= 1;
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
data() {
|
|
109
|
+
return {
|
|
110
|
+
pointerPosition: null,
|
|
111
|
+
isPointerInChart: false,
|
|
112
|
+
|
|
113
|
+
debouncedMouseHandler: debounceByAnimationFrame(this.mouseHandler),
|
|
114
|
+
};
|
|
52
115
|
},
|
|
53
116
|
computed: {
|
|
54
|
-
|
|
117
|
+
targetId() {
|
|
55
118
|
// if multiple tooltips are used in a chart component,
|
|
56
119
|
// `this.id` can be used to uniquely identify them
|
|
57
120
|
return `${this.chart.getDom().getAttribute('_echarts_instance_')}-tooltip-${this.id}`;
|
|
58
121
|
},
|
|
59
|
-
|
|
60
|
-
|
|
122
|
+
targetStyle() {
|
|
123
|
+
// the target is a rectangular space between cursor and popover
|
|
124
|
+
return {
|
|
125
|
+
marginTop: `${-this.yOffset}px`,
|
|
126
|
+
height: `${this.yOffset * 2}px`,
|
|
127
|
+
|
|
128
|
+
marginLeft: `${-this.xOffset}px`,
|
|
129
|
+
width: `${this.xOffset * 2}px`,
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
fixedPosition() {
|
|
133
|
+
const { top, left, bottom, right } = this;
|
|
134
|
+
if (top || left || bottom || right) {
|
|
135
|
+
return { top, left, bottom, right };
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
},
|
|
139
|
+
shouldShowPopover() {
|
|
140
|
+
if (this.show !== null) {
|
|
141
|
+
return this.show;
|
|
142
|
+
}
|
|
143
|
+
return this.isPointerInChart;
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
created() {
|
|
147
|
+
this.chart.getZr().on('mousemove', this.debouncedMouseHandler);
|
|
148
|
+
this.chart.getZr().on('mouseout', this.debouncedMouseHandler);
|
|
149
|
+
},
|
|
150
|
+
beforeDestroy() {
|
|
151
|
+
this.chart.getZr().off('mousemove', this.debouncedMouseHandler);
|
|
152
|
+
this.chart.getZr().off('mouseout', this.debouncedMouseHandler);
|
|
153
|
+
},
|
|
154
|
+
methods: {
|
|
155
|
+
mouseHandler(event) {
|
|
156
|
+
let { zrX: x, zrY: y } = event.event;
|
|
61
157
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
accumulator[prop] = position;
|
|
66
|
-
}
|
|
158
|
+
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
159
|
+
x = Math.round(x);
|
|
160
|
+
y = Math.round(y);
|
|
67
161
|
|
|
68
|
-
|
|
69
|
-
|
|
162
|
+
this.pointerPosition = {
|
|
163
|
+
left: `${x}px`,
|
|
164
|
+
top: `${y}px`,
|
|
165
|
+
};
|
|
166
|
+
this.isPointerInChart = this.chart.containPixel('grid', [x, y]);
|
|
167
|
+
}
|
|
70
168
|
},
|
|
71
169
|
},
|
|
72
170
|
};
|
|
73
171
|
</script>
|
|
74
172
|
|
|
75
173
|
<template>
|
|
76
|
-
<div>
|
|
77
|
-
<!--
|
|
78
|
-
Width and height need to be greater than 0px for the
|
|
79
|
-
popover component to render within the following container
|
|
80
|
-
-->
|
|
174
|
+
<div v-if="chart" class="gl-pointer-events-none">
|
|
81
175
|
<div
|
|
82
|
-
:id="
|
|
83
|
-
:style="
|
|
84
|
-
style="width: 1px; height: 1px"
|
|
176
|
+
:id="targetId"
|
|
177
|
+
:style="{ ...(fixedPosition || pointerPosition), ...targetStyle }"
|
|
85
178
|
class="gl-chart-tooltip"
|
|
86
179
|
></div>
|
|
87
180
|
<!--
|
|
88
|
-
|
|
89
|
-
|
|
181
|
+
Is shown using `show` property directly so
|
|
182
|
+
`triggers` are set to an empty string
|
|
90
183
|
-->
|
|
91
184
|
<gl-popover
|
|
92
185
|
v-bind="$attrs"
|
|
93
|
-
:
|
|
94
|
-
:
|
|
186
|
+
:show="shouldShowPopover"
|
|
187
|
+
:target="targetId"
|
|
188
|
+
:container="targetId"
|
|
95
189
|
:placement="placement"
|
|
96
190
|
triggers=""
|
|
97
191
|
>
|
package/src/scss/utilities.scss
CHANGED
|
@@ -7156,6 +7156,16 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
|
|
|
7156
7156
|
margin-left: $gl-spacing-scale-7 !important;
|
|
7157
7157
|
}
|
|
7158
7158
|
}
|
|
7159
|
+
.gl-sm-mr-0 {
|
|
7160
|
+
@include gl-media-breakpoint-up(sm) {
|
|
7161
|
+
margin-right: 0;
|
|
7162
|
+
}
|
|
7163
|
+
}
|
|
7164
|
+
.gl-sm-mr-0\! {
|
|
7165
|
+
@include gl-media-breakpoint-up(sm) {
|
|
7166
|
+
margin-right: 0 !important;
|
|
7167
|
+
}
|
|
7168
|
+
}
|
|
7159
7169
|
.gl-sm-mt-0 {
|
|
7160
7170
|
@include gl-media-breakpoint-up(sm) {
|
|
7161
7171
|
margin-top: 0;
|
|
@@ -7340,6 +7350,16 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
|
|
|
7340
7350
|
margin-left: $gl-spacing-scale-3 !important;
|
|
7341
7351
|
}
|
|
7342
7352
|
}
|
|
7353
|
+
.gl-md-mr-0 {
|
|
7354
|
+
@include gl-media-breakpoint-up(md) {
|
|
7355
|
+
margin-right: 0;
|
|
7356
|
+
}
|
|
7357
|
+
}
|
|
7358
|
+
.gl-md-mr-0\! {
|
|
7359
|
+
@include gl-media-breakpoint-up(md) {
|
|
7360
|
+
margin-right: 0 !important;
|
|
7361
|
+
}
|
|
7362
|
+
}
|
|
7343
7363
|
.gl-md-mr-3 {
|
|
7344
7364
|
@include gl-media-breakpoint-up(md) {
|
|
7345
7365
|
margin-right: $gl-spacing-scale-3;
|
|
@@ -999,6 +999,12 @@
|
|
|
999
999
|
}
|
|
1000
1000
|
}
|
|
1001
1001
|
|
|
1002
|
+
@mixin gl-sm-mr-0 {
|
|
1003
|
+
@include gl-media-breakpoint-up(sm) {
|
|
1004
|
+
@include gl-mr-0;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1002
1008
|
@mixin gl-sm-mt-0 {
|
|
1003
1009
|
@include gl-media-breakpoint-up(sm) {
|
|
1004
1010
|
@include gl-mt-0;
|
|
@@ -1107,6 +1113,12 @@
|
|
|
1107
1113
|
}
|
|
1108
1114
|
}
|
|
1109
1115
|
|
|
1116
|
+
@mixin gl-md-mr-0 {
|
|
1117
|
+
@include gl-media-breakpoint-up(md) {
|
|
1118
|
+
@include gl-mr-0;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1110
1122
|
@mixin gl-md-mr-3 {
|
|
1111
1123
|
@include gl-media-breakpoint-up(md) {
|
|
1112
1124
|
@include gl-mr-3;
|
|
@@ -17,13 +17,6 @@ export const ANNOTATIONS_SERIES_NAME = 'annotations';
|
|
|
17
17
|
*/
|
|
18
18
|
export const ANNOTATIONS_COMPONENT_TYPE = 'markPoint';
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* This is so that the mouse doesn't go over the
|
|
22
|
-
* tooltip and call mouseout which will hide the
|
|
23
|
-
* tooltip.
|
|
24
|
-
*/
|
|
25
|
-
export const ANNOTATION_TOOLTIP_TOP_OFFSET = 10;
|
|
26
|
-
|
|
27
20
|
/**
|
|
28
21
|
* This is a slight offset that gets applied to the left
|
|
29
22
|
* of the chart tooltips to ensure a correct position.
|
|
@@ -31,11 +24,10 @@ export const ANNOTATION_TOOLTIP_TOP_OFFSET = 10;
|
|
|
31
24
|
export const TOOLTIP_LEFT_OFFSET = 2;
|
|
32
25
|
|
|
33
26
|
/**
|
|
34
|
-
* This is
|
|
35
|
-
*
|
|
36
|
-
* some spacing.
|
|
27
|
+
* This is a slight offset that gets applied to the left
|
|
28
|
+
* of the chart tooltips to ensure a correct position.
|
|
37
29
|
*/
|
|
38
|
-
export const
|
|
30
|
+
export const TOOLTIP_TOP_OFFSET = 10;
|
|
39
31
|
|
|
40
32
|
/**
|
|
41
33
|
* These are the accepted values for the layout prop
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { glBorderRadiusBase } from '../../../scss_to_js/scss_variables';
|
|
2
1
|
import {
|
|
3
2
|
WHITE,
|
|
4
3
|
GRAY_50,
|
|
@@ -68,6 +67,8 @@ import {
|
|
|
68
67
|
import { scrollHandleSvgPath } from '../svgs/svg_paths';
|
|
69
68
|
import { hexToRgba } from '../utils';
|
|
70
69
|
|
|
70
|
+
const GL_BORDER_RADIUS_BASE = '0.25rem';
|
|
71
|
+
|
|
71
72
|
export const themeName = 'gitlab';
|
|
72
73
|
|
|
73
74
|
export const heatmapHues = [
|
|
@@ -269,7 +270,7 @@ export const createTheme = (options = {}) => ({
|
|
|
269
270
|
borderWidth: 0,
|
|
270
271
|
color: GRAY_900,
|
|
271
272
|
textBackgroundColor: WHITE,
|
|
272
|
-
textBorderRadius:
|
|
273
|
+
textBorderRadius: GL_BORDER_RADIUS_BASE,
|
|
273
274
|
textPadding: [8, 12],
|
|
274
275
|
},
|
|
275
276
|
},
|
package/src/utils/constants.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { glIconSizes as glIconSizesVariable } from '../../scss_to_js/scss_variables'; // eslint-disable-line import/no-unresolved
|
|
2
|
-
|
|
3
1
|
import { POSITION } from '../components/utilities/truncate/constants';
|
|
4
2
|
|
|
5
3
|
function appendDefaultOption(options) {
|
|
@@ -159,7 +157,7 @@ export const datepickerWidthOptionsMap = {
|
|
|
159
157
|
};
|
|
160
158
|
|
|
161
159
|
// size options all have corresponding styles (e.g. .s12 defined in icon.scss)
|
|
162
|
-
export const iconSizeOptions =
|
|
160
|
+
export const iconSizeOptions = [8, 12, 14, 16, 24, 32, 48, 72];
|
|
163
161
|
|
|
164
162
|
export const triggerVariantOptions = {
|
|
165
163
|
click: 'click',
|