This commit is contained in:
Andrey Sharshov
2025-11-16 18:54:31 +01:00
commit 9487728656
2342 changed files with 62687 additions and 0 deletions

19
utils/styles.js Normal file
View File

@@ -0,0 +1,19 @@
export const createStyles = (sheet) => {
return new Proxy(sheet, {
get: (target, property, receiver) => {
const medias = getMedia(target).filter((media) => {
if (!target[media].hasOwnProperty(property)) return false;
return matchMedia(media).matches;
});
if (medias.length === 0) return target[property];
return target[medias[medias.length-1]][property];
}
})
}
function getMedia(target) {
const properties = Object.keys(target);
const regex = new RegExp(/\(.*\)/);
return properties.filter((property) => regex.test(property))
}