@gitlab/ui 115.11.0 → 117.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/dist/components/base/filtered_search/filtered_search_suggestion.js +11 -5
- package/dist/components/dashboards/dashboard_layout/grid_layout/grid_layout.js +2 -2
- package/dist/components/dashboards/dashboard_panel/dashboard_panel.js +45 -3
- package/dist/components/index.js +1 -4
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/tailwind.css.map +1 -1
- package/dist/tokens/common_story_options.js +1 -6
- package/dist/tokens/tokens_story.js +3 -16
- package/package.json +5 -5
- package/src/components/base/filtered_search/filtered_search_suggestion.vue +32 -14
- package/src/components/dashboards/dashboard_layout/grid_layout/grid_layout.vue +2 -2
- package/src/components/dashboards/dashboard_panel/dashboard_panel.md +61 -13
- package/src/components/dashboards/dashboard_panel/dashboard_panel.vue +46 -3
- package/src/components/index.js +1 -4
- package/src/scss/components.scss +0 -1
- package/src/tokens/common_story_options.js +1 -9
- package/src/tokens/tokens_story.vue +2 -22
- package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +0 -79
- package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +0 -138
- package/dist/components/base/form/form_checkbox_tree/models/constants.js +0 -12
- package/dist/components/base/form/form_checkbox_tree/models/node.js +0 -51
- package/dist/components/base/form/form_checkbox_tree/models/tree.js +0 -200
- package/dist/components/base/nav/nav.js +0 -132
- package/dist/components/base/nav/nav_item.js +0 -125
- package/src/components/base/form/form.md +0 -2
- package/src/components/base/form/form_character_count/form_character_count.md +0 -53
- package/src/components/base/form/form_checkbox_tree/checkbox_tree_node.vue +0 -58
- package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.md +0 -73
- package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.vue +0 -116
- package/src/components/base/form/form_checkbox_tree/models/constants.js +0 -12
- package/src/components/base/form/form_checkbox_tree/models/node.js +0 -48
- package/src/components/base/form/form_checkbox_tree/models/tree.js +0 -186
- package/src/components/base/form/form_combobox/form_combobox.md +0 -52
- package/src/components/base/form/form_date/form_date.md +0 -26
- package/src/components/base/form/form_fields/form_fields.md +0 -41
- package/src/components/base/form/form_group/form_group.md +0 -1
- package/src/components/base/form/form_input_group/form_input_group.md +0 -67
- package/src/components/base/form/input_group_text/input_group_text.md +0 -1
- package/src/components/base/nav/nav.md +0 -184
- package/src/components/base/nav/nav.scss +0 -7
- package/src/components/base/nav/nav.vue +0 -70
- package/src/components/base/nav/nav_item.vue +0 -109
- package/src/components/base/token_selector/token_selector.md +0 -78
- package/src/components/charts/bar/bar.md +0 -3
- package/src/components/charts/chart/chart.md +0 -19
- package/src/components/charts/gauge/gauge.md +0 -8
- package/src/components/charts/heatmap/heatmap.md +0 -7
- package/src/components/charts/legend/legend.md +0 -16
- package/src/components/charts/line/line.md +0 -7
- package/src/components/charts/series_label/series_label.md +0 -1
- package/src/components/charts/shared/tooltip/tooltip.md +0 -3
- package/src/components/charts/single_stat/single_stat.md +0 -8
- package/src/components/charts/sparkline/sparkline.md +0 -8
- package/src/components/charts/stacked_column/stacked_column.md +0 -10
- package/src/components/regions/empty_state/empty_state.md +0 -4
- package/src/components/utilities/animated_number/animated_number.md +0 -6
- package/src/components/utilities/friendly_wrap/friendly_wrap.md +0 -66
- package/src/components/utilities/intersection_observer/intersection_observer.md +0 -16
- package/src/components/utilities/intersperse/intersperse.md +0 -90
- package/src/components/utilities/sprintf/sprintf.md +0 -243
- package/src/components/utilities/truncate/truncate.md +0 -14
- package/src/components/utilities/truncate_text/truncate_text.md +0 -26
- package/src/directives/hover_load/hover_load.md +0 -22
- package/src/directives/outside/outside.md +0 -140
- package/src/directives/resize_observer/resize_observer.md +0 -54
- package/src/directives/safe_html/safe_html.md +0 -58
- package/src/directives/safe_link/safe_link.md +0 -37
- package/src/internal/color_contrast/color_contrast.md +0 -8
- package/src/internal/color_contrast/color_contrast.vue +0 -52
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
## Disabling Legends
|
|
2
|
-
|
|
3
|
-
By default, to prevent the chart from disappearing, all legends can't be toggled off – the last
|
|
4
|
-
active legend will be disabled. To manually disable a legend, pass it the
|
|
5
|
-
`disabled` property in `seriesInfo`:
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
seriesInfo = [
|
|
9
|
-
{
|
|
10
|
-
name: 'Example Legend',
|
|
11
|
-
color: 'blue',
|
|
12
|
-
disabled: true,
|
|
13
|
-
type: 'line'
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Displays chart data series name as a label for chart legend, tooltip, etc.
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
The single stat component is used to show a single value. The color of the meta icon / badge is
|
|
2
|
-
determined by the **variant** prop, which can be one of "success", "warning", "danger", "info",
|
|
3
|
-
"neutral" or "muted" (default).
|
|
4
|
-
|
|
5
|
-
#### Hover state
|
|
6
|
-
|
|
7
|
-
You can make the component focusable by adding a `tabindex=0` attribute to it. This will also apply
|
|
8
|
-
a hover state to the component.
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
The `presentation` property allows you to change between a stacked and tiled presentation style. It
|
|
2
|
-
is only setup to accept `stacked` or `tiled` as values, the default value is `stacked`.
|
|
3
|
-
|
|
4
|
-
The `stacked` presentation allows to view multiple series of the same stack as a single column,
|
|
5
|
-
while `tiled` presents the information in multiple columns for each series of a stack.
|
|
6
|
-
|
|
7
|
-
`groupBy` is a property that defines how the data is going to be grouped by for each of the series
|
|
8
|
-
that the `data` property provides. For example if the `data` property has a total of 3 series, with
|
|
9
|
-
7 elements each, `groupBy` could use a 7 element array to show 7 stacked bars or 7 groups of bars
|
|
10
|
-
depending on the preference set by the `presentation` property.
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
The friendly-wrap component lets you wrap text in a predictable way by appending [`<wbr>`] elements
|
|
2
|
-
to specific break-symbols.
|
|
3
|
-
|
|
4
|
-
[`<wbr>`]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr
|
|
5
|
-
|
|
6
|
-
## Internet Explorer 11
|
|
7
|
-
|
|
8
|
-
IE11 doesn't support the `<wbr>` element: <https://caniuse.com/#search=wbr>
|
|
9
|
-
To use this component on IE11, you'll need some CSS to preserve its behaviour:
|
|
10
|
-
|
|
11
|
-
```css
|
|
12
|
-
wbr {
|
|
13
|
-
display: inline-block;
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
### Default
|
|
20
|
-
|
|
21
|
-
By default, `GlFriendlyWrap` wraps text with slashes (`/`) as the break-symbol, which is especially
|
|
22
|
-
useful when displaying paths or URLs:
|
|
23
|
-
|
|
24
|
-
```html
|
|
25
|
-
<gl-friendly-wrap text="/some/file/path" />
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
The code above renders to the following HTML:
|
|
29
|
-
|
|
30
|
-
```html
|
|
31
|
-
<span class="text-break">/<wbr>some/<wbr>file/<wbr>path</span>
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### Custom symbols
|
|
35
|
-
|
|
36
|
-
Multiple custom break-symbols can be defined via the `GlFriendlyWrap` prop:
|
|
37
|
-
|
|
38
|
-
```html
|
|
39
|
-
<gl-friendly-wrap
|
|
40
|
-
:symbols="[';', '-', '.']"
|
|
41
|
-
text="some;text-that.needs;to-be.wrapped"
|
|
42
|
-
/>
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Which renders to:
|
|
46
|
-
|
|
47
|
-
```html
|
|
48
|
-
<span class="text-break">some;<wbr>text-<wbr>that.<wbr>needs;<wbr>to-<wbr>be.<wbr>wrapped</span>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Break words
|
|
52
|
-
|
|
53
|
-
Symbols can be words too:
|
|
54
|
-
|
|
55
|
-
```html
|
|
56
|
-
<gl-friendly-wrap
|
|
57
|
-
:symbols="['and']"
|
|
58
|
-
text="it goes on and on and on and on"
|
|
59
|
-
/>
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Which renders to:
|
|
63
|
-
|
|
64
|
-
```html
|
|
65
|
-
<span class="text-break">it goes on and<wbr> on and<wbr> on and<wbr> on</span>
|
|
66
|
-
```
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
This intersection observer component is an invisible watcher that emits events when it appears and
|
|
2
|
-
dissapears from view.
|
|
3
|
-
|
|
4
|
-
It acts a a vue-friendly wrapper around the [intersection observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
|
|
5
|
-
|
|
6
|
-
Because of it's simplicity you can use it for a lot of different things.
|
|
7
|
-
It's especially helpful for the lazy loading of images, and infinite scrolling of lists.
|
|
8
|
-
|
|
9
|
-
Anything slotted inside this component will become the element that is being observed.
|
|
10
|
-
|
|
11
|
-
This slot can also be used as a fallback for the browsers that don't support the intersection
|
|
12
|
-
observer, or in the case that the observer fails to work.
|
|
13
|
-
For example, adding a "Fetch more posts" button inside an observer that should fetch more posts
|
|
14
|
-
automatically when visible. If the observer fails to work for any reason, the button will still be
|
|
15
|
-
clickable, and the experience preserved. Please use a fallback wherever possible as
|
|
16
|
-
**the intersection observer API is not supported in IE11**.
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
The intersperse component separates a list of elements
|
|
2
|
-
by a given character (the default is `, `).
|
|
3
|
-
|
|
4
|
-
It takes all direct descendants of its default slot and inserts
|
|
5
|
-
the given separator between each item:
|
|
6
|
-
|
|
7
|
-
`item 1, item 2, item 3`
|
|
8
|
-
|
|
9
|
-
Optionally the character used for separating each item and the last separator can be set
|
|
10
|
-
independently:
|
|
11
|
-
|
|
12
|
-
* `separator="/"` renders `item 1/item 2/item 3`
|
|
13
|
-
* `lastSeparator=" and "` will render `item 1, item 2, and item 3`
|
|
14
|
-
* `lastSeparator=" and "` and given two items will render `item 1 and item 2`
|
|
15
|
-
|
|
16
|
-
**Note**:
|
|
17
|
-
|
|
18
|
-
The component provides an inline context since the result is wrapped in a `span`.
|
|
19
|
-
|
|
20
|
-
Also, whitespace elements that are direct children of the default-slot get removed to ensure
|
|
21
|
-
consistent formatting.
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
### Default
|
|
26
|
-
|
|
27
|
-
```html
|
|
28
|
-
<gl-intersperse>
|
|
29
|
-
<span>Item 1</span>
|
|
30
|
-
<span>Item 2</span>
|
|
31
|
-
<span>Item 3</span>
|
|
32
|
-
</gl-intersperse>
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
This renders to the following HTML:
|
|
36
|
-
|
|
37
|
-
```html
|
|
38
|
-
<span><span>Item 1</span>, <span>Item 2</span>, <span>Item 3</span></span>
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Custom Separator
|
|
42
|
-
|
|
43
|
-
A custom separator can be defined via the `separator` prop:
|
|
44
|
-
|
|
45
|
-
```html
|
|
46
|
-
<gl-intersperse separator="/">
|
|
47
|
-
<span>Item 1</span>
|
|
48
|
-
<span>Item 2</span>
|
|
49
|
-
<span>Item 3</span>
|
|
50
|
-
</gl-intersperse>
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
This renders to the following HTML:
|
|
54
|
-
|
|
55
|
-
```html
|
|
56
|
-
<span><span>Item 1</span>/<span>Item 2</span>/<span>Item 3</span></span>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Custom Last Separator
|
|
60
|
-
|
|
61
|
-
A custom last separator can be defined via the `lastSeparator` prop:
|
|
62
|
-
|
|
63
|
-
```html
|
|
64
|
-
<gl-intersperse last-separator=" and ">
|
|
65
|
-
<span>Item 1</span>
|
|
66
|
-
<span>Item 2</span>
|
|
67
|
-
<span>Item 3</span>
|
|
68
|
-
</gl-intersperse>
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
This renders to the following HTML:
|
|
72
|
-
|
|
73
|
-
```html
|
|
74
|
-
<span><span>Item 1</span>, <span>Item 2</span>, and <span>Item 3</span></span>
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
A custom last separator used on two items will only place `lastSeparator` between them:
|
|
78
|
-
|
|
79
|
-
```html
|
|
80
|
-
<gl-intersperse last-separator=" and ">
|
|
81
|
-
<span>Item 1</span>
|
|
82
|
-
<span>Item 2</span>
|
|
83
|
-
</gl-intersperse>
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
This renders to the following HTML:
|
|
87
|
-
|
|
88
|
-
```html
|
|
89
|
-
<span><span>Item 1</span> and <span>Item 2</span></span>
|
|
90
|
-
```
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
|
|
3
|
-
The `GlSprintf` component lets you do `sprintf`-style string interpolation with
|
|
4
|
-
child components. Each placeholder in the translated string, provided via the
|
|
5
|
-
`message` prop, becomes a slot that you can use to insert any components or
|
|
6
|
-
markup in the rendered output.
|
|
7
|
-
|
|
8
|
-
> NOTE: `gl-sprintf` does not translate the message for you; you must provide
|
|
9
|
-
> it already translated. In the following examples, it is assumed that
|
|
10
|
-
> a `gettext`-style `__` translation function is available in your Vue
|
|
11
|
-
> templates.
|
|
12
|
-
|
|
13
|
-
## Displaying messages with text between placeholders (e.g., links, buttons)
|
|
14
|
-
|
|
15
|
-
Sentences should not be split up into different messages, otherwise they may
|
|
16
|
-
not be translatable into certain languages. To help with this, `GlSprintf`
|
|
17
|
-
interprets placeholders suffixed with `Start` and `End` to indicate the
|
|
18
|
-
boundaries of a component to display within the message. Any text between
|
|
19
|
-
them is passed, via the `content` scoped slot property, to the slot name common
|
|
20
|
-
to the placeholders.
|
|
21
|
-
|
|
22
|
-
For example, using `linkStart` and `linkEnd` placeholders in a message defines
|
|
23
|
-
a `link` scoped slot:
|
|
24
|
-
|
|
25
|
-
```html
|
|
26
|
-
<div>
|
|
27
|
-
<gl-sprintf :message="__('Learn more about %{linkStart}zones%{linkEnd}')">
|
|
28
|
-
<template #link="{ content }">
|
|
29
|
-
<gl-link
|
|
30
|
-
href="https://cloud.google.com/compute/docs/regions-zones/regions-zones"
|
|
31
|
-
target="_blank"
|
|
32
|
-
>{{ content }}</gl-link>
|
|
33
|
-
</template>
|
|
34
|
-
</gl-sprintf>
|
|
35
|
-
</div>
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
will render as:
|
|
39
|
-
|
|
40
|
-
```html
|
|
41
|
-
<div>
|
|
42
|
-
Learn more about
|
|
43
|
-
<a
|
|
44
|
-
href="https://cloud.google.com/compute/docs/regions-zones/regions-zones"
|
|
45
|
-
target="_blank"
|
|
46
|
-
rel="noopener noreferrer"
|
|
47
|
-
>zones</a>
|
|
48
|
-
</div>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Note that _any_ arbitrary HTML tags or Vue component(s) can be used within
|
|
52
|
-
a scoped slot, and that the content passed to it can be used in any way at all;
|
|
53
|
-
for instance, as regular text, or in component attributes or slots.
|
|
54
|
-
|
|
55
|
-
Here's a more complex example, which `<gl-sprintf>` lets you do in a breeze:
|
|
56
|
-
|
|
57
|
-
```html
|
|
58
|
-
<div>
|
|
59
|
-
<gl-sprintf :message="__('Written by %{authorStart}someone%{authorEnd}')">
|
|
60
|
-
<template #author="{ content }">
|
|
61
|
-
<my-vue-component v-gl-tooltip="content" @event="handleEvent(content)">
|
|
62
|
-
{{ content }}
|
|
63
|
-
</my-vue-component>
|
|
64
|
-
<p>
|
|
65
|
-
{{ content }}
|
|
66
|
-
<div>{{ content }}</div>
|
|
67
|
-
</p>
|
|
68
|
-
</template>
|
|
69
|
-
</gl-sprintf>
|
|
70
|
-
</div>
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
This is not feasible in a JS-only solution, since arbitrary Vue components
|
|
74
|
-
cannot easily be used. In addition, a JS-only solution is more likely to be
|
|
75
|
-
prone to XSS attacks, as the Vue compiler isn't available to help protect
|
|
76
|
-
against them.
|
|
77
|
-
|
|
78
|
-
### Customizing start/end placeholders
|
|
79
|
-
|
|
80
|
-
You can customize the start and end placeholders that `GlSprintf` looks for
|
|
81
|
-
using the `placeholders` prop. For instance:
|
|
82
|
-
|
|
83
|
-
```html
|
|
84
|
-
<div>
|
|
85
|
-
<gl-sprintf
|
|
86
|
-
:message="__('Learn more about %{my_custom_start}zones%{my_custom_end}')"
|
|
87
|
-
:placeholders="{ link: ['my_custom_start', 'my_custom_end'] }"
|
|
88
|
-
>
|
|
89
|
-
<template #link="{ content }">
|
|
90
|
-
<gl-link
|
|
91
|
-
href="https://cloud.google.com/compute/docs/regions-zones/regions-zones"
|
|
92
|
-
target="_blank"
|
|
93
|
-
>{{ content }}</gl-link>
|
|
94
|
-
</template>
|
|
95
|
-
</gl-sprintf>
|
|
96
|
-
</div>
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
This can be useful if you are migrating an existing string to `GlSprintf` that
|
|
100
|
-
uses different placeholder naming conventions, and don't want invalidate
|
|
101
|
-
existing translations.
|
|
102
|
-
|
|
103
|
-
## Displaying components within a message
|
|
104
|
-
|
|
105
|
-
Use slots to replace placeholders in the message with the slots' contents.
|
|
106
|
-
There is a slot for every placeholder in the message. For example, the `author`
|
|
107
|
-
slot name can be used when there is an `%{author}` placeholder in the message:
|
|
108
|
-
|
|
109
|
-
```html
|
|
110
|
-
<script>
|
|
111
|
-
export default {
|
|
112
|
-
data() {
|
|
113
|
-
return {
|
|
114
|
-
authorName: 'Some author',
|
|
115
|
-
};
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
</script>
|
|
119
|
-
|
|
120
|
-
<template>
|
|
121
|
-
<div>
|
|
122
|
-
<gl-sprintf :message="__('Written by %{author}')">
|
|
123
|
-
<template #author>
|
|
124
|
-
<span>{{ authorName }}</span>
|
|
125
|
-
</template>
|
|
126
|
-
</gl-sprintf>
|
|
127
|
-
</div>
|
|
128
|
-
</template>
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
The example above renders to this HTML:
|
|
132
|
-
|
|
133
|
-
```html
|
|
134
|
-
<div>Written by <span>Some author</span></div>
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
## Usage caveats
|
|
138
|
-
|
|
139
|
-
### White space
|
|
140
|
-
|
|
141
|
-
`GlSprintf` does not handle white space in scoped slots specially; it is passed
|
|
142
|
-
through and rendered just like regular text. This means that white space in the
|
|
143
|
-
scoped slot templates _themselves_, including newlines and indentation, are
|
|
144
|
-
passed through untouched (assuming the template compiler you're using doesn't
|
|
145
|
-
trim text nodes at compile time; `vue-template-compiler` preserves white space
|
|
146
|
-
by default, for instance).
|
|
147
|
-
|
|
148
|
-
Most of the time you don't need to worry about this, since
|
|
149
|
-
[browsers normalize white space][1] automatically, but here's an example, using
|
|
150
|
-
punctuation, where you might want to be conscious of the white space in the
|
|
151
|
-
template:
|
|
152
|
-
|
|
153
|
-
```html
|
|
154
|
-
<div>
|
|
155
|
-
<gl-sprintf :message="__('Foo %{boldStart}bar%{boldEnd}!')">
|
|
156
|
-
<template #bold="{ content }">
|
|
157
|
-
<b>
|
|
158
|
-
{{ content }}
|
|
159
|
-
</b>
|
|
160
|
-
</template>
|
|
161
|
-
</gl-sprintf>
|
|
162
|
-
</div>
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
As written, the literal markup rendered would be:
|
|
166
|
-
|
|
167
|
-
```html
|
|
168
|
-
<div> Foo <b>
|
|
169
|
-
bar
|
|
170
|
-
</b>!
|
|
171
|
-
</div>
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
where the white space (including newlines) before and after `bar` is exactly
|
|
175
|
-
the newlines and indentation in the source template. The browser will render
|
|
176
|
-
this as:
|
|
177
|
-
|
|
178
|
-
<div> Foo <b>
|
|
179
|
-
bar
|
|
180
|
-
</b>!
|
|
181
|
-
</div>
|
|
182
|
-
|
|
183
|
-
Note the single space between `bar` and `!`. To avoid that, remove the
|
|
184
|
-
white space in the template, or use `v-text`:
|
|
185
|
-
|
|
186
|
-
```html
|
|
187
|
-
<div>
|
|
188
|
-
<gl-sprintf :message="__('Foo %{boldStart}bar%{boldEnd}!')">
|
|
189
|
-
<template #bold="{ content }">
|
|
190
|
-
<b>{{ content }}</b>
|
|
191
|
-
<!-- OR -->
|
|
192
|
-
<b v-text="content" />
|
|
193
|
-
</template>
|
|
194
|
-
</gl-sprintf>
|
|
195
|
-
</div>
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### Miscellaneous
|
|
199
|
-
|
|
200
|
-
While there are a lot of caveats here, you don't need to worry about reading
|
|
201
|
-
them _unless_ you find `GlSprintf` isn't rendering what you'd expect.
|
|
202
|
-
|
|
203
|
-
- Since `GlSprintf` typically renders multiple elements, it can't be used as
|
|
204
|
-
a component's root, it must be wrapped with at least one other root element,
|
|
205
|
-
otherwise Vue will throw a `Multiple root nodes returned from render
|
|
206
|
-
function` error.
|
|
207
|
-
- If a slot for a given placeholder _isn't_ provided, the placeholder
|
|
208
|
-
will be rendered as-is, e.g., literally `Written by %{author}` if the
|
|
209
|
-
`author` slot _isn't_ provided, or literally `%{linkStart}foo%{linkEnd}` if
|
|
210
|
-
the `link` slot isn't provided.
|
|
211
|
-
- Content between `Start` and `End` placeholders is effectively thrown away if
|
|
212
|
-
the scoped slot of the correct name doesn't consume the `content` property in
|
|
213
|
-
some way, though the slot's components should still be rendered.
|
|
214
|
-
- If there's no placeholder in the message for a provided named slot, the
|
|
215
|
-
content of that slot is silently thrown away.
|
|
216
|
-
- If only one of the `Start` or `End` placeholders is in the message, or they
|
|
217
|
-
are in the wrong order, they are treated as plain slots, i.e., it is assumed
|
|
218
|
-
there is no text to extract and pass to the scoped slot. This allows you to
|
|
219
|
-
use plain slots whose names end in `Start` or `End`, e.g., `backEnd`, or
|
|
220
|
-
`fromStart` in isolation, without their `Start`/`End` counterparts.
|
|
221
|
-
- Text extraction between `Start` and `End` placeholders is only done one level
|
|
222
|
-
deep. This is intentional, so as to avoid building complex sprintf messages
|
|
223
|
-
that would better be implemented in components. As an example,
|
|
224
|
-
`${linkStart}test%{icon}%{linkEnd}`, if provided both the `link` and `icon`
|
|
225
|
-
slots, would pass `test%{icon}` as a literal string as content to the `link`
|
|
226
|
-
scoped slot.
|
|
227
|
-
- For more examples and edge cases, please see the test suite for `GlSprintf`.
|
|
228
|
-
- To be successfully used in `GlSprintf`, slot names should:
|
|
229
|
-
- start with a letter (`[A-Za-z]`)
|
|
230
|
-
- only contain alpha-numeric characters (`[A-Za-z0-9]`), underscore (`_`) and
|
|
231
|
-
dash (`-`),
|
|
232
|
-
- should not end with underscore (`_`) or dash (`-`) So for example:
|
|
233
|
-
`%{author}`, `%{author_name}`, `%{authorName}` or `%{author-name-100}` are
|
|
234
|
-
all valid placeholders.
|
|
235
|
-
|
|
236
|
-
## Internet Explorer 11
|
|
237
|
-
|
|
238
|
-
This component uses [`String.prototype.startsWith()`] and [`String.prototype.endsWith()`] under the
|
|
239
|
-
hood. Make sure those methods are polyfilled if you plan on using the component on IE11.
|
|
240
|
-
|
|
241
|
-
[1]: https://www.w3.org/TR/css-text-3/#white-space-phase-1
|
|
242
|
-
[`String.prototype.startsWith()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
|
|
243
|
-
[`String.prototype.endsWith()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
The `GlTruncate` component lets you truncate the long texts with ellipsis.
|
|
2
|
-
|
|
3
|
-
> **Tip:** Try resizing the side panel for truncation.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```html
|
|
8
|
-
<gl-truncate :text="text" :position="position" />
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
By default, the ellipsis position is at the `end`.
|
|
12
|
-
|
|
13
|
-
Pro Tip: Truncating long filepaths from the `middle` / `start` can help preventing the important
|
|
14
|
-
information in the end, i.e. filenames.
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
The `GlTruncateText` component lets you truncate a large text by number of lines.
|
|
2
|
-
The last line ends with an ellipsis if the text is truncated.
|
|
3
|
-
Truncation can be toggled by a 'Show more' / 'Show less' button.
|
|
4
|
-
The button will not be shown when no truncation is necessary.
|
|
5
|
-
There is a separate property to set the number of lines initially shown on small screens.
|
|
6
|
-
Use the `showMoreText` and `showLessText` properties to provide translated strings.
|
|
7
|
-
|
|
8
|
-
> **Tip:** Try resizing the side panel to see the truncated number of lines change.
|
|
9
|
-
|
|
10
|
-
## Usage
|
|
11
|
-
|
|
12
|
-
```html
|
|
13
|
-
<gl-truncate-text :show-more-text="__('Show more')" :show-less-text="__('Show less')" :lines="3" :mobile-lines="10">
|
|
14
|
-
{{ largeText }}
|
|
15
|
-
</gl-truncate-text>
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Usage caveats
|
|
19
|
-
|
|
20
|
-
When the size of the window is large,
|
|
21
|
-
and the text is displayed on a number of lines greater than the value of the `lines` property,
|
|
22
|
-
but smaller than the value of the `mobileLines` property,
|
|
23
|
-
and the `Show more` button has been clicked to show the entire content of the text,
|
|
24
|
-
and the window is resized to a small size,
|
|
25
|
-
then instead of disappearing,
|
|
26
|
-
the `Show less` button will remain visible and will do nothing when clicked.
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
A Vue Directive to help with preloading resources when hovering over an element.
|
|
2
|
-
|
|
3
|
-
## Usage
|
|
4
|
-
|
|
5
|
-
```html
|
|
6
|
-
<script>
|
|
7
|
-
import { GlHoverLoadDirective } from '@gitlab/ui';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
directives: { GlHoverLoadDirective },
|
|
11
|
-
methods: {
|
|
12
|
-
handlePreload() {
|
|
13
|
-
fetch('some/endpoint');
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<template>
|
|
20
|
-
<div v-gl-hover-load="handlePreload">Hover me to preload</div>
|
|
21
|
-
</template>
|
|
22
|
-
```
|