UNPKG

@aesthetic/style

Version:

A low-level, high-performance, atomic-based CSS-in-JS style engine.

59 lines (45 loc) 1.57 kB
// Bundled with Packemon: https://packemon.dev // Platform: browser, Support: stable, Format: lib 'use strict'; const engine = require('./bundle-cfb1e92a.js'); /* eslint-disable sort-keys */ function getStyleElement(type) { let element = document.querySelector(`#aesthetic-${type}`); if (!element) { element = document.createElement('style'); element.setAttribute('id', `aesthetic-${type}`); element.setAttribute('type', 'text/css'); element.setAttribute('media', 'screen'); element.dataset.aestheticType = type; document.head.append(element); } return element.sheet; } function createStyleElements() { return { // Order is important here! global: getStyleElement('global'), standard: getStyleElement('standard'), conditions: getStyleElement('conditions') }; } function createSheetManager(sheets) { return { insertRule(rule, options, index) { var _options$type; const sheet = sheets[(_options$type = options.type) !== null && _options$type !== void 0 ? _options$type : options.media || options.supports ? 'conditions' : 'standard']; if (engine.isImportRule(rule)) { return engine.insertImportRule(sheet, rule); } if (engine.isAtRule(rule)) { return engine.insertAtRule(sheet, rule); } return engine.insertRule(sheet, rule, index); }, sheets }; } exports.createSheetManager = createSheetManager; exports.createStyleElements = createStyleElements; exports.getStyleElement = getStyleElement; //# sourceMappingURL=bundle-f8b1a29f.js.map