mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature: css: --is-mobile: add
This commit is contained in:
parent
06cf0eebce
commit
a733d81441
5 changed files with 47 additions and 10 deletions
|
|
@ -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}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue