2020-05-14 21:36:01 +05:30
|
|
|
// retrieve a HTML string for given SVG icon name and size in pixels
|
2020-02-12 07:23:18 +05:30
|
|
|
export function svg(name, size) {
|
2020-02-18 11:37:58 +05:30
|
|
|
return `<svg class="svg ${name}" width="${size}" height="${size}" aria-hidden="true"><use xlink:href="#${name}"/></svg>`;
|
2020-02-12 07:23:18 +05:30
|
|
|
}
|
2020-05-14 21:36:01 +05:30
|
|
|
|
|
|
|
// 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');
|
|
|
|
}
|