UNPKG

918 BJavaScriptView Raw
1import { BVConfigPlugin } from 'bootstrap-vue';
2import Vue from 'vue';
3import { tooltipDelay } from './utils/constants';
4
5const bFormTextGlobalConfig = {
6 textVariant: 'gl-muted',
7};
8
9const tooltipGlobalConfig = {
10 customClass: 'gl-tooltip',
11 delay: tooltipDelay,
12};
13
14/**
15 * Guard against nonexistent localStorage,
16 * or corrupted localStorage
17 *
18 * localStorage access is not possible in certain environments like
19 * - in iframe usage in Chrome if embedded on another domain
20 * - tests / node
21 */
22try {
23 const glTooltipDelay = localStorage.getItem('gl-tooltip-delay');
24
25 if (glTooltipDelay) {
26 tooltipGlobalConfig.delay = JSON.parse(glTooltipDelay);
27 }
28} catch (e) {
29 // localStorage doesn't exist (or the value is not properly formatted)
30}
31
32const setConfigs = () => {
33 Vue.use(BVConfigPlugin, {
34 BFormText: bFormTextGlobalConfig,
35 BTooltip: tooltipGlobalConfig,
36 });
37};
38
39export default setConfigs;