feature: css: --is-mobile: add

This commit is contained in:
coderiaser 2024-11-06 16:53:30 +02:00
parent 06cf0eebce
commit a733d81441
5 changed files with 47 additions and 10 deletions

View file

@ -520,6 +520,11 @@ module.exports.getPanelPosition = (panel) => {
return panel.dataset.name.replace('js-', '');
};
module.exports.getCSSVar = (name, {body = document.body} = {}) => {
const bodyStyle = getComputedStyle(body);
return bodyStyle.getPropertyValue(`--${name}`);
};
/** function getting panel active, or passive
* @param options = {active: true}
*/

View file

@ -4,6 +4,7 @@ require('css-modules-require-hook/preset');
const {test, stub} = require('supertape');
const mockRequire = require('mock-require');
const {getCSSVar} = require('./index');
const {reRequire, stopAll} = mockRequire;
global.CloudCmd = {};
@ -29,3 +30,32 @@ test('cloudcmd: client: dom: goToDirectory', async (t) => {
t.calledWith(changeDir, [path]);
t.end();
});
test('cloudcmd: client: dom: getCSSVar', (t) => {
const body = {};
const getPropertyValue = stub().returns(0);
global.getComputedStyle = stub().returns({
getPropertyValue,
});
const result = getCSSVar('hello', {body});
delete global.getComputedStyle;
t.notOk(result);
t.end();
});
test('cloudcmd: client: dom: getCSSVar: 1', (t) => {
const body = {};
const getPropertyValue = stub().returns(1);
global.getComputedStyle = stub().returns({
getPropertyValue,
});
const result = getCSSVar('hello', {body});
delete global.getComputedStyle;
t.ok(result);
t.end();
});