UNPKG

@twind/preset-tailwind

Version:

Tailwind CSS preset for twind

1 lines 2.57 kB
{"version":3,"file":"base.dev.cjs","sources":["../src/base.ts"],"sourcesContent":["/**\n * @module @twind/preset-tailwind/base\n */\n\nimport type { BaseTheme, Preset } from '@twind/core'\nimport type { TailwindTheme } from './types'\n\nimport theme from './baseTheme'\nimport preflight from './preflight'\nimport rules from './rules'\nimport variants from './variants'\n\nexport * from './types'\n\nexport interface TailwindPresetBaseOptions {\n colors?: BaseTheme['colors']\n /** Allows to disable to tailwind preflight (default: `false` eg include the tailwind preflight ) */\n disablePreflight?: boolean | undefined\n}\n\n/**\n * @experimental\n */\nexport default function presetTailwindBase({\n colors,\n disablePreflight,\n}: TailwindPresetBaseOptions = {}): Preset<TailwindTheme> {\n return {\n // allow other preflight to run\n preflight: disablePreflight ? undefined : preflight,\n theme: {\n ...theme,\n colors: {\n inherit: 'inherit',\n current: 'currentColor',\n transparent: 'transparent',\n black: '#000',\n white: '#fff',\n ...colors,\n },\n },\n variants,\n rules,\n finalize(rule) {\n // automatically add `content: ''` to before and after so you don’t have to specify it unless you want a different value\n if (\n // ignore global, preflight, and auto added rules\n rule.n &&\n // only if there are declarations\n rule.d &&\n // and it has a ::before or ::after selector\n rule.r.some((r) => /^&::(before|after)$/.test(r)) &&\n // there is no content property yet\n !/(^|;)content:/.test(rule.d)\n ) {\n return { ...rule, d: 'content:var(--tw-content);' + rule.d }\n }\n\n return rule\n },\n }\n}\n"],"names":["colors","disablePreflight","preflight","undefined","theme","inherit","current","transparent","black","white","variants","rules","finalize","rule","n","d","r","some","test"],"mappings":";;iBAgBE,kGAAA,GAAA;;CAOa,GAAA,SAA4B,EACzCA,OAAAA,EACAC,iBAAAA,EAC0B,GAAG,CAAA,CAAE,EAAyB;IACxD,OAAO;;QAELC,WAAWD,mBAAmBE,KAAAA,IAAYD,SAAS;QACnDE,OAAO;YACL,GAAGA,SAAK;YACRJ,QAAQ;gBACNK,SAAS;gBACTC,SAAS;gBACTC,aAAa;gBACbC,OAAO;gBACPC,OAAO;gBACP,GAAGT,MAAM;YACX;QACF;QACAU;QACAC;QACAC,UAASC,IAAI,EAAE;;YAEb,iDAAA;YAEEA,KAAKC,CAAC,IAAA,iCAAA;YAEND,KAAKE,CAAC,IAAA,4CAAA;YAENF,KAAKG,CAAC,CAACC,IAAI,CAAC,CAACD,IAAM,sBAAsBE,IAAI,CAACF,OAAAA,mCAAAA;YAE9C,CAAC,gBAAgBE,IAAI,CAACL,KAAKE,CAAC,IAErB;gBAAE,GAAGF,IAAI;gBAAEE,GAAG,+BAA+BF,KAAKE,CAAC;YAAC,IAGtDF,IAHsD;QAI/D;IACF;AACF"}