@twind/preset-typography
Advanced tools
Comparing version 1.0.0-next.38 to 1.0.0-next.39
# @twind/preset-typography | ||
## 1.0.0-next.39 | ||
### Patch Changes | ||
- Updated dependencies [[`774e2bb4`](https://github.com/tw-in-js/twind/commit/774e2bb4c7a019d76e55296e9af75fedc77bd054), [`a3b1bcba`](https://github.com/tw-in-js/twind/commit/a3b1bcba6269bc4a51b63041689baf58f6222b7f), [`0e2aa5c4`](https://github.com/tw-in-js/twind/commit/0e2aa5c4f07e5bca3bea37f864773f665935a263), [`9b5e3297`](https://github.com/tw-in-js/twind/commit/9b5e3297470f9d2bdbd4f540d819ee0f42e63595), [`0a63948e`](https://github.com/tw-in-js/twind/commit/0a63948e9f6c5f1bb8088ae6e21dc4bf215ee9e8), [`b2b7e40d`](https://github.com/tw-in-js/twind/commit/b2b7e40d39406b8d04f72cac6c980775e64df6c4), [`bdc0a7a1`](https://github.com/tw-in-js/twind/commit/bdc0a7a1c353990d0ef009af181f79c1134bfcec), [`f74163ba`](https://github.com/tw-in-js/twind/commit/f74163ba7310ece8d2de4a80586d19df419bfa86)]: | ||
- twind@1.0.0-next.39 | ||
## 1.0.0-next.38 | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@twind/preset-typography", | ||
"version": "1.0.0-next.38", | ||
"version": "1.0.0-next.39", | ||
"description": "Typography preset for twind", | ||
@@ -40,6 +40,6 @@ "type": "module", | ||
"engines": { | ||
"node": ">=12.4" | ||
"node": ">=14.15.0" | ||
}, | ||
"dependencies": { | ||
"@swc/helpers": "^0.3.3" | ||
"@swc/helpers": "^0.4.11" | ||
}, | ||
@@ -49,6 +49,6 @@ "main": "./preset-typography.cjs", | ||
".": { | ||
"types": "./preset-typography.d.ts", | ||
"esnext": "./preset-typography.esnext.js", | ||
"module": "./preset-typography.js", | ||
"script": "./preset-typography.global.js", | ||
"types": "./preset-typography.d.ts", | ||
"node": { | ||
@@ -58,3 +58,6 @@ "import": "./preset-typography.mjs", | ||
}, | ||
"default": "./preset-typography.js" | ||
"default": { | ||
"import": "./preset-typography.mjs", | ||
"require": "./preset-typography.cjs" | ||
} | ||
}, | ||
@@ -65,4 +68,4 @@ "./package.json": "./package.json" | ||
"peerDependencies": { | ||
"twind": "1.0.0-next.38", | ||
"typescript": "^4.4.0" | ||
"twind": "1.0.0-next.39", | ||
"typescript": "^4.8.4" | ||
}, | ||
@@ -76,4 +79,3 @@ "peerDependenciesMeta": { | ||
"tag": "next", | ||
"access": "public", | ||
"directory": "dist" | ||
"access": "public" | ||
}, | ||
@@ -84,4 +86,3 @@ "module": "./preset-typography.js", | ||
"jsdelivr": "./preset-typography.global.js", | ||
"types": "./preset-typography.d.ts", | ||
"readme": "# @twind/preset-typography [![MIT License](https://flat.badgen.net/github/license/tw-in-js/twind)](https://github.com/tw-in-js/twind/blob/next/LICENSE) [![Latest Release](https://flat.badgen.net/npm/v/@twind/preset-typography/next?icon=npm&label&cache=10800&color=blue)](https://www.npmjs.com/package/@twind/preset-typography/v/next) [![Github](https://flat.badgen.net/badge/icon/tw-in-js%2Ftwind%23preset-typography?icon=github&label)](https://github.com/tw-in-js/twind/tree/next/packages/preset-typography)\n\n---\n\n## READ THIS FIRST!\n\n**Twind v1 is still in beta. Expect bugs!**\n\n---\n\nA plugin that provides a set of `prose` classes you can use to add beautiful typographic defaults to any vanilla HTML you don't control, like HTML rendered from Markdown, or pulled from a CMS.\n\n> Based on [@tailwindcss/typography](https://github.com/tailwindlabs/tailwindcss-typography).\n\n## Installation\n\nInstall from npm:\n\n```sh\nnpm install twind@next @twind/preset-typography@next\n```\n\n## Installation\n\n**with [twind](https://github.com/tw-in-js/twind/tree/next/packages/twind)**\n\n```js\nimport { setup } from 'twind'\nimport presetTypography from '@twind/preset-typography'\n\nsetup({\n presets: [presetTypography(/* options */)],\n /* config */\n})\n```\n\n<details><summary>Usage with a script tag</summary>\n\n```html\n<head>\n <script\n src=\"https://cdn.jsdelivr.net/combine/npm/twind@next,npm/@twind/preset-typography@next\"\n crossorigin\n ></script>\n <script>\n twind.setup({\n presets: [twind.presetTypography(/* options */)],\n /* config */\n })\n </script>\n</head>\n```\n\n</details>\n\n**with [Twind CDN](https://github.com/tw-in-js/twind/tree/next/packages/cdn)** — a drop-in replacement for [Tailwind CSS Play CDN](https://tailwindcss.com/docs/installation/play-cdn)\n\n```html\n<head>\n <script\n src=\"https://cdn.jsdelivr.net/combine/npm/@twind/cdn@next,npm/@twind/preset-typography@next\"\n crossorigin\n ></script>\n <script>\n twind.setup({\n presets: [twind.presetTypography(/* options */)],\n /* config */\n })\n </script>\n</head>\n```\n\n## Usage\n\nTBD\n\nMost features of the [Tailwind CSSS › typography-plugin](https://tailwindcss.com/docs/typography-plugin) are implemented in the same way.\n\n## Differences\n\n- _Adding custom color themes_: every color from `theme.colors` is available via `prose-<color>`; the default color `gray` can be changed via `presetTypography({ defaultColor: '...'})`\n- _Customizing the CSS_: can be done using `presetTypography({ extend: { /* CSS object */ } })`\n" | ||
"types": "./preset-typography.d.ts" | ||
} |
import { toColorValue } from 'twind'; | ||
/** | ||
* The class name to use the typographic utilities. | ||
* To undo the styles to the elements, use it like | ||
* `not-${className}` which is by default `not-prose`. | ||
* | ||
* Note: `not` utility is only available in class. | ||
* | ||
* @defaultValue `prose` | ||
*/ /** | ||
* Default color to use. | ||
* | ||
* @defaultValue 'gray' | ||
*/ /** | ||
* @defaultValue '700' | ||
*/ /** | ||
* @defaultValue '900' | ||
*/ /** | ||
* @defaultValue '600' | ||
*/ /** | ||
* @defaultValue '900' | ||
*/ /** | ||
* @defaultValue '900' | ||
*/ /** | ||
* @defaultValue '500' | ||
*/ /** | ||
* @defaultValue '300' | ||
*/ /** | ||
* @defaultValue '200' | ||
*/ /** | ||
* @defaultValue '900' | ||
*/ /** | ||
* @defaultValue '200' | ||
*/ /** | ||
* @defaultValue '500' | ||
*/ /** | ||
* @defaultValue '900' | ||
*/ /** | ||
* @defaultValue '200' | ||
*/ /** | ||
* @defaultValue '800' | ||
*/ /** | ||
* @defaultValue '300' | ||
*/ /** | ||
* @defaultValue '200' | ||
*/ // invert colors (dark mode) | ||
/** | ||
* @defaultValue '300' | ||
*/ /** | ||
* @defaultValue '#fff' | ||
*/ /** | ||
* @defaultValue '400' | ||
*/ /** | ||
* @defaultValue '#fff' | ||
*/ /** | ||
* @defaultValue '#fff' | ||
*/ /** | ||
* @defaultValue '400' | ||
*/ /** | ||
* @defaultValue '600' | ||
*/ /** | ||
* @defaultValue '700' | ||
*/ /** | ||
* @defaultValue '100' | ||
*/ /** | ||
* @defaultValue '700' | ||
*/ /** | ||
* @defaultValue '400' | ||
*/ /** | ||
* @defaultValue '#fff' | ||
*/ /** | ||
* @defaultValue '300' | ||
*/ /** | ||
* @defaultValue 'rgb(0 0 0 / 50%)' | ||
*/ /** | ||
* @defaultValue '600' | ||
*/ /** | ||
* @defaultValue '700' | ||
*/ /** | ||
* Extend or override CSS selectors with CSS declaration block. | ||
* | ||
* @defaultValue undefined | ||
*/ /** | ||
* Twind Preset for Typography | ||
@@ -143,10 +224,7 @@ * | ||
'hr' | ||
], | ||
].map(([name, selector1 = name])=>[ | ||
] | ||
].map(([name, selector = name])=>[ | ||
`${className}-${name}`, | ||
(_, context)=>adjustSelector(className, selector1[0] == '.' ? '.' + context.e(context.h(selector1.slice(1))) : selector1, context, (selector)=>`& :is(${selector.trim()})` | ||
) | ||
, | ||
] | ||
), | ||
(_, context)=>adjustSelector(className, selector[0] == '.' ? '.' + context.e(context.h(selector.slice(1))) : selector, context, (selector)=>`& :is(${selector.trim()})`) | ||
]), | ||
rules: [ | ||
@@ -183,3 +261,3 @@ // marker classes lead and not-prose | ||
} | ||
}, | ||
} | ||
], | ||
@@ -194,3 +272,3 @@ // for type scale: prose-xl | ||
}; | ||
}, | ||
} | ||
], | ||
@@ -482,3 +560,3 @@ // for colors: prose-sky | ||
}), | ||
adjustSelectors(className, context, extend), | ||
adjustSelectors(className, context, extend) | ||
], | ||
@@ -491,4 +569,3 @@ '@layer components': { | ||
}) | ||
, | ||
], | ||
] | ||
] | ||
@@ -508,17 +585,17 @@ }; | ||
}; | ||
for(const key2 in colors){ | ||
const shade = colors[key2]; | ||
if (key2 != 'dark' && shade) { | ||
set(key2, shade, properties); | ||
for(const key in colors){ | ||
const shade = colors[key]; | ||
if (key != 'dark' && shade) { | ||
set(key, shade, properties); | ||
} | ||
} | ||
for(const key1 in colors.dark || {}){ | ||
const shade = colors.dark[key1]; | ||
if (shade) { | ||
const shade1 = colors.dark[key1]; | ||
if (shade1) { | ||
if (colors.dark) { | ||
// explicit dark colors - need to use `dark:prose-invert` | ||
set('invert-' + key1, shade, properties); | ||
set('invert-' + key1, shade1, properties); | ||
} else { | ||
// auto dark colors | ||
set(key1, shade, darkProperties); | ||
set(key1, shade1, darkProperties); | ||
} | ||
@@ -534,16 +611,15 @@ } | ||
} | ||
}function adjustSelectors(className, context, css) { | ||
} | ||
function adjustSelectors(className, context, css) { | ||
const result = {}; | ||
for(const selector2 in css){ | ||
result[adjustSelector(className, selector2, context, (selector)=>`.${context.e(context.h(className))}${selector}` | ||
)] = css[selector2]; | ||
for(const selector in css){ | ||
result[adjustSelector(className, selector, context, (selector)=>`.${context.e(context.h(className))}${selector}`)] = css[selector]; | ||
} | ||
return result; | ||
} | ||
function adjustSelector(className, selector3, { e , h }, replace) { | ||
function adjustSelector(className, selector, { e , h }, replace) { | ||
// pseudo elements can't be matched | ||
return selector3.replace(// 1. if there no pseudo use whole selector | ||
return selector.replace(// 1. if there no pseudo use whole selector | ||
// 2. if there are pseudo replace prefix | ||
/^[^>:]+$|(>)?((?:[^:,]+(?::[\w-]+)?)|:[\w-]+)(::[\w-]+)?/g, (_, prefix = ' ', selector = _, pseudoElement = '')=>replace(`${prefix}:where(${selector}):not(:where(.${e(h('not-' + className))} *))${pseudoElement}`) | ||
); | ||
/^[^>:]+$|(>)?((?:[^:,]+(?::[\w-]+)?)|:[\w-]+)(::[\w-]+)?/g, (_, prefix = ' ', selector = _, pseudoElement = '')=>replace(`${prefix}:where(${selector}):not(:where(.${e(h('not-' + className))} *))${pseudoElement}`)); | ||
} | ||
@@ -550,0 +626,0 @@ function getFontSize(_) { |
@@ -1,1 +0,1 @@ | ||
this.twind=this.twind||{},this.twind.presetTypography=(function(a){"use strict";function b(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function c(a){for(var c=1;c<arguments.length;c++){var d=null!=arguments[c]?arguments[c]:{},e=Object.keys(d);"function"==typeof Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(d).filter(function(a){return Object.getOwnPropertyDescriptor(d,a).enumerable}))),e.forEach(function(c){b(a,c,d[c])})}return a}function d(a,b,c){const d={};for(const f in c)d[e(a,f,b,c=>`.${b.e(b.h(a))}${c}`)]=c[f];return d}function e(a,b,{e:c,h:d},e){return b.replace(/^[^>:]+$|(>)?((?:[^:,]+(?::[\w-]+)?)|:[\w-]+)(::[\w-]+)?/g,(b,f=" ",g=b,h="")=>e(`${f}:where(${g}):not(:where(.${c(d("not-"+a))} *))${h}`))}function f(a){return a?"string"==typeof a?{fontSize:a}:c({fontSize:a[0]},"string"==typeof a[1]?{lineHeight:a[1]}:a[1]):void 0}function g(a,b){return`${(a/b).toFixed(3).replace(/^0|\.?0+$/g,"")}em`}return function({className:b="prose",defaultColor:h="gray",extend:i={},colors:j={}}={}){function k(b,c){const d={},e={},f=(d,f,g)=>{const h=c.theme(`colors.${b}.${f}`,f);g["--tw-prose-"+d]=a.toColorValue(h);const i=g!=e&&c.d("colors",`${b}.${f}`,h);i&&(e["--tw-prose-"+d]=a.toColorValue(i))};for(const g in j){const h=j[g];"dark"!=g&&h&&f(g,h,d)}for(const i in j.dark||{}){const k=j.dark[i];k&&(j.dark?f("invert-"+i,k,d):f(i,k,e))}return Object.keys(d).length?{"@layer defaults":{"&":d,[c.v("dark")]:e}}:void 0}return j=c({body:"700",headings:"900",lead:"600",links:"900",bold:"900",counters:"500",bullets:"300",hr:"200",quotes:"900","quote-borders":"200",captions:"500",code:"900","pre-code":"200","pre-bg":"800","th-borders":"300","td-borders":"200"},j,{dark:null===j.dark?null:c({body:"300",headings:"#fff",lead:"400",links:"#fff",bold:"#fff",counters:"400",bullets:"600",hr:"700",quotes:"100","quote-borders":"700",captions:"400",code:"#fff","pre-code":"300","pre-bg":"rgb(0 0 0 / 50%)","th-borders":"600","td-borders":"700"},j.dark)}),{variants:[["headings","h1,h2,h3,h4,th"],["lead",".lead"],["h1"],["h2"],["h3"],["h4"],["p"],["a"],["blockquote"],["figure"],["figcaption"],["strong"],["em"],["code"],["pre"],["ol"],["ul"],["li"],["table"],["thead"],["tr"],["th"],["td"],["img"],["video"],["hr"],].map(([a,c=a])=>[`${b}-${a}`,(a,d)=>e(b,"."==c[0]?"."+d.e(d.h(c.slice(1))):c,d,a=>`& :is(${a.trim()})`),]),rules:[[`(lead|not-${b})`,({1:a},{h:b})=>[{c:b(a)}]],[`${b}-invert`,{"@layer defaults":{"--tw-prose-body":"var(--tw-prose-invert-body)","--tw-prose-headings":"var(--tw-prose-invert-headings)","--tw-prose-lead":"var(--tw-prose-invert-lead)","--tw-prose-links":"var(--tw-prose-invert-links)","--tw-prose-bold":"var(--tw-prose-invert-bold)","--tw-prose-counters":"var(--tw-prose-invert-counters)","--tw-prose-bullets":"var(--tw-prose-invert-bullets)","--tw-prose-hr":"var(--tw-prose-invert-hr)","--tw-prose-quotes":"var(--tw-prose-invert-quotes)","--tw-prose-quote-borders":"var(--tw-prose-invert-quote-borders)","--tw-prose-captions":"var(--tw-prose-invert-captions)","--tw-prose-code":"var(--tw-prose-invert-code)","--tw-prose-pre-code":"var(--tw-prose-invert-pre-code)","--tw-prose-pre-bg":"var(--tw-prose-invert-pre-bg)","--tw-prose-th-borders":"var(--tw-prose-invert-th-borders)","--tw-prose-td-borders":"var(--tw-prose-invert-td-borders)"}},],[b+"-",({$$:a},b)=>{const c=f(b.theme("fontSize",a));return c&&{"@layer components":c}},],[b+"-",({$$:a},b)=>k(a,b)],[b,(a,e)=>c({},k(h,e),{"@layer base":[d(b,e,{a:{color:"var(--tw-prose-links)",textDecorationLine:"underline",fontWeight:"500"},strong:{color:"var(--tw-prose-bold)",fontWeight:"600"},ul:{listStyleType:"disc"},ol:{listStyleType:"decimal"},"ol[type=\"A\"]":{listStyleType:"upper-alpha"},"ol[type=\"a\"]":{listStyleType:"lower-alpha"},"ol[type=\"A\" s]":{listStyleType:"upper-alpha"},"ol[type=\"a\" s]":{listStyleType:"lower-alpha"},"ol[type=\"I\"]":{listStyleType:"upper-roman"},"ol[type=\"i\"]":{listStyleType:"lower-roman"},"ol[type=\"I\" s]":{listStyleType:"upper-roman"},"ol[type=\"i\" s]":{listStyleType:"lower-roman"},"ol[type=\"1\"]":{listStyleType:"decimal"},"ol,ul":{marginTop:g(20,16),marginBottom:g(20,16),paddingLeft:g(26,16)},li:{marginTop:g(8,16),marginBottom:g(8,16)},"ol>li,ul>li":{paddingLeft:g(6,16)},">ul>li p":{marginTop:g(12,16),marginBottom:g(12,16)},">ul>li>*:first-child,>ol>li>*:last-child":{marginTop:g(20,16)},">ul>li>*:last-child,>ol>li>*:last-child":{marginBottom:g(20,16)},"ol>li::marker":{fontWeight:"400",color:"var(--tw-prose-counters)"},"ul>li::marker":{color:"var(--tw-prose-bullets)"},"ul ul,ul ol,ol ul,ol ol":{marginTop:g(12,16),marginBottom:g(12,16)},hr:{borderColor:"var(--tw-prose-hr)",borderTopWidth:"1",marginTop:g(48,16),marginBottom:g(48,16)},blockquote:{marginTop:g(32,20),marginBottom:g(32,20),paddingLeft:g(20,20),fontWeight:"500",fontStyle:"italic",color:"var(--tw-prose-quotes)",borderLeftWidth:"0.25rem",borderLeftColor:"var(--tw-prose-quote-borders)",quotes:"\"\\201C\"\"\\201D\"\"\\2018\"\"\\2019\""},"blockquote p:first-of-type::before":{content:"open-quote"},"blockquote p:last-of-type::after":{content:"close-quote"},p:{marginTop:g(20,16),marginBottom:g(20,16)},h1:{color:"var(--tw-prose-headings)",fontWeight:"800",fontSize:g(36,16),marginTop:"0",marginBottom:g(32,36),lineHeight:1.15},"h1 strong":{fontWeight:"900"},h2:{color:"var(--tw-prose-headings)",fontWeight:"700",fontSize:g(24,16),marginTop:g(48,24),marginBottom:g(24,24),lineHeight:"1.35"},"h2 strong":{fontWeight:"800"},h3:{color:"var(--tw-prose-headings)",fontWeight:"600",fontSize:g(20,16),marginTop:g(32,20),marginBottom:g(12,20),lineHeight:"1.6"},"h3 strong":{fontWeight:"700"},h4:{color:"var(--tw-prose-headings)",fontWeight:"600",marginTop:g(24,16),marginBottom:g(8,16),lineHeight:"1.5"},"h4 strong":{fontWeight:"700"},"hr+*,h2+*,h3+*,h4+*":{marginTop:"0"},"img,video,figure":{marginTop:g(32,16),marginBottom:g(32,16)},"figure>*":{marginTop:"0",marginBottom:"0"},figcaption:{color:"var(--tw-prose-captions)",fontSize:g(14,16),lineHeight:"1.4",marginTop:g(12,14)},code:{color:"var(--tw-prose-code)",fontWeight:"600",fontSize:g(14,16)},"code::before,code::after":{content:"\"`\""},"h2 code":{fontSize:g(21,24)},"h3 code":{fontSize:g(18,20)},"a code":{color:"var(--tw-prose-links)"},pre:{color:"var(--tw-prose-pre-code)",backgroundColor:"var(--tw-prose-pre-bg)",overflowX:"auto",fontWeight:"400",fontSize:g(14,16),lineHeight:"1.7",marginTop:g(24,14),marginBottom:g(24,14),borderRadius:"0.375rem",paddingTop:g(12,14),paddingRight:g(16,14),paddingBottom:g(12,14),paddingLeft:g(16,14)},"pre code":{backgroundColor:"transparent",borderWidth:"0",borderRadius:"0",padding:"0",fontWeight:"inherit",color:"inherit",fontSize:"inherit",fontFamily:"inherit",lineHeight:"inherit"},"pre code::before":{content:"none"},"pre code::after":{content:"none"},table:{width:"100%",tableLayout:"auto",textAlign:"left",marginTop:g(32,16),marginBottom:g(32,16),fontSize:g(14,16),lineHeight:"1.7"},thead:{borderBottomWidth:"1px",borderBottomColor:"var(--tw-prose-th-borders)"},"thead th":{color:"var(--tw-prose-headings)",fontWeight:"600",verticalAlign:"bottom",paddingRight:g(8,14),paddingBottom:g(8,14),paddingLeft:g(8,14)},"thead th:first-child":{paddingLeft:"0"},"thead th:last-child":{paddingRight:"0"},"tbody tr":{borderBottomWidth:"1px",borderBottomColor:"var(--tw-prose-td-borders)"},"tbody tr:last-child":{borderBottomWidth:"0"},"tbody td":{verticalAlign:"baseline",paddingTop:g(8,14),paddingRight:g(8,14),paddingBottom:g(8,14),paddingLeft:g(8,14)},"tbody td:first-child":{paddingLeft:"0"},"tbody td:last-child":{paddingRight:"0"},[`.${e.e(e.h("lead"))}`]:{color:"var(--tw-prose-lead)",fontSize:g(20,16),lineHeight:"1.6",marginTop:g(24,20),marginBottom:g(24,20)},">:first-child":{marginTop:"0"},">:last-child":{marginBottom:"0"}}),d(b,e,i),],"@layer components":c({},f(e.theme("fontSize","base")),{color:"var(--tw-prose-body)",maxWidth:"theme(max-w.prose, 65ch)"})}),],]}}})(twind)//# sourceMappingURL=preset-typography.global.js.map | ||
this.twind=this.twind||{},this.twind.presetTypography=function(t){"use strict";function e(){return(e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(t[r]=o[r])}return t}).apply(this,arguments)}function o(){return e.apply(this,arguments)}function r(t,e,o){let r={};for(let n in o)r[i(t,n,e,o=>`.${e.e(e.h(t))}${o}`)]=o[n];return r}function i(t,e,{e:o,h:r},i){return e.replace(/^[^>:]+$|(>)?((?:[^:,]+(?::[\w-]+)?)|:[\w-]+)(::[\w-]+)?/g,(e,n=" ",l=e,a="")=>i(`${n}:where(${l}):not(:where(.${o(r("not-"+t))} *))${a}`))}function n(t){return t?"string"==typeof t?{fontSize:t}:o({fontSize:t[0]},"string"==typeof t[1]?{lineHeight:t[1]}:t[1]):void 0}function l(t,e){return`${(t/e).toFixed(3).replace(/^0|\.?0+$/g,"")}em`}return function({className:e="prose",defaultColor:a="gray",extend:p={},colors:d={}}={}){return d=o({body:"700",headings:"900",lead:"600",links:"900",bold:"900",counters:"500",bullets:"300",hr:"200",quotes:"900","quote-borders":"200",captions:"500",code:"900","pre-code":"200","pre-bg":"800","th-borders":"300","td-borders":"200"},d,{dark:null===d.dark?null:o({body:"300",headings:"#fff",lead:"400",links:"#fff",bold:"#fff",counters:"400",bullets:"600",hr:"700",quotes:"100","quote-borders":"700",captions:"400",code:"#fff","pre-code":"300","pre-bg":"rgb(0 0 0 / 50%)","th-borders":"600","td-borders":"700"},d.dark)}),{variants:[["headings","h1,h2,h3,h4,th"],["lead",".lead"],["h1"],["h2"],["h3"],["h4"],["p"],["a"],["blockquote"],["figure"],["figcaption"],["strong"],["em"],["code"],["pre"],["ol"],["ul"],["li"],["table"],["thead"],["tr"],["th"],["td"],["img"],["video"],["hr"]].map(([t,o=t])=>[`${e}-${t}`,(t,r)=>i(e,"."==o[0]?"."+r.e(r.h(o.slice(1))):o,r,t=>`& :is(${t.trim()})`)]),rules:[[`(lead|not-${e})`,({1:t},{h:e})=>[{c:e(t)}]],[`${e}-invert`,{"@layer defaults":{"--tw-prose-body":"var(--tw-prose-invert-body)","--tw-prose-headings":"var(--tw-prose-invert-headings)","--tw-prose-lead":"var(--tw-prose-invert-lead)","--tw-prose-links":"var(--tw-prose-invert-links)","--tw-prose-bold":"var(--tw-prose-invert-bold)","--tw-prose-counters":"var(--tw-prose-invert-counters)","--tw-prose-bullets":"var(--tw-prose-invert-bullets)","--tw-prose-hr":"var(--tw-prose-invert-hr)","--tw-prose-quotes":"var(--tw-prose-invert-quotes)","--tw-prose-quote-borders":"var(--tw-prose-invert-quote-borders)","--tw-prose-captions":"var(--tw-prose-invert-captions)","--tw-prose-code":"var(--tw-prose-invert-code)","--tw-prose-pre-code":"var(--tw-prose-invert-pre-code)","--tw-prose-pre-bg":"var(--tw-prose-invert-pre-bg)","--tw-prose-th-borders":"var(--tw-prose-invert-th-borders)","--tw-prose-td-borders":"var(--tw-prose-invert-td-borders)"}}],[e+"-",({$$:t},e)=>{let o=n(e.theme("fontSize",t));return o&&{"@layer components":o}}],[e+"-",({$$:t},e)=>s(t,e)],[e,(t,i)=>o({},s(a,i),{"@layer base":[r(e,i,{a:{color:"var(--tw-prose-links)",textDecorationLine:"underline",fontWeight:"500"},strong:{color:"var(--tw-prose-bold)",fontWeight:"600"},ul:{listStyleType:"disc"},ol:{listStyleType:"decimal"},'ol[type="A"]':{listStyleType:"upper-alpha"},'ol[type="a"]':{listStyleType:"lower-alpha"},'ol[type="A" s]':{listStyleType:"upper-alpha"},'ol[type="a" s]':{listStyleType:"lower-alpha"},'ol[type="I"]':{listStyleType:"upper-roman"},'ol[type="i"]':{listStyleType:"lower-roman"},'ol[type="I" s]':{listStyleType:"upper-roman"},'ol[type="i" s]':{listStyleType:"lower-roman"},'ol[type="1"]':{listStyleType:"decimal"},"ol,ul":{marginTop:l(20,16),marginBottom:l(20,16),paddingLeft:l(26,16)},li:{marginTop:l(8,16),marginBottom:l(8,16)},"ol>li,ul>li":{paddingLeft:l(6,16)},">ul>li p":{marginTop:l(12,16),marginBottom:l(12,16)},">ul>li>*:first-child,>ol>li>*:last-child":{marginTop:l(20,16)},">ul>li>*:last-child,>ol>li>*:last-child":{marginBottom:l(20,16)},"ol>li::marker":{fontWeight:"400",color:"var(--tw-prose-counters)"},"ul>li::marker":{color:"var(--tw-prose-bullets)"},"ul ul,ul ol,ol ul,ol ol":{marginTop:l(12,16),marginBottom:l(12,16)},hr:{borderColor:"var(--tw-prose-hr)",borderTopWidth:"1",marginTop:l(48,16),marginBottom:l(48,16)},blockquote:{marginTop:l(32,20),marginBottom:l(32,20),paddingLeft:l(20,20),fontWeight:"500",fontStyle:"italic",color:"var(--tw-prose-quotes)",borderLeftWidth:"0.25rem",borderLeftColor:"var(--tw-prose-quote-borders)",quotes:'"\\201C""\\201D""\\2018""\\2019"'},"blockquote p:first-of-type::before":{content:"open-quote"},"blockquote p:last-of-type::after":{content:"close-quote"},p:{marginTop:l(20,16),marginBottom:l(20,16)},h1:{color:"var(--tw-prose-headings)",fontWeight:"800",fontSize:l(36,16),marginTop:"0",marginBottom:l(32,36),lineHeight:1.15},"h1 strong":{fontWeight:"900"},h2:{color:"var(--tw-prose-headings)",fontWeight:"700",fontSize:l(24,16),marginTop:l(48,24),marginBottom:l(24,24),lineHeight:"1.35"},"h2 strong":{fontWeight:"800"},h3:{color:"var(--tw-prose-headings)",fontWeight:"600",fontSize:l(20,16),marginTop:l(32,20),marginBottom:l(12,20),lineHeight:"1.6"},"h3 strong":{fontWeight:"700"},h4:{color:"var(--tw-prose-headings)",fontWeight:"600",marginTop:l(24,16),marginBottom:l(8,16),lineHeight:"1.5"},"h4 strong":{fontWeight:"700"},"hr+*,h2+*,h3+*,h4+*":{marginTop:"0"},"img,video,figure":{marginTop:l(32,16),marginBottom:l(32,16)},"figure>*":{marginTop:"0",marginBottom:"0"},figcaption:{color:"var(--tw-prose-captions)",fontSize:l(14,16),lineHeight:"1.4",marginTop:l(12,14)},code:{color:"var(--tw-prose-code)",fontWeight:"600",fontSize:l(14,16)},"code::before,code::after":{content:'"`"'},"h2 code":{fontSize:l(21,24)},"h3 code":{fontSize:l(18,20)},"a code":{color:"var(--tw-prose-links)"},pre:{color:"var(--tw-prose-pre-code)",backgroundColor:"var(--tw-prose-pre-bg)",overflowX:"auto",fontWeight:"400",fontSize:l(14,16),lineHeight:"1.7",marginTop:l(24,14),marginBottom:l(24,14),borderRadius:"0.375rem",paddingTop:l(12,14),paddingRight:l(16,14),paddingBottom:l(12,14),paddingLeft:l(16,14)},"pre code":{backgroundColor:"transparent",borderWidth:"0",borderRadius:"0",padding:"0",fontWeight:"inherit",color:"inherit",fontSize:"inherit",fontFamily:"inherit",lineHeight:"inherit"},"pre code::before":{content:"none"},"pre code::after":{content:"none"},table:{width:"100%",tableLayout:"auto",textAlign:"left",marginTop:l(32,16),marginBottom:l(32,16),fontSize:l(14,16),lineHeight:"1.7"},thead:{borderBottomWidth:"1px",borderBottomColor:"var(--tw-prose-th-borders)"},"thead th":{color:"var(--tw-prose-headings)",fontWeight:"600",verticalAlign:"bottom",paddingRight:l(8,14),paddingBottom:l(8,14),paddingLeft:l(8,14)},"thead th:first-child":{paddingLeft:"0"},"thead th:last-child":{paddingRight:"0"},"tbody tr":{borderBottomWidth:"1px",borderBottomColor:"var(--tw-prose-td-borders)"},"tbody tr:last-child":{borderBottomWidth:"0"},"tbody td":{verticalAlign:"baseline",paddingTop:l(8,14),paddingRight:l(8,14),paddingBottom:l(8,14),paddingLeft:l(8,14)},"tbody td:first-child":{paddingLeft:"0"},"tbody td:last-child":{paddingRight:"0"},[`.${i.e(i.h("lead"))}`]:{color:"var(--tw-prose-lead)",fontSize:l(20,16),lineHeight:"1.6",marginTop:l(24,20),marginBottom:l(24,20)},">:first-child":{marginTop:"0"},">:last-child":{marginBottom:"0"}}),r(e,i,p)],"@layer components":o({},n(i.theme("fontSize","base")),{color:"var(--tw-prose-body)",maxWidth:"theme(max-w.prose, 65ch)"})})]]};function s(e,o){let r={},i={},n=(r,n,l)=>{let a=o.theme(`colors.${e}.${n}`,n);l["--tw-prose-"+r]=t.toColorValue(a);let p=l!=i&&o.d("colors",`${e}.${n}`,a);p&&(i["--tw-prose-"+r]=t.toColorValue(p))};for(let l in d){let a=d[l];"dark"!=l&&a&&n(l,a,r)}for(let p in d.dark||{}){let s=d.dark[p];s&&(d.dark?n("invert-"+p,s,r):n(p,s,i))}return Object.keys(r).length?{"@layer defaults":{"&":r,[o.v("dark")]:i}}:void 0}}}(twind);//# sourceMappingURL=preset-typography.global.js.map |
import { toColorValue } from 'twind'; | ||
/** | ||
* The class name to use the typographic utilities. | ||
* To undo the styles to the elements, use it like | ||
* `not-${className}` which is by default `not-prose`. | ||
* | ||
* Note: `not` utility is only available in class. | ||
* | ||
* @defaultValue `prose` | ||
*/ /** | ||
* Default color to use. | ||
* | ||
* @defaultValue 'gray' | ||
*/ /** | ||
* @defaultValue '700' | ||
*/ /** | ||
* @defaultValue '900' | ||
*/ /** | ||
* @defaultValue '600' | ||
*/ /** | ||
* @defaultValue '900' | ||
*/ /** | ||
* @defaultValue '900' | ||
*/ /** | ||
* @defaultValue '500' | ||
*/ /** | ||
* @defaultValue '300' | ||
*/ /** | ||
* @defaultValue '200' | ||
*/ /** | ||
* @defaultValue '900' | ||
*/ /** | ||
* @defaultValue '200' | ||
*/ /** | ||
* @defaultValue '500' | ||
*/ /** | ||
* @defaultValue '900' | ||
*/ /** | ||
* @defaultValue '200' | ||
*/ /** | ||
* @defaultValue '800' | ||
*/ /** | ||
* @defaultValue '300' | ||
*/ /** | ||
* @defaultValue '200' | ||
*/ // invert colors (dark mode) | ||
/** | ||
* @defaultValue '300' | ||
*/ /** | ||
* @defaultValue '#fff' | ||
*/ /** | ||
* @defaultValue '400' | ||
*/ /** | ||
* @defaultValue '#fff' | ||
*/ /** | ||
* @defaultValue '#fff' | ||
*/ /** | ||
* @defaultValue '400' | ||
*/ /** | ||
* @defaultValue '600' | ||
*/ /** | ||
* @defaultValue '700' | ||
*/ /** | ||
* @defaultValue '100' | ||
*/ /** | ||
* @defaultValue '700' | ||
*/ /** | ||
* @defaultValue '400' | ||
*/ /** | ||
* @defaultValue '#fff' | ||
*/ /** | ||
* @defaultValue '300' | ||
*/ /** | ||
* @defaultValue 'rgb(0 0 0 / 50%)' | ||
*/ /** | ||
* @defaultValue '600' | ||
*/ /** | ||
* @defaultValue '700' | ||
*/ /** | ||
* Extend or override CSS selectors with CSS declaration block. | ||
* | ||
* @defaultValue undefined | ||
*/ /** | ||
* Twind Preset for Typography | ||
@@ -143,10 +224,7 @@ * | ||
'hr' | ||
], | ||
].map(([name, selector1 = name])=>[ | ||
] | ||
].map(([name, selector = name])=>[ | ||
`${className}-${name}`, | ||
(_, context)=>adjustSelector(className, selector1[0] == '.' ? '.' + context.e(context.h(selector1.slice(1))) : selector1, context, (selector)=>`& :is(${selector.trim()})` | ||
) | ||
, | ||
] | ||
), | ||
(_, context)=>adjustSelector(className, selector[0] == '.' ? '.' + context.e(context.h(selector.slice(1))) : selector, context, (selector)=>`& :is(${selector.trim()})`) | ||
]), | ||
rules: [ | ||
@@ -183,3 +261,3 @@ // marker classes lead and not-prose | ||
} | ||
}, | ||
} | ||
], | ||
@@ -194,3 +272,3 @@ // for type scale: prose-xl | ||
}; | ||
}, | ||
} | ||
], | ||
@@ -482,3 +560,3 @@ // for colors: prose-sky | ||
}), | ||
adjustSelectors(className, context, extend), | ||
adjustSelectors(className, context, extend) | ||
], | ||
@@ -491,4 +569,3 @@ '@layer components': { | ||
}) | ||
, | ||
], | ||
] | ||
] | ||
@@ -508,17 +585,17 @@ }; | ||
}; | ||
for(const key2 in colors){ | ||
const shade = colors[key2]; | ||
if (key2 != 'dark' && shade) { | ||
set(key2, shade, properties); | ||
for(const key in colors){ | ||
const shade = colors[key]; | ||
if (key != 'dark' && shade) { | ||
set(key, shade, properties); | ||
} | ||
} | ||
for(const key1 in colors.dark || {}){ | ||
const shade = colors.dark[key1]; | ||
if (shade) { | ||
const shade1 = colors.dark[key1]; | ||
if (shade1) { | ||
if (colors.dark) { | ||
// explicit dark colors - need to use `dark:prose-invert` | ||
set('invert-' + key1, shade, properties); | ||
set('invert-' + key1, shade1, properties); | ||
} else { | ||
// auto dark colors | ||
set(key1, shade, darkProperties); | ||
set(key1, shade1, darkProperties); | ||
} | ||
@@ -534,16 +611,15 @@ } | ||
} | ||
}function adjustSelectors(className, context, css) { | ||
} | ||
function adjustSelectors(className, context, css) { | ||
const result = {}; | ||
for(const selector2 in css){ | ||
result[adjustSelector(className, selector2, context, (selector)=>`.${context.e(context.h(className))}${selector}` | ||
)] = css[selector2]; | ||
for(const selector in css){ | ||
result[adjustSelector(className, selector, context, (selector)=>`.${context.e(context.h(className))}${selector}`)] = css[selector]; | ||
} | ||
return result; | ||
} | ||
function adjustSelector(className, selector3, { e , h }, replace) { | ||
function adjustSelector(className, selector, { e , h }, replace) { | ||
// pseudo elements can't be matched | ||
return selector3.replace(// 1. if there no pseudo use whole selector | ||
return selector.replace(// 1. if there no pseudo use whole selector | ||
// 2. if there are pseudo replace prefix | ||
/^[^>:]+$|(>)?((?:[^:,]+(?::[\w-]+)?)|:[\w-]+)(::[\w-]+)?/g, (_, prefix = ' ', selector = _, pseudoElement = '')=>replace(`${prefix}:where(${selector}):not(:where(.${e(h('not-' + className))} *))${pseudoElement}`) | ||
); | ||
/^[^>:]+$|(>)?((?:[^:,]+(?::[\w-]+)?)|:[\w-]+)(::[\w-]+)?/g, (_, prefix = ' ', selector = _, pseudoElement = '')=>replace(`${prefix}:where(${selector}):not(:where(.${e(h('not-' + className))} *))${pseudoElement}`)); | ||
} | ||
@@ -550,0 +626,0 @@ function getFontSize(_) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
239986
2128
+ Added@swc/helpers@0.4.37(transitive)
+ Addedtwind@1.0.0-next.39(transitive)
- Removed@swc/helpers@0.3.17(transitive)
- Removedtwind@1.0.0-next.38(transitive)
Updated@swc/helpers@^0.4.11