twrnc
Version:
simple, expressive API for tailwindcss + react-native
35 lines (34 loc) • 1.03 kB
JavaScript
const plugin = (handler) => {
return { handler, config: undefined };
};
export default plugin;
export function getAddedUtilities(plugins) {
var _a;
return ((_a = plugins === null || plugins === void 0 ? void 0 : plugins.reduce((utils, plugin) => ({ ...utils, ...callPluginFunction(plugin.handler) }), {})) !== null && _a !== void 0 ? _a : {});
}
function callPluginFunction(pluginFn) {
let added = {};
pluginFn({
addUtilities: (utilities) => {
added = utilities;
},
...core,
});
return added;
}
function notImplemented(fn) {
throw new Error(`tailwindcss plugin function argument object prop "${fn}" not implemented`);
}
const core = {
addComponents: notImplemented,
addBase: notImplemented,
addVariant: notImplemented,
e: notImplemented,
prefix: notImplemented,
theme: notImplemented,
variants: notImplemented,
config: notImplemented,
corePlugins: notImplemented,
matchUtilities: notImplemented,
postcss: null,
};