@aesthetic/style
Version:
A low-level, high-performance, atomic-based CSS-in-JS style engine.
52 lines (41 loc) • 1.45 kB
JavaScript
// Bundled with Packemon: https://packemon.dev
// Platform: browser, Support: stable, Format: esm
import { l as isImportRule, j as insertImportRule, k as isAtRule, h as insertAtRule, i as insertRule } from './bundle-30cd3868.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) {
const sheet = sheets[options.type ?? (options.media || options.supports ? 'conditions' : 'standard')];
if (isImportRule(rule)) {
return insertImportRule(sheet, rule);
}
if (isAtRule(rule)) {
return insertAtRule(sheet, rule);
}
return insertRule(sheet, rule, index);
},
sheets
};
}
export { createStyleElements as a, createSheetManager as c, getStyleElement as g };
//# sourceMappingURL=bundle-f0e57f15.js.map