@unocss/preset-typography 0.24.2 → 0.25.1

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.
package/dist/index.cjs CHANGED
@@ -6,17 +6,17 @@ const core = require('@unocss/core');
6
6
 
7
7
  const DEFAULT = {
8
8
  "h1,h2,h3,h4,h5,h6": {
9
- "color": "var(--uno-prose-headings)",
9
+ "color": "var(--un-prose-headings)",
10
10
  "font-weight": "600",
11
11
  "line-height": 1.25
12
12
  },
13
13
  "a": {
14
- "color": "var(--uno-prose-links)",
14
+ "color": "var(--un-prose-links)",
15
15
  "text-decoration": "underline",
16
16
  "font-weight": "500"
17
17
  },
18
18
  "a code": {
19
- color: "var(--uno-prose-links)"
19
+ color: "var(--un-prose-links)"
20
20
  },
21
21
  "p,ul,ol,pre": {
22
22
  "margin": "1em 0",
@@ -26,7 +26,7 @@ const DEFAULT = {
26
26
  "margin": "1em 0",
27
27
  "padding-left": "1em",
28
28
  "font-style": "italic",
29
- "border-left": ".25em solid var(--uno-prose-borders)"
29
+ "border-left": ".25em solid var(--un-prose-borders)"
30
30
  },
31
31
  "h1": {
32
32
  "margin": "1rem 0",
@@ -51,11 +51,11 @@ const DEFAULT = {
51
51
  margin: "1em 0"
52
52
  },
53
53
  "figcaption": {
54
- "color": "var(--uno-prose-captions)",
54
+ "color": "var(--un-prose-captions)",
55
55
  "font-size": ".875em"
56
56
  },
57
57
  "code": {
58
- "color": "var(--uno-prose-code)",
58
+ "color": "var(--un-prose-code)",
59
59
  "font-size": ".875em",
60
60
  "font-weight": 600,
61
61
  "font-family": "ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation-Mono,Courier-New,monospace"
@@ -91,11 +91,11 @@ const DEFAULT = {
91
91
  "list-style-type": "disc"
92
92
  },
93
93
  "ol > li::marker,ul > li::marker,summary::marker": {
94
- color: "var(--uno-prose-lists)"
94
+ color: "var(--un-prose-lists)"
95
95
  },
96
96
  "hr": {
97
97
  margin: "2em 0",
98
- border: "1px solid var(--uno-prose-hr)"
98
+ border: "1px solid var(--un-prose-hr)"
99
99
  },
100
100
  "table": {
101
101
  "display": "block",
@@ -104,17 +104,17 @@ const DEFAULT = {
104
104
  "overflow-x": "auto"
105
105
  },
106
106
  "tr:nth-child(2n)": {
107
- background: "var(--uno-prose-bg-soft)"
107
+ background: "var(--un-prose-bg-soft)"
108
108
  },
109
109
  "td,th": {
110
- border: "1px solid var(--uno-prose-borders)",
110
+ border: "1px solid var(--un-prose-borders)",
111
111
  padding: ".625em 1em"
112
112
  },
113
113
  "abbr": {
114
114
  cursor: "help"
115
115
  },
116
116
  "kbd": {
117
- "color": "var(--uno-prose-code)",
117
+ "color": "var(--un-prose-code)",
118
118
  "border": "1px solid",
119
119
  "padding": ".25rem .5rem",
120
120
  "font-size": ".875em",
@@ -123,7 +123,7 @@ const DEFAULT = {
123
123
  "details": {
124
124
  margin: "1em 0",
125
125
  padding: "1.25rem 1.5rem",
126
- background: "var(--uno-prose-bg-soft)"
126
+ background: "var(--un-prose-bg-soft)"
127
127
  },
128
128
  "summary": {
129
129
  "cursor": "pointer",
@@ -171,7 +171,7 @@ function presetTypography(options) {
171
171
  let selectorProse = "";
172
172
  const className = options?.className || "prose";
173
173
  const classNameRE = new RegExp(`^${className}$`);
174
- const colorsRE = new RegExp(`^${className}-(rose|pink|fuchsia|purple|violet|indigo|blue|sky|cyan|teal|emerald|green|lime|yellow|amber|orange|red|gray|slate|zinc|neutral|stone)$`);
174
+ const colorsRE = new RegExp(`^${className}-([-\\w]+)$`);
175
175
  const invertRE = new RegExp(`^${className}-invert$`);
176
176
  const cssExtend = options?.cssExtend;
177
177
  return {
@@ -184,32 +184,36 @@ function presetTypography(options) {
184
184
  (_, { rawSelector }) => {
185
185
  hasProseClass = true;
186
186
  selectorProse = rawSelector;
187
- return { "color": "var(--uno-prose-body)", "max-width": "65ch" };
187
+ return { "color": "var(--un-prose-body)", "max-width": "65ch" };
188
188
  },
189
189
  { layer: "typography" }
190
190
  ],
191
191
  [
192
192
  colorsRE,
193
193
  ([, color], { theme }) => {
194
+ const baseColor = theme.colors?.[color];
195
+ if (baseColor == null)
196
+ return;
197
+ const colorObject = typeof baseColor === "object" ? baseColor : {};
194
198
  return {
195
- "--uno-prose-body": theme.colors[color][700],
196
- "--uno-prose-headings": theme.colors[color][900],
197
- "--uno-prose-links": theme.colors[color][900],
198
- "--uno-prose-lists": theme.colors[color][400],
199
- "--uno-prose-hr": theme.colors[color][200],
200
- "--uno-prose-captions": theme.colors[color][500],
201
- "--uno-prose-code": theme.colors[color][900],
202
- "--uno-prose-borders": theme.colors[color][200],
203
- "--uno-prose-bg-soft": theme.colors[color][100],
204
- "--uno-prose-invert-body": theme.colors[color][200],
205
- "--uno-prose-invert-headings": theme.colors[color][100],
206
- "--uno-prose-invert-links": theme.colors[color][100],
207
- "--uno-prose-invert-lists": theme.colors[color][500],
208
- "--uno-prose-invert-hr": theme.colors[color][700],
209
- "--uno-prose-invert-captions": theme.colors[color][400],
210
- "--uno-prose-invert-code": theme.colors[color][100],
211
- "--uno-prose-invert-borders": theme.colors[color][700],
212
- "--uno-prose-invert-bg-soft": theme.colors[color][800]
199
+ "--un-prose-body": colorObject[700] ?? baseColor,
200
+ "--un-prose-headings": colorObject[900] ?? baseColor,
201
+ "--un-prose-links": colorObject[900] ?? baseColor,
202
+ "--un-prose-lists": colorObject[400] ?? baseColor,
203
+ "--un-prose-hr": colorObject[200] ?? baseColor,
204
+ "--un-prose-captions": colorObject[500] ?? baseColor,
205
+ "--un-prose-code": colorObject[900] ?? baseColor,
206
+ "--un-prose-borders": colorObject[200] ?? baseColor,
207
+ "--un-prose-bg-soft": colorObject[100] ?? baseColor,
208
+ "--un-prose-invert-body": colorObject[200] ?? baseColor,
209
+ "--un-prose-invert-headings": colorObject[100] ?? baseColor,
210
+ "--un-prose-invert-links": colorObject[100] ?? baseColor,
211
+ "--un-prose-invert-lists": colorObject[500] ?? baseColor,
212
+ "--un-prose-invert-hr": colorObject[700] ?? baseColor,
213
+ "--un-prose-invert-captions": colorObject[400] ?? baseColor,
214
+ "--un-prose-invert-code": colorObject[100] ?? baseColor,
215
+ "--un-prose-invert-borders": colorObject[700] ?? baseColor,
216
+ "--un-prose-invert-bg-soft": colorObject[800] ?? baseColor
213
217
  };
214
218
  },
215
219
  { layer: "typography" }
@@ -218,15 +222,15 @@ function presetTypography(options) {
218
222
  invertRE,
219
223
  () => {
220
224
  return {
221
- "--uno-prose-body": "var(--uno-prose-invert-body)",
222
- "--uno-prose-headings": "var(--uno-prose-invert-headings)",
223
- "--uno-prose-links": "var(--uno-prose-invert-links)",
224
- "--uno-prose-lists": "var(--uno-prose-invert-lists)",
225
- "--uno-prose-hr": "var(--uno-prose-invert-hr)",
226
- "--uno-prose-captions": "var(--uno-prose-invert-captions)",
227
- "--uno-prose-code": "var(--uno-prose-invert-code)",
228
- "--uno-prose-borders": "var(--uno-prose-invert-borders)",
229
- "--uno-prose-bg-soft": "var(--uno-prose-invert-bg-soft)"
225
+ "--un-prose-body": "var(--un-prose-invert-body)",
226
+ "--un-prose-headings": "var(--un-prose-invert-headings)",
227
+ "--un-prose-links": "var(--un-prose-invert-links)",
228
+ "--un-prose-lists": "var(--un-prose-invert-lists)",
229
+ "--un-prose-hr": "var(--un-prose-invert-hr)",
230
+ "--un-prose-captions": "var(--un-prose-invert-captions)",
231
+ "--un-prose-code": "var(--un-prose-invert-code)",
232
+ "--un-prose-borders": "var(--un-prose-invert-borders)",
233
+ "--un-prose-bg-soft": "var(--un-prose-invert-bg-soft)"
230
234
  };
231
235
  },
232
236
  { layer: "typography" }
@@ -241,4 +245,5 @@ function presetTypography(options) {
241
245
  };
242
246
  }
243
247
 
248
+ exports["default"] = presetTypography;
244
249
  exports.presetTypography = presetTypography;
package/dist/index.d.ts CHANGED
@@ -43,4 +43,4 @@ interface TypographyOptions {
43
43
  */
44
44
  declare function presetTypography(options?: TypographyOptions): Preset;
45
45
 
46
- export { TypographyOptions, presetTypography };
46
+ export { TypographyOptions, presetTypography as default, presetTypography };
package/dist/index.mjs CHANGED
@@ -2,17 +2,17 @@ import { mergeDeep } from '@unocss/core';
2
2
 
3
3
  const DEFAULT = {
4
4
  "h1,h2,h3,h4,h5,h6": {
5
- "color": "var(--uno-prose-headings)",
5
+ "color": "var(--un-prose-headings)",
6
6
  "font-weight": "600",
7
7
  "line-height": 1.25
8
8
  },
9
9
  "a": {
10
- "color": "var(--uno-prose-links)",
10
+ "color": "var(--un-prose-links)",
11
11
  "text-decoration": "underline",
12
12
  "font-weight": "500"
13
13
  },
14
14
  "a code": {
15
- color: "var(--uno-prose-links)"
15
+ color: "var(--un-prose-links)"
16
16
  },
17
17
  "p,ul,ol,pre": {
18
18
  "margin": "1em 0",
@@ -22,7 +22,7 @@ const DEFAULT = {
22
22
  "margin": "1em 0",
23
23
  "padding-left": "1em",
24
24
  "font-style": "italic",
25
- "border-left": ".25em solid var(--uno-prose-borders)"
25
+ "border-left": ".25em solid var(--un-prose-borders)"
26
26
  },
27
27
  "h1": {
28
28
  "margin": "1rem 0",
@@ -47,11 +47,11 @@ const DEFAULT = {
47
47
  margin: "1em 0"
48
48
  },
49
49
  "figcaption": {
50
- "color": "var(--uno-prose-captions)",
50
+ "color": "var(--un-prose-captions)",
51
51
  "font-size": ".875em"
52
52
  },
53
53
  "code": {
54
- "color": "var(--uno-prose-code)",
54
+ "color": "var(--un-prose-code)",
55
55
  "font-size": ".875em",
56
56
  "font-weight": 600,
57
57
  "font-family": "ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation-Mono,Courier-New,monospace"
@@ -87,11 +87,11 @@ const DEFAULT = {
87
87
  "list-style-type": "disc"
88
88
  },
89
89
  "ol > li::marker,ul > li::marker,summary::marker": {
90
- color: "var(--uno-prose-lists)"
90
+ color: "var(--un-prose-lists)"
91
91
  },
92
92
  "hr": {
93
93
  margin: "2em 0",
94
- border: "1px solid var(--uno-prose-hr)"
94
+ border: "1px solid var(--un-prose-hr)"
95
95
  },
96
96
  "table": {
97
97
  "display": "block",
@@ -100,17 +100,17 @@ const DEFAULT = {
100
100
  "overflow-x": "auto"
101
101
  },
102
102
  "tr:nth-child(2n)": {
103
- background: "var(--uno-prose-bg-soft)"
103
+ background: "var(--un-prose-bg-soft)"
104
104
  },
105
105
  "td,th": {
106
- border: "1px solid var(--uno-prose-borders)",
106
+ border: "1px solid var(--un-prose-borders)",
107
107
  padding: ".625em 1em"
108
108
  },
109
109
  "abbr": {
110
110
  cursor: "help"
111
111
  },
112
112
  "kbd": {
113
- "color": "var(--uno-prose-code)",
113
+ "color": "var(--un-prose-code)",
114
114
  "border": "1px solid",
115
115
  "padding": ".25rem .5rem",
116
116
  "font-size": ".875em",
@@ -119,7 +119,7 @@ const DEFAULT = {
119
119
  "details": {
120
120
  margin: "1em 0",
121
121
  padding: "1.25rem 1.5rem",
122
- background: "var(--uno-prose-bg-soft)"
122
+ background: "var(--un-prose-bg-soft)"
123
123
  },
124
124
  "summary": {
125
125
  "cursor": "pointer",
@@ -167,7 +167,7 @@ function presetTypography(options) {
167
167
  let selectorProse = "";
168
168
  const className = options?.className || "prose";
169
169
  const classNameRE = new RegExp(`^${className}$`);
170
- const colorsRE = new RegExp(`^${className}-(rose|pink|fuchsia|purple|violet|indigo|blue|sky|cyan|teal|emerald|green|lime|yellow|amber|orange|red|gray|slate|zinc|neutral|stone)$`);
170
+ const colorsRE = new RegExp(`^${className}-([-\\w]+)$`);
171
171
  const invertRE = new RegExp(`^${className}-invert$`);
172
172
  const cssExtend = options?.cssExtend;
173
173
  return {
@@ -180,32 +180,36 @@ function presetTypography(options) {
180
180
  (_, { rawSelector }) => {
181
181
  hasProseClass = true;
182
182
  selectorProse = rawSelector;
183
- return { "color": "var(--uno-prose-body)", "max-width": "65ch" };
183
+ return { "color": "var(--un-prose-body)", "max-width": "65ch" };
184
184
  },
185
185
  { layer: "typography" }
186
186
  ],
187
187
  [
188
188
  colorsRE,
189
189
  ([, color], { theme }) => {
190
+ const baseColor = theme.colors?.[color];
191
+ if (baseColor == null)
192
+ return;
193
+ const colorObject = typeof baseColor === "object" ? baseColor : {};
190
194
  return {
191
- "--uno-prose-body": theme.colors[color][700],
192
- "--uno-prose-headings": theme.colors[color][900],
193
- "--uno-prose-links": theme.colors[color][900],
194
- "--uno-prose-lists": theme.colors[color][400],
195
- "--uno-prose-hr": theme.colors[color][200],
196
- "--uno-prose-captions": theme.colors[color][500],
197
- "--uno-prose-code": theme.colors[color][900],
198
- "--uno-prose-borders": theme.colors[color][200],
199
- "--uno-prose-bg-soft": theme.colors[color][100],
200
- "--uno-prose-invert-body": theme.colors[color][200],
201
- "--uno-prose-invert-headings": theme.colors[color][100],
202
- "--uno-prose-invert-links": theme.colors[color][100],
203
- "--uno-prose-invert-lists": theme.colors[color][500],
204
- "--uno-prose-invert-hr": theme.colors[color][700],
205
- "--uno-prose-invert-captions": theme.colors[color][400],
206
- "--uno-prose-invert-code": theme.colors[color][100],
207
- "--uno-prose-invert-borders": theme.colors[color][700],
208
- "--uno-prose-invert-bg-soft": theme.colors[color][800]
195
+ "--un-prose-body": colorObject[700] ?? baseColor,
196
+ "--un-prose-headings": colorObject[900] ?? baseColor,
197
+ "--un-prose-links": colorObject[900] ?? baseColor,
198
+ "--un-prose-lists": colorObject[400] ?? baseColor,
199
+ "--un-prose-hr": colorObject[200] ?? baseColor,
200
+ "--un-prose-captions": colorObject[500] ?? baseColor,
201
+ "--un-prose-code": colorObject[900] ?? baseColor,
202
+ "--un-prose-borders": colorObject[200] ?? baseColor,
203
+ "--un-prose-bg-soft": colorObject[100] ?? baseColor,
204
+ "--un-prose-invert-body": colorObject[200] ?? baseColor,
205
+ "--un-prose-invert-headings": colorObject[100] ?? baseColor,
206
+ "--un-prose-invert-links": colorObject[100] ?? baseColor,
207
+ "--un-prose-invert-lists": colorObject[500] ?? baseColor,
208
+ "--un-prose-invert-hr": colorObject[700] ?? baseColor,
209
+ "--un-prose-invert-captions": colorObject[400] ?? baseColor,
210
+ "--un-prose-invert-code": colorObject[100] ?? baseColor,
211
+ "--un-prose-invert-borders": colorObject[700] ?? baseColor,
212
+ "--un-prose-invert-bg-soft": colorObject[800] ?? baseColor
209
213
  };
210
214
  },
211
215
  { layer: "typography" }
@@ -214,15 +218,15 @@ function presetTypography(options) {
214
218
  invertRE,
215
219
  () => {
216
220
  return {
217
- "--uno-prose-body": "var(--uno-prose-invert-body)",
218
- "--uno-prose-headings": "var(--uno-prose-invert-headings)",
219
- "--uno-prose-links": "var(--uno-prose-invert-links)",
220
- "--uno-prose-lists": "var(--uno-prose-invert-lists)",
221
- "--uno-prose-hr": "var(--uno-prose-invert-hr)",
222
- "--uno-prose-captions": "var(--uno-prose-invert-captions)",
223
- "--uno-prose-code": "var(--uno-prose-invert-code)",
224
- "--uno-prose-borders": "var(--uno-prose-invert-borders)",
225
- "--uno-prose-bg-soft": "var(--uno-prose-invert-bg-soft)"
221
+ "--un-prose-body": "var(--un-prose-invert-body)",
222
+ "--un-prose-headings": "var(--un-prose-invert-headings)",
223
+ "--un-prose-links": "var(--un-prose-invert-links)",
224
+ "--un-prose-lists": "var(--un-prose-invert-lists)",
225
+ "--un-prose-hr": "var(--un-prose-invert-hr)",
226
+ "--un-prose-captions": "var(--un-prose-invert-captions)",
227
+ "--un-prose-code": "var(--un-prose-invert-code)",
228
+ "--un-prose-borders": "var(--un-prose-invert-borders)",
229
+ "--un-prose-bg-soft": "var(--un-prose-invert-bg-soft)"
226
230
  };
227
231
  },
228
232
  { layer: "typography" }
@@ -237,4 +241,4 @@ function presetTypography(options) {
237
241
  };
238
242
  }
239
243
 
240
- export { presetTypography };
244
+ export { presetTypography as default, presetTypography };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-typography",
3
- "version": "0.24.2",
3
+ "version": "0.25.1",
4
4
  "description": "Typography preset for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -32,7 +32,7 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@unocss/core": "0.24.2"
35
+ "@unocss/core": "0.25.1"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "unbuild",