@unocss/preset-typography 66.6.6 → 66.6.7
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.mjs +18 -23
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { clone, definePreset, mergeDeep, symbols, toArray } from "@unocss/core";
|
|
2
2
|
import { alphaPlaceholders, colorToString } from "@unocss/rule-utils";
|
|
3
|
-
|
|
4
3
|
//#region src/constants.ts
|
|
5
4
|
const modifiers = [
|
|
6
5
|
[
|
|
@@ -1015,7 +1014,6 @@ const ProseDefaultSize = {
|
|
|
1015
1014
|
"> :last-child": { "margin-bottom": "0" }
|
|
1016
1015
|
}
|
|
1017
1016
|
};
|
|
1018
|
-
|
|
1019
1017
|
//#endregion
|
|
1020
1018
|
//#region src/resolve.ts
|
|
1021
1019
|
function resolveColorScheme(userColorScheme) {
|
|
@@ -1049,7 +1047,6 @@ function getCSS(preflights, options) {
|
|
|
1049
1047
|
function getElements(modifier) {
|
|
1050
1048
|
for (const [name, ...selectors] of modifiers) if (name === modifier) return selectors.length > 0 ? selectors : [name];
|
|
1051
1049
|
}
|
|
1052
|
-
|
|
1053
1050
|
//#endregion
|
|
1054
1051
|
//#region src/index.ts
|
|
1055
1052
|
/**
|
|
@@ -1091,9 +1088,9 @@ const presetTypography = definePreset((options) => {
|
|
|
1091
1088
|
if (!options?.compatibility?.noColonIs) s = `:is(${s})`;
|
|
1092
1089
|
return s;
|
|
1093
1090
|
};
|
|
1094
|
-
const defaultRE =
|
|
1095
|
-
const colorsRE =
|
|
1096
|
-
const sizeRE =
|
|
1091
|
+
const defaultRE = new RegExp(`^${selectorName}-default$`);
|
|
1092
|
+
const colorsRE = new RegExp(`^${selectorName}-([-\\w]+)$`);
|
|
1093
|
+
const sizeRE = new RegExp(`^${selectorName}-(${Object.keys(resolvedSizeScheme).join("|")})$`);
|
|
1097
1094
|
return {
|
|
1098
1095
|
name: "@unocss/preset-typography",
|
|
1099
1096
|
enforce: "post",
|
|
@@ -1106,11 +1103,11 @@ const presetTypography = definePreset((options) => {
|
|
|
1106
1103
|
rules: [
|
|
1107
1104
|
[
|
|
1108
1105
|
defaultRE,
|
|
1109
|
-
(_, { symbols
|
|
1106
|
+
(_, { symbols, theme }) => {
|
|
1110
1107
|
const css = getCSS(extended(mergeDeep(ProseDefaultCSSObject, ProseDefaultSize.base), theme), options ?? {});
|
|
1111
1108
|
return {
|
|
1112
|
-
[symbols
|
|
1113
|
-
[symbols
|
|
1109
|
+
[symbols.body]: css,
|
|
1110
|
+
[symbols.selector]: normalizeSelector
|
|
1114
1111
|
};
|
|
1115
1112
|
},
|
|
1116
1113
|
{
|
|
@@ -1121,7 +1118,7 @@ const presetTypography = definePreset((options) => {
|
|
|
1121
1118
|
],
|
|
1122
1119
|
[
|
|
1123
1120
|
colorsRE,
|
|
1124
|
-
([, color], { theme, symbols
|
|
1121
|
+
([, color], { theme, symbols }) => {
|
|
1125
1122
|
const baseColor = theme.colors?.[color];
|
|
1126
1123
|
if (!baseColor || typeof baseColor !== "object") return;
|
|
1127
1124
|
if ([
|
|
@@ -1145,20 +1142,20 @@ const presetTypography = definePreset((options) => {
|
|
|
1145
1142
|
].includes(color)) return {
|
|
1146
1143
|
[`${cssVarPrefix}-links`]: baseColor["600"],
|
|
1147
1144
|
[`${cssVarPrefix}-invert-links`]: baseColor["500"],
|
|
1148
|
-
[symbols
|
|
1145
|
+
[symbols.selector]: normalizeSelector
|
|
1149
1146
|
};
|
|
1150
1147
|
else return Object.entries(resolvedColorScheme).reduce((acc, [key, value]) => {
|
|
1151
1148
|
const [colorKey, invertKey] = value;
|
|
1152
|
-
const resolve = (key
|
|
1153
|
-
const color
|
|
1149
|
+
const resolve = (key) => baseColor[key] ?? theme[key] ?? key;
|
|
1150
|
+
const color = resolve(colorKey);
|
|
1154
1151
|
const invertColor = resolve(invertKey);
|
|
1155
1152
|
const cssVarColorKey = `${cssVarPrefix}-${key}`;
|
|
1156
1153
|
const cssVarInvertColorKey = `${cssVarPrefix}-invert-${key}`;
|
|
1157
|
-
acc[cssVarColorKey] = colorToString(color
|
|
1154
|
+
acc[cssVarColorKey] = colorToString(color, `var(${cssVarColorKey}-opacity)`);
|
|
1158
1155
|
acc[cssVarInvertColorKey] = colorToString(invertColor, `var(${cssVarInvertColorKey}-opacity)`);
|
|
1159
|
-
for (const [c, k] of [[color
|
|
1156
|
+
for (const [c, k] of [[color, `${cssVarColorKey}-opacity`], [invertColor, `${cssVarInvertColorKey}-opacity`]]) if (alphaPlaceholders.some((p) => c.includes(p))) acc[k] = "1";
|
|
1160
1157
|
return acc;
|
|
1161
|
-
}, { [symbols
|
|
1158
|
+
}, { [symbols.selector]: normalizeSelector });
|
|
1162
1159
|
},
|
|
1163
1160
|
{
|
|
1164
1161
|
layer: "typography",
|
|
@@ -1167,11 +1164,11 @@ const presetTypography = definePreset((options) => {
|
|
|
1167
1164
|
],
|
|
1168
1165
|
[
|
|
1169
1166
|
sizeRE,
|
|
1170
|
-
([, size], { symbols
|
|
1167
|
+
([, size], { symbols, theme }) => {
|
|
1171
1168
|
const css = getCSS(extended(resolvedSizeScheme[size], theme), options ?? {});
|
|
1172
1169
|
return {
|
|
1173
|
-
[symbols
|
|
1174
|
-
[symbols
|
|
1170
|
+
[symbols.body]: css,
|
|
1171
|
+
[symbols.selector]: normalizeSelector
|
|
1175
1172
|
};
|
|
1176
1173
|
},
|
|
1177
1174
|
{
|
|
@@ -1209,7 +1206,7 @@ const presetTypography = definePreset((options) => {
|
|
|
1209
1206
|
name: "typography element modifiers",
|
|
1210
1207
|
match: (matcher) => {
|
|
1211
1208
|
if (matcher.startsWith(`${selectorName}-`)) {
|
|
1212
|
-
const modifyRe =
|
|
1209
|
+
const modifyRe = new RegExp(`^${selectorName}-(\\w+)[:-].+$`);
|
|
1213
1210
|
const modifier = matcher.match(modifyRe)?.[1];
|
|
1214
1211
|
if (modifier) {
|
|
1215
1212
|
const elements = getElements(modifier);
|
|
@@ -1227,7 +1224,5 @@ const presetTypography = definePreset((options) => {
|
|
|
1227
1224
|
}]
|
|
1228
1225
|
};
|
|
1229
1226
|
});
|
|
1230
|
-
var src_default = presetTypography;
|
|
1231
|
-
|
|
1232
1227
|
//#endregion
|
|
1233
|
-
export {
|
|
1228
|
+
export { presetTypography as default, presetTypography };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/preset-typography",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.6.
|
|
4
|
+
"version": "66.6.7",
|
|
5
5
|
"description": "Typography preset for UnoCSS",
|
|
6
6
|
"author": "Jeff Yang",
|
|
7
7
|
"license": "MIT",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@unocss/
|
|
32
|
-
"@unocss/
|
|
31
|
+
"@unocss/rule-utils": "66.6.7",
|
|
32
|
+
"@unocss/core": "66.6.7"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsdown",
|