@pikacss/plugin-typography 0.0.62 → 0.0.64
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/README.md +7 -3
- package/dist/index.d.mts +29 -25
- package/dist/index.mjs +38 -41
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,12 +10,16 @@ pnpm add -D @pikacss/plugin-typography
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
+
The example below assumes the application already uses `@pikacss/unplugin-pikacss`; Nuxt applications can import the same `defineConfig` surface from `@pikacss/nuxt-pikacss`.
|
|
14
|
+
|
|
13
15
|
```ts
|
|
14
|
-
import { defineEngineConfig } from '@pikacss/core'
|
|
15
16
|
import { typography } from '@pikacss/plugin-typography'
|
|
17
|
+
import { defineConfig } from '@pikacss/unplugin-pikacss'
|
|
16
18
|
|
|
17
|
-
export default
|
|
18
|
-
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
engine: {
|
|
21
|
+
plugins: [typography()],
|
|
22
|
+
},
|
|
19
23
|
})
|
|
20
24
|
```
|
|
21
25
|
|
package/dist/index.d.mts
CHANGED
|
@@ -12,32 +12,33 @@ import { EnginePlugin } from "@pikacss/core";
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```ts
|
|
15
|
-
*
|
|
15
|
+
* typography({ variables: {
|
|
16
16
|
* ...typographyVariables,
|
|
17
17
|
* '--pk-prose-color-links': '#3b82f6',
|
|
18
|
-
* })
|
|
18
|
+
* } })
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
declare const
|
|
22
|
-
'--pk-prose-color-body':
|
|
23
|
-
'--pk-prose-color-headings':
|
|
24
|
-
'--pk-prose-color-lead':
|
|
25
|
-
'--pk-prose-color-links':
|
|
26
|
-
'--pk-prose-color-bold':
|
|
27
|
-
'--pk-prose-color-counters':
|
|
28
|
-
'--pk-prose-color-bullets':
|
|
29
|
-
'--pk-prose-color-hr':
|
|
30
|
-
'--pk-prose-color-quotes':
|
|
31
|
-
'--pk-prose-color-quote-borders':
|
|
32
|
-
'--pk-prose-color-captions':
|
|
33
|
-
'--pk-prose-color-code':
|
|
34
|
-
'--pk-prose-color-pre-code':
|
|
35
|
-
'--pk-prose-color-pre-bg':
|
|
36
|
-
'--pk-prose-color-th-borders':
|
|
37
|
-
'--pk-prose-color-td-borders':
|
|
38
|
-
'--pk-prose-color-kbd':
|
|
39
|
-
'--pk-prose-kbd-shadows':
|
|
21
|
+
declare const typographyVariableDefaults: {
|
|
22
|
+
readonly '--pk-prose-color-body': "currentColor";
|
|
23
|
+
readonly '--pk-prose-color-headings': "currentColor";
|
|
24
|
+
readonly '--pk-prose-color-lead': "currentColor";
|
|
25
|
+
readonly '--pk-prose-color-links': "currentColor";
|
|
26
|
+
readonly '--pk-prose-color-bold': "currentColor";
|
|
27
|
+
readonly '--pk-prose-color-counters': "currentColor";
|
|
28
|
+
readonly '--pk-prose-color-bullets': "currentColor";
|
|
29
|
+
readonly '--pk-prose-color-hr': "currentColor";
|
|
30
|
+
readonly '--pk-prose-color-quotes': "currentColor";
|
|
31
|
+
readonly '--pk-prose-color-quote-borders': "currentColor";
|
|
32
|
+
readonly '--pk-prose-color-captions': "currentColor";
|
|
33
|
+
readonly '--pk-prose-color-code': "currentColor";
|
|
34
|
+
readonly '--pk-prose-color-pre-code': "currentColor";
|
|
35
|
+
readonly '--pk-prose-color-pre-bg': "transparent";
|
|
36
|
+
readonly '--pk-prose-color-th-borders': "currentColor";
|
|
37
|
+
readonly '--pk-prose-color-td-borders': "currentColor";
|
|
38
|
+
readonly '--pk-prose-color-kbd': "currentColor";
|
|
39
|
+
readonly '--pk-prose-kbd-shadows': "currentColor";
|
|
40
40
|
};
|
|
41
|
+
declare const typographyVariables: { [K in keyof typeof typographyVariableDefaults]: string };
|
|
41
42
|
//#endregion
|
|
42
43
|
//#region src/index.d.ts
|
|
43
44
|
/**
|
|
@@ -87,11 +88,14 @@ declare module '@pikacss/core' {
|
|
|
87
88
|
* @example
|
|
88
89
|
* ```ts
|
|
89
90
|
* import { typography } from '@pikacss/plugin-typography'
|
|
91
|
+
* import { defineConfig } from '@pikacss/unplugin-pikacss'
|
|
90
92
|
*
|
|
91
|
-
* export default
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
93
|
+
* export default defineConfig({
|
|
94
|
+
* engine: {
|
|
95
|
+
* plugins: [typography()],
|
|
96
|
+
* typography: {
|
|
97
|
+
* variables: { '--pk-prose-color-links': '#3b82f6' },
|
|
98
|
+
* },
|
|
95
99
|
* },
|
|
96
100
|
* })
|
|
97
101
|
* ```
|
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
1
|
import { defineEnginePlugin } from "@pikacss/core";
|
|
2
|
-
//#region src/styles.ts
|
|
3
|
-
/**
|
|
4
|
-
* Default CSS custom property values for prose typography colors and accents.
|
|
5
|
-
* @internal
|
|
6
|
-
*
|
|
7
|
-
* @remarks Each variable controls a specific color role within prose content
|
|
8
|
-
* (body text, headings, links, code, borders, etc.). All default to
|
|
9
|
-
* `currentColor` or `transparent`, allowing consumers to override them
|
|
10
|
-
* through the plugin's `variables` option.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* engine.variables.add({
|
|
15
|
-
* ...typographyVariables,
|
|
16
|
-
* '--pk-prose-color-links': '#3b82f6',
|
|
17
|
-
* })
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
2
|
const typographyVariables = {
|
|
21
3
|
"--pk-prose-color-body": "currentColor",
|
|
22
4
|
"--pk-prose-color-headings": "currentColor",
|
|
@@ -46,7 +28,7 @@ const typographyVariables = {
|
|
|
46
28
|
*
|
|
47
29
|
* @example
|
|
48
30
|
* ```ts
|
|
49
|
-
*
|
|
31
|
+
* typography() lowers `{ name: 'prose-base', value: proseBaseStyle }` into Core shortcut config.
|
|
50
32
|
* ```
|
|
51
33
|
*/
|
|
52
34
|
const proseBaseStyle = {
|
|
@@ -355,15 +337,25 @@ const proseSizeVariants = {
|
|
|
355
337
|
lineHeight: "1.66"
|
|
356
338
|
}
|
|
357
339
|
};
|
|
358
|
-
function
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
340
|
+
function createTypographyShortcuts() {
|
|
341
|
+
return [
|
|
342
|
+
{
|
|
343
|
+
name: "prose-base",
|
|
344
|
+
value: proseBaseStyle
|
|
345
|
+
},
|
|
346
|
+
...proseShortcutModules.map(([name, style]) => ({
|
|
347
|
+
name,
|
|
348
|
+
value: ["prose-base", style]
|
|
349
|
+
})),
|
|
350
|
+
{
|
|
351
|
+
name: "prose",
|
|
352
|
+
value: proseShortcutModules.map(([name]) => name)
|
|
353
|
+
},
|
|
354
|
+
...Object.entries(proseSizeVariants).map(([size, overrides]) => ({
|
|
355
|
+
name: `prose-${size}`,
|
|
356
|
+
value: ["prose", overrides]
|
|
357
|
+
}))
|
|
358
|
+
];
|
|
367
359
|
}
|
|
368
360
|
/**
|
|
369
361
|
* Creates the PikaCSS typography engine plugin.
|
|
@@ -379,11 +371,14 @@ function registerTypographyShortcuts(engine) {
|
|
|
379
371
|
* @example
|
|
380
372
|
* ```ts
|
|
381
373
|
* import { typography } from '@pikacss/plugin-typography'
|
|
374
|
+
* import { defineConfig } from '@pikacss/unplugin-pikacss'
|
|
382
375
|
*
|
|
383
|
-
* export default
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
376
|
+
* export default defineConfig({
|
|
377
|
+
* engine: {
|
|
378
|
+
* plugins: [typography()],
|
|
379
|
+
* typography: {
|
|
380
|
+
* variables: { '--pk-prose-color-links': '#3b82f6' },
|
|
381
|
+
* },
|
|
387
382
|
* },
|
|
388
383
|
* })
|
|
389
384
|
* ```
|
|
@@ -391,16 +386,18 @@ function registerTypographyShortcuts(engine) {
|
|
|
391
386
|
function typography() {
|
|
392
387
|
return defineEnginePlugin({
|
|
393
388
|
name: "typography",
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if (config.typography) context.state.typographyConfig = config.typography;
|
|
397
|
-
},
|
|
398
|
-
configureEngine: async (engine, context) => {
|
|
399
|
-
engine.variables.add({
|
|
389
|
+
configureRawConfig: (config) => {
|
|
390
|
+
const variableValues = {
|
|
400
391
|
...typographyVariables,
|
|
401
|
-
...
|
|
402
|
-
}
|
|
403
|
-
|
|
392
|
+
...config.typography?.variables
|
|
393
|
+
};
|
|
394
|
+
const loweredVariables = Object.fromEntries(Object.entries(variableValues).map(([name, value]) => [name, { value }]));
|
|
395
|
+
const existingVariables = config.variables?.definitions == null ? [] : [config.variables.definitions].flat();
|
|
396
|
+
config.variables = {
|
|
397
|
+
...config.variables,
|
|
398
|
+
definitions: [...existingVariables, loweredVariables]
|
|
399
|
+
};
|
|
400
|
+
config.shortcuts = { definitions: [...config.shortcuts?.definitions ?? [], ...createTypographyShortcuts()] };
|
|
404
401
|
}
|
|
405
402
|
});
|
|
406
403
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.64",
|
|
8
8
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"homepage": "https://pikacss.github.io",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"node": ">=22"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@pikacss/core": "0.0.
|
|
42
|
+
"@pikacss/core": "0.0.64"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@pikacss/core": "0.0.
|
|
45
|
+
"@pikacss/core": "0.0.64"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsdown",
|