2020-05-14 16:06:01 +00:00
|
|
|
// retrieve a HTML string for given SVG icon name and size in pixels
|
2020-02-12 01:53:18 +00:00
|
|
|
export function svg(name, size) {
|
2020-02-18 06:07:58 +00:00
|
|
|
return `<svg class="svg ${name}" width="${size}" height="${size}" aria-hidden="true"><use xlink:href="#${name}"/></svg>`;
|
2020-02-12 01:53:18 +00:00
|
|
|
}
|
2020-05-14 16:06:01 +00:00
|
|
|
|
|
|
|
// transform /path/to/file.ext to file.ext
|
|
|
|
export function basename(path = '') {
|
|
|
|
return path ? path.replace(/^.*\//, '') : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
// transform /path/to/file.ext to .ext
|
|
|
|
export function extname(path = '') {
|
|
|
|
const [_, ext] = /.+(\.[^.]+)$/.exec(path) || [];
|
|
|
|
return ext || '';
|
|
|
|
}
|
|
|
|
|
|
|
|
// test whether a variable is an object
|
|
|
|
export function isObject(obj) {
|
|
|
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns whether a dark theme is enabled
|
|
|
|
export function isDarkTheme() {
|
|
|
|
return document.documentElement.classList.contains('theme-arc-green');
|
|
|
|
}
|
2020-05-21 02:00:43 +00:00
|
|
|
|
|
|
|
// removes duplicate elements in an array
|
|
|
|
export function uniq(arr) {
|
|
|
|
return Array.from(new Set(arr));
|
|
|
|
}
|