@unocss/preset-typography 65.4.2 → 65.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +37 -19
  2. package/package.json +5 -4
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { mergeDeep, definePreset, toEscapedSelector } from '@unocss/core';
2
+ import { alphaPlaceholders } from '@unocss/rule-utils';
2
3
 
3
4
  function DEFAULT(theme) {
4
5
  return {
@@ -271,27 +272,44 @@ const presetTypography = definePreset((options) => {
271
272
  if (baseColor == null)
272
273
  return;
273
274
  const colorObject = typeof baseColor === "object" ? baseColor : {};
274
- return {
275
- "--un-prose-body": colorObject[700] ?? baseColor,
276
- "--un-prose-headings": colorObject[900] ?? baseColor,
277
- "--un-prose-links": colorObject[900] ?? baseColor,
278
- "--un-prose-lists": colorObject[400] ?? baseColor,
279
- "--un-prose-hr": colorObject[200] ?? baseColor,
280
- "--un-prose-captions": colorObject[500] ?? baseColor,
281
- "--un-prose-code": colorObject[900] ?? baseColor,
282
- "--un-prose-borders": colorObject[200] ?? baseColor,
283
- "--un-prose-bg-soft": colorObject[100] ?? baseColor,
275
+ const TagColorMap = {
276
+ "body": 700,
277
+ "headings": 900,
278
+ "links": 900,
279
+ "lists": 400,
280
+ "hr": 200,
281
+ "captions": 500,
282
+ "code": 900,
283
+ "borders": 200,
284
+ "bg-soft": 100,
284
285
  // invert colors (dark mode)
285
- "--un-prose-invert-body": colorObject[200] ?? baseColor,
286
- "--un-prose-invert-headings": colorObject[100] ?? baseColor,
287
- "--un-prose-invert-links": colorObject[100] ?? baseColor,
288
- "--un-prose-invert-lists": colorObject[500] ?? baseColor,
289
- "--un-prose-invert-hr": colorObject[700] ?? baseColor,
290
- "--un-prose-invert-captions": colorObject[400] ?? baseColor,
291
- "--un-prose-invert-code": colorObject[100] ?? baseColor,
292
- "--un-prose-invert-borders": colorObject[700] ?? baseColor,
293
- "--un-prose-invert-bg-soft": colorObject[800] ?? baseColor
286
+ "invert-body": 200,
287
+ "invert-headings": 100,
288
+ "invert-links": 100,
289
+ "invert-lists": 500,
290
+ "invert-hr": 700,
291
+ "invert-captions": 400,
292
+ "invert-code": 100,
293
+ "invert-borders": 700,
294
+ "invert-bg-soft": 800
294
295
  };
296
+ const result = {};
297
+ for (const key in TagColorMap) {
298
+ const value = TagColorMap[key];
299
+ const color2 = colorObject[value] ?? baseColor;
300
+ let hasAlpha = false;
301
+ for (const placeholder of alphaPlaceholders) {
302
+ if (color2.includes(placeholder)) {
303
+ hasAlpha = true;
304
+ result[`--un-prose-${key}-opacity`] = 1;
305
+ result[`--un-prose-${key}`] = color2.replace(placeholder, `var(--un-prose-${key}-opacity)`);
306
+ break;
307
+ }
308
+ }
309
+ if (!hasAlpha)
310
+ result[`--un-prose-${key}`] = color2;
311
+ }
312
+ return result;
295
313
  },
296
314
  { layer: "typography" }
297
315
  ],
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@unocss/preset-typography",
3
3
  "type": "module",
4
- "version": "65.4.2",
4
+ "version": "65.5.0",
5
5
  "description": "Typography preset for UnoCSS",
6
6
  "author": "Jeff Yang",
7
7
  "license": "MIT",
8
8
  "homepage": "https://unocss.dev",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/unocss/unocss",
11
+ "url": "git+https://github.com/unocss/unocss",
12
12
  "directory": "packages-presets/preset-typography"
13
13
  },
14
14
  "bugs": {
@@ -32,8 +32,9 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@unocss/core": "65.4.2",
36
- "@unocss/preset-mini": "65.4.2"
35
+ "@unocss/rule-utils": "65.5.0",
36
+ "@unocss/core": "65.5.0",
37
+ "@unocss/preset-mini": "65.5.0"
37
38
  },
38
39
  "scripts": {
39
40
  "build": "unbuild",