How to use the @reshadow/core.KEYS.__use__ function in @reshadow/core

To help you get started, we’ve selected a few @reshadow/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lttb / reshadow / packages / vue / index.js View on Github external
const use = obj => {
    const result = {attrs: {}};
    result.attrs[KEYS.__use__] = obj;
    return result;
};
github lttb / reshadow / packages / runtime / parse.js View on Github external
const parse = (
    code,
    hash,
    {isMixin, elements, attributes, onlyNamespaced, classes},
) => {
    const options = {
        prefix: !isMixin,
    };

    stylis.set(options);

    const tokens = Object.create(null);
    tokens[KEYS.__use__] = {};
    const postfix = '_' + hash;

    const rules = Object.create(null);

    let skip = false;

    stylis.use(null)(function(
        context,
        content,
        selectors,
        parent,
        line,
        column,
    ) {
        if (skip) return;
github lttb / reshadow / packages / runtime / parse.js View on Github external
let name = attr[0];
                        let isModifier = false;
                        const value = attr[1];

                        if (name[0] === '|') {
                            name = name.slice(1);
                            isModifier = true;
                        } else if (name.slice(0, 4) === 'use|') {
                            name = name.slice(4);
                            isModifier = true;
                        } else if (onlyNamespaced && !isRoot) {
                            return match;
                        }

                        if (isModifier) {
                            tokens[KEYS.__use__][
                                name + '_' + (value || true)
                            ] = true;
                            name = USE_PREFIX + name;
                        }

                        if (value) {
                            className = '_' + name + '_' + value;
                        } else {
                            className = '_' + name;
                        }
                    }

                    if (!className) return match;

                    tokens[className] = className + postfix;
                    return '.' + tokens[className];
github lttb / reshadow / packages / runtime / index.js View on Github external
} else if (typeof value === 'object') {
                if (!(KEYS.__style__ in value)) {
                    value = css([obj2css(value)]);
                }

                Object.assign(mixinVars, value[KEYS.__style__]);
                mixinsHash += '_' + value[KEYS.__hash__];
                mixins[i] = value[KEYS.__css__];

                /** replace &{...} for mixins */
                if (mixins[i].slice(0, 2) === '&{') {
                    mixins[i] = mixins[i].slice(2, -1);
                }

                mixinTokens.push(value);
                Object.assign(mixinUses, value[KEYS.__use__]);
            } else {
                const name = '--' + hash + '_' + i;

                const matchUnit = str[i] && str[i].match(unitRe);
                if (matchUnit) {
                    const match = matchUnit[0];
                    value += matchUnit[1];
                    str[i] =
                        match[match.length - 1] + str[i].slice(match.length);
                }

                vars[name] = value;
            }
        }

        const cacheKey = stringHash(hash + mixinsHash).toString(36);