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