@gitlab/ui 115.10.0 → 116.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.
Files changed (53) hide show
  1. package/dist/components/base/filtered_search/filtered_search_suggestion.js +11 -5
  2. package/dist/components/dashboards/dashboard_layout/grid_layout/grid_layout.js +2 -2
  3. package/dist/components/dashboards/dashboard_panel/dashboard_panel.js +45 -3
  4. package/dist/components/index.js +1 -1
  5. package/dist/index.css +1 -1
  6. package/dist/index.css.map +1 -1
  7. package/dist/tailwind.css +1 -1
  8. package/dist/tailwind.css.map +1 -1
  9. package/dist/tokens/common_story_options.js +1 -6
  10. package/dist/tokens/tokens_story.js +3 -16
  11. package/package.json +5 -5
  12. package/src/components/base/button/button.scss +8 -0
  13. package/src/components/base/filtered_search/filtered_search_suggestion.vue +32 -14
  14. package/src/components/dashboards/dashboard_layout/grid_layout/grid_layout.vue +2 -2
  15. package/src/components/dashboards/dashboard_panel/dashboard_panel.md +61 -13
  16. package/src/components/dashboards/dashboard_panel/dashboard_panel.vue +46 -3
  17. package/src/components/index.js +1 -1
  18. package/src/tokens/common_story_options.js +1 -9
  19. package/src/tokens/tokens_story.vue +2 -22
  20. package/src/components/base/form/form.md +0 -2
  21. package/src/components/base/form/form_character_count/form_character_count.md +0 -53
  22. package/src/components/base/form/form_combobox/form_combobox.md +0 -52
  23. package/src/components/base/form/form_date/form_date.md +0 -26
  24. package/src/components/base/form/form_fields/form_fields.md +0 -41
  25. package/src/components/base/form/form_group/form_group.md +0 -1
  26. package/src/components/base/form/form_input_group/form_input_group.md +0 -67
  27. package/src/components/base/form/input_group_text/input_group_text.md +0 -1
  28. package/src/components/charts/bar/bar.md +0 -3
  29. package/src/components/charts/chart/chart.md +0 -19
  30. package/src/components/charts/gauge/gauge.md +0 -8
  31. package/src/components/charts/heatmap/heatmap.md +0 -7
  32. package/src/components/charts/legend/legend.md +0 -16
  33. package/src/components/charts/line/line.md +0 -7
  34. package/src/components/charts/series_label/series_label.md +0 -1
  35. package/src/components/charts/shared/tooltip/tooltip.md +0 -3
  36. package/src/components/charts/single_stat/single_stat.md +0 -8
  37. package/src/components/charts/sparkline/sparkline.md +0 -8
  38. package/src/components/charts/stacked_column/stacked_column.md +0 -10
  39. package/src/components/regions/empty_state/empty_state.md +0 -4
  40. package/src/components/utilities/animated_number/animated_number.md +0 -6
  41. package/src/components/utilities/friendly_wrap/friendly_wrap.md +0 -66
  42. package/src/components/utilities/intersection_observer/intersection_observer.md +0 -16
  43. package/src/components/utilities/intersperse/intersperse.md +0 -90
  44. package/src/components/utilities/sprintf/sprintf.md +0 -243
  45. package/src/components/utilities/truncate/truncate.md +0 -14
  46. package/src/components/utilities/truncate_text/truncate_text.md +0 -26
  47. package/src/directives/hover_load/hover_load.md +0 -22
  48. package/src/directives/outside/outside.md +0 -140
  49. package/src/directives/resize_observer/resize_observer.md +0 -54
  50. package/src/directives/safe_html/safe_html.md +0 -58
  51. package/src/directives/safe_link/safe_link.md +0 -37
  52. package/src/internal/color_contrast/color_contrast.md +0 -8
  53. package/src/internal/color_contrast/color_contrast.vue +0 -52
@@ -2,18 +2,16 @@
2
2
  import { colorFromBackground } from '../utils/utils';
3
3
  import { GlTooltipDirective } from '../directives/tooltip/tooltip';
4
4
  import GlBadge from '../components/base/badge/badge.vue';
5
- import GlColorContrast from '../internal/color_contrast/color_contrast.vue';
6
5
 
7
6
  export default {
8
7
  name: 'TokensStory',
9
8
  components: {
10
9
  GlBadge,
11
- GlColorContrast,
12
10
  },
13
11
  directives: {
14
12
  GlTooltip: GlTooltipDirective,
15
13
  },
16
- inject: ['isBackgroundColorStory', 'lightBackground', 'darkBackground', 'containerClass'],
14
+ inject: ['containerClass'],
17
15
  props: {
18
16
  tokens: {
19
17
  type: Object,
@@ -30,7 +28,6 @@ export default {
30
28
  },
31
29
  getClasses(value) {
32
30
  if (!this.isHex(value)) return '';
33
- if (!this.isBackgroundColorStory) return '';
34
31
 
35
32
  const textColorVariant = colorFromBackground(value, 4.5);
36
33
  return {
@@ -38,13 +35,6 @@ export default {
38
35
  'gl-text-neutral-0': textColorVariant === 'light',
39
36
  };
40
37
  },
41
- getStyle(value) {
42
- if (this.isBackgroundColorStory) {
43
- return { backgroundColor: value };
44
- }
45
-
46
- return { color: value };
47
- },
48
38
  },
49
39
  };
50
40
  </script>
@@ -57,7 +47,7 @@ export default {
57
47
  :key="token.name"
58
48
  class="gl-flex gl-flex-wrap gl-items-center gl-justify-between gl-gap-3 gl-p-3"
59
49
  :class="getClasses(token.$value)"
60
- :style="getStyle(token.$value)"
50
+ :style="{ backgroundColor: token.$value }"
61
51
  >
62
52
  <code v-gl-tooltip :title="token.comment" class="gl-text-inherit">
63
53
  {{ getTokenName(token) }}
@@ -67,16 +57,6 @@ export default {
67
57
  Deprecated
68
58
  </gl-badge>
69
59
  <code class="gl-text-inherit">{{ token.$value }}</code>
70
- <gl-color-contrast
71
- v-if="isHex(token.$value)"
72
- :foreground="token.$value"
73
- :background="darkBackground"
74
- />
75
- <gl-color-contrast
76
- v-if="isHex(token.$value)"
77
- :foreground="token.$value"
78
- :background="lightBackground"
79
- />
80
60
  </div>
81
61
  </li>
82
62
  </ul>
@@ -1,2 +0,0 @@
1
- A wrapper element for `gl-form-*` input elements. Supports `@submit` and `@reset` events.
2
- To disable native HTML validation pass the `novalidate` attribute.
@@ -1,53 +0,0 @@
1
- ## Usage
2
-
3
- `GlFormCharacterCount` can be used to add a character count to an input.
4
- If you are using `GlFormTextarea` on its own see [with character count example](https://design.gitlab.com/storybook?path=/story/base-form-form-textarea--with-character-count).
5
- If you are wrapping your input, such as in a markdown component, and need the character
6
- count separate from the input, use `GlFormCharacterCount`.
7
-
8
- ## Example
9
-
10
- ```html
11
- <script>
12
- import { GlFormCharacterCount, GlFormInput, GlFormGroup } from '@gitlab/ui'
13
-
14
- export default {
15
- inputId: 'form-input-with-character-count',
16
- countTextId: 'character-count-text',
17
- limit: 100,
18
- components: { GlFormCharacterCount, GlFormInput, GlFormGroup },
19
- data() {
20
- return {
21
- value: '',
22
- }
23
- },
24
- methods: {
25
- remainingCountText(count) {
26
- return n__('%d character remaining.', '%d characters remaining.', count)
27
- },
28
- overLimitText(count) {
29
- return n__('%d character over limit.', '%d characters over limit.', count);
30
- },
31
- },
32
- }
33
- <script>
34
-
35
- <template>
36
- <gl-form-group label="Form input with character count" :label-for="$options.inputId">
37
- <gl-form-input
38
- v-model="value"
39
- :id="$options.inputId"
40
- :value="value"
41
- :aria-describedby="$options.countTextId"
42
- />
43
- <gl-form-character-count
44
- :value="value"
45
- :limit="$options.limit"
46
- :count-text-id="$options.countTextId"
47
- >
48
- <template #remaining-count-text="{ count }">{{ remainingCountText(count) }}</template>
49
- <template #over-limit-text="{ count }">{{ overLimitText(count) }}</template>
50
- </gl-form-character-count>
51
- </gl-form-group>
52
- <template>
53
- ```
@@ -1,52 +0,0 @@
1
- Use this component to add a [`FormInput`](/?path=/story/base-form-form-input--default) component
2
- with synchronous autocomplete dropdown. It behaves as follows:
3
-
4
- - Typing matches tokens; dropdown disappears when there is no match
5
- - Up and down arrows navigate the dropdown
6
- - Enter selects keyboard-highlighted item; clicking overrides this
7
- - Esc closes dropdown when it is open, clears field when it is not
8
- - Browser/native autocomplete dropdown hidden when ours is open, shows when it is not
9
- - Tab selects current entered text and moves to next field
10
-
11
- This behavior based on
12
- [this w3c pattern](https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html)
13
- and [this accessible combobox example](https://alligator.io/vuejs/vue-a11y-autocomplete/).
14
-
15
- ## Usage
16
-
17
- The combobox accepts an array of string tokens, a `v-model`, and label text. Internally, it generates
18
- unique element IDs so multiple can be used on one page without clashing.
19
-
20
- On selection it sets the input value to the selected string and emits a `value-selected` event for
21
- consumption by parent components.
22
-
23
- ```html
24
- <gl-form-combobox
25
- v-model="inputVal"
26
- :token-list="tokens"
27
- label-text="Combobox Label"
28
- />
29
- ```
30
-
31
- It does not have a loading state nor does it accept tokens other than strings. It allows for one
32
- selected value.
33
-
34
- ### What if I need to load the options asynchronously?
35
-
36
- You may want to look at [`GlSearchBoxByType`] or [`GlSearchBoxByClick`].
37
-
38
- ### What if I need multiple options?
39
-
40
- The [`GlTokenSelector`] may be what you need. Alternately, [`GlFilteredSearch`] will let you search
41
- and include tokens.
42
-
43
- ## Edge cases
44
-
45
- The algorithm to match tokens with the input is very naive. If you need to use the component with a
46
- very large list of matches, you may want to update the implementation or use one of the search
47
- inputs, like [`GlSearchBoxByType`], [`GlSearchBoxByClick`], or [`GlFilteredSearch`].
48
-
49
- [`GlSearchBoxByType`]: https://design.gitlab.com/storybook?path=/story/base-search-box-by-type--default
50
- [`GlSearchBoxByClick`]: https://design.gitlab.com/storybook?path=/story/base-search-box-by-click--default
51
- [`GlTokenSelector`]: https://design.gitlab.com/storybook?path=/story/base-token-selector--default
52
- [`GlFilteredSearch`]: https://design.gitlab.com/storybook?path=/story/base-filtered-search--default
@@ -1,26 +0,0 @@
1
- `GlFormDate` allows users to choose and input a date using a keyboard by by using
2
- browser implemented calendar controls, where available.
3
-
4
- `GlFormDate` extends `<input type="date">` with an `<output>` for audible announcement
5
- of selected date, in full format, by screen-readers.
6
-
7
- ## Usage
8
-
9
- On `change` the value is emitted in `YYYY-MM-DD` format.
10
-
11
- ## Accessibility
12
-
13
- `GlFormDate` is a form `<input>` and should have an accessible name using a `<label>`.
14
-
15
- `GlFormGroup` can be used to label `GlFormDate`.
16
-
17
- ```html
18
- <gl-form-group
19
- label="Enter date"
20
- label-for="input-id"
21
- >
22
- <gl-form-date
23
- id="input-id"
24
- />
25
- </gl-form-group>
26
- ```
@@ -1,41 +0,0 @@
1
- ## Usage
2
-
3
- `GlFormFields` provides form builder functionality for ease of building simple
4
- forms out of other GitLab UI form components.
5
-
6
- For a code example, look at the story. It covers usage of `mapValue`, `validators`,
7
- custom form elements, and `inputAttrs`.
8
-
9
- ## Fields type
10
-
11
- Each value of `fields` prop is expected to be a `FieldDefinition`. See below for the shape of this type:
12
-
13
- ```ts
14
- interface FieldDefinition<TValue> {
15
- // Label text to show for this field.
16
- label: string;
17
-
18
- // Collection of validator functions
19
- validators?: Array<(value: TValue) => string | undefined>;
20
-
21
- // Function that maps the inputted string value to the field's actual value
22
- // (e.g. a Number).
23
- mapValue?: (input: string) => TValue;
24
-
25
- // Properties that are passed to the actual input for this field.
26
- inputAttrs?: {};
27
-
28
- // Properties that are passed to the group wrapping this field.
29
- groupAttrs?: {};
30
- }
31
- ```
32
-
33
- ## Slots
34
-
35
- | Name | Description |
36
- | ------ | ------ |
37
- | `input(<fieldName>)` | Used to render components other than `GlFormInput`. |
38
- | `group(<fieldName>)-label` | Used for `label` slot on `GlFormGroup` of a specific field. |
39
- | `group(<fieldName>)-description` | Used for `description` slot on `GlFormGroup` of a specific field. |
40
- | `group(<fieldName>)-label-description` | Used for `label-description` slot on `GlFormGroup` of a specific field. |
41
- | `after(<fieldName>)` | Used to render content after `GlFormGroup` of a specific field. |
@@ -1 +0,0 @@
1
- Form group adds structure to forms.
@@ -1,67 +0,0 @@
1
- The `GlFormInputGroup` component allows one to build more advanced text
2
- input fields than generic `GlFormInput` when one needs that flexibility.
3
- Basic usage of the component:
4
-
5
- ```html
6
- <div>
7
- <gl-form-input-group>
8
- <template #prepend>
9
- <!-- Content to prepend your text input field -->
10
- </template>
11
- <template #append>
12
- <!-- Content to append your text input field -->
13
- </template>
14
- </gl-form-input-group>
15
- </div>
16
- ```
17
-
18
- One can use any other component (custom or `<gl-*>`) in both slots or
19
- not to use the slots at all. In the latter, the component will fallback
20
- to simple `GlFormInput`.
21
-
22
- ## Predefined options
23
-
24
- Sometimes custom text input from the user isn't desired. Instead, the
25
- user should pick one of the predefined options that will automatically
26
- populate the input field. Typically, such cases will also include an
27
- actionable button (like **Copy**) put into the `append` slot.
28
-
29
- To achieve this effect, the `GlFormInputGroup` component accepts an
30
- array of options in the form of `predefinedOptions` param. For example:
31
-
32
- ```javascript
33
- const optionValues = [
34
- { name: 'Option #1', value: 'Option #1 is selected!' },
35
- { name: 'Option #2', value: 'Option #2 is selected!' },
36
- ];
37
- ...
38
- <gl-form-input-group :predefined-options="optionValues" />
39
- ```
40
-
41
- This will tell `GlFormInputGroup` to render a dropdown in the `prepend`
42
- slot with all of the supplied options' `name`s. When one of the options
43
- is selected, the input field is automatically populated with the
44
- option's `value`. Check the "Examples" section below for "With
45
- predefined options" example.
46
-
47
- ### Pro tips
48
-
49
- Read some useful tips below about specific usage of the component.
50
-
51
- ### Readonly input
52
-
53
- Often you want to make sure user doesn't mess up the predefined content
54
- pasted into the input field. In this case, you can set `readonly`
55
- param to `true`. You can play with `Readonly` knob on the right.
56
-
57
- ### Preselect the text to copy
58
-
59
- If you set the `readonly` param on the `GlFormInputGroup` component,
60
- users will still be able to manually select the text and copy it.
61
- However, it's more user-friendly to preselect the text for the users if
62
- they click anywhere in the input field. This can be achieved by setting
63
- the `select-on-click` param to `true`. You can play with
64
- `Select text on click` knob on the right. Even better, try enabling
65
- `Readonly`, `Select text on click`, and `Switch to predefined input`
66
- altogether. And, probably, remove `Prepend text`. Or leave it. It's your
67
- call. :)
@@ -1 +0,0 @@
1
- GlInputGroupText components are used to add text to an input group.
@@ -1,3 +0,0 @@
1
- A bar chart is similar to a column chart where the the length of bars represents the data value.
2
- Although alike, they are cannot be interchangeably used. Bar charts are good for displaying large
3
- number of categories on the y-axis.
@@ -1,19 +0,0 @@
1
- ### ECharts Wrapper
2
-
3
- The chart component is a Vue component wrapper around [Apache ECharts](https://echarts.apache.org/en/api.html#echarts).
4
- The chart component accepts width and height props in order to allow the user to make it responsive.
5
-
6
- > Note: When implementing a chart type that does not already have a GitLab UI component, you can use
7
- > this component alonside the [ECharts options](https://echarts.apache.org/en/api.html#echarts) to
8
- > build your chart. Each type of chart should still follow the general guidelines in the
9
- > [pajamas documentation](https://design.gitlab.com/data-visualization/charts).
10
-
11
- ### EChart Lifecycle
12
-
13
- This component emits the following events during the ECharts lifecycle:
14
-
15
- - `created`: emitted after calling `echarts.init`
16
- - `updated`: emitted after calling `echarts.setOption`
17
-
18
- In all cases, the event payload is the
19
- [echart instance](https://echarts.apache.org/en/api.html#echartsInstance).
@@ -1,8 +0,0 @@
1
- Some layout problems can be encountered with this component. Specifically, when the gauge chart's
2
- axis labels or detail text have larger widths, they can overlap with the chart elements.
3
-
4
- Also, when the containing element of the gauge chart has either of a small calculated `width` and
5
- `height`, its axis width could become bulkier in relation to other chart elements. This is because
6
- at this time [eCharts only allows for setting the axis line width in absolute units](https://echarts.apache.org/en/option.html#series-gauge.axisLine.lineStyle.width).
7
-
8
- This issue is to be addressed by [https://gitlab.com/gitlab-org/gitlab-ui/-/issues/916](https://gitlab.com/gitlab-org/gitlab-ui/-/issues/916).
@@ -1,7 +0,0 @@
1
- ## Heatmaps
2
-
3
- **Note** This component uses `<gl-legend>`, which should allow a user to click on any data point(s)
4
- in the legend and make the corresponding data point(s) on the chart rendered disappear.
5
- _See [area chart](https://design.gitlab.com/storybook?path=/story/charts-area-chart--default)
6
- for an example_ For this particular chart, there is a [known issue](https://gitlab.com/gitlab-org/gitlab-ui/issues/352)
7
- with the functionality of the legend, where clicking on it does nothing.
@@ -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,7 +0,0 @@
1
- This is a basic line chart.
2
-
3
- ### Implementation Details
4
-
5
- This component wraps the GitLab UI `chart` component, which in turn wraps the ECharts component.
6
-
7
- See the [chart](./?path=/story/charts-chart--default) component for more info.
@@ -1 +0,0 @@
1
- Displays chart data series name as a label for chart legend, tooltip, etc.
@@ -1,3 +0,0 @@
1
- ### ECharts custom tooltip
2
-
3
- Uses GitLab UI's `popover` component in lieu of echart's tooltip.
@@ -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,8 +0,0 @@
1
-
2
- This is a basic sparkline chart.
3
-
4
- ### Implementation Details
5
-
6
- This component wraps the GitLab UI `chart` component, which in turn wraps the ECharts component.
7
-
8
- See the [chart](./?path=/story/charts-chart--default) component for more info.
@@ -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,4 +0,0 @@
1
- ### Buttons
2
-
3
- You can either have a primary button, a secondary button, or both.
4
- Buttons require both text a link in order for the button to render.
@@ -1,6 +0,0 @@
1
- Animated numbers provide a signifier that values are being changed.
2
-
3
- ## Usage
4
-
5
- The animated number component can be used with or without decimal places. Decimal places will
6
- not be rounded if chosen to be omitted.
@@ -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
- ```