@pikacss/plugin-typography 0.0.47 → 0.0.48

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 ADDED
@@ -0,0 +1,37 @@
1
+ # @pikacss/plugin-typography
2
+
3
+ Typography plugin for PikaCSS. Provides `prose` shortcuts for styling long-form content.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add -D @pikacss/plugin-typography
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { defineEngineConfig } from '@pikacss/core'
15
+ import { typography } from '@pikacss/plugin-typography'
16
+
17
+ export default defineEngineConfig({
18
+ plugins: [typography()],
19
+ })
20
+ ```
21
+
22
+ Then use in templates:
23
+
24
+ ```vue
25
+ <article :class="pika('prose')">
26
+ <h1>Title</h1>
27
+ <p>Content with beautiful typography.</p>
28
+ </article>
29
+ ```
30
+
31
+ ## Documentation
32
+
33
+ See the [full documentation](https://pikacss.com/guide/plugins/typography).
34
+
35
+ ## License
36
+
37
+ MIT
package/dist/index.d.mts CHANGED
@@ -1,6 +1,23 @@
1
1
  import { EnginePlugin } from "@pikacss/core";
2
2
 
3
3
  //#region src/styles.d.ts
4
+ /**
5
+ * Default CSS custom property values for prose typography colors and accents.
6
+ * @internal
7
+ *
8
+ * @remarks Each variable controls a specific color role within prose content
9
+ * (body text, headings, links, code, borders, etc.). All default to
10
+ * `currentColor` or `transparent`, allowing consumers to override them
11
+ * through the plugin's `variables` option.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * engine.variables.add({
16
+ * ...typographyVariables,
17
+ * '--pk-prose-color-links': '#3b82f6',
18
+ * })
19
+ * ```
20
+ */
4
21
  declare const typographyVariables: {
5
22
  '--pk-prose-color-body': string;
6
23
  '--pk-prose-color-headings': string;
@@ -23,17 +40,62 @@ declare const typographyVariables: {
23
40
  };
24
41
  //#endregion
25
42
  //#region src/index.d.ts
43
+ /**
44
+ * Configuration options for the typography plugin.
45
+ *
46
+ * @remarks Pass this object under the `typography` key in your engine config
47
+ * to customize prose color variables.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const config = {
52
+ * typography: {
53
+ * variables: { '--pk-prose-color-links': '#3b82f6' },
54
+ * },
55
+ * }
56
+ * ```
57
+ */
26
58
  interface TypographyPluginOptions {
27
59
  /**
28
- * Custom variables to override the default typography variables.
60
+ * Partial overrides for the default prose CSS custom properties.
61
+ *
62
+ * @default `{}`
29
63
  */
30
64
  variables?: Partial<typeof typographyVariables>;
31
65
  }
32
66
  declare module '@pikacss/core' {
33
67
  interface EngineConfig {
68
+ /**
69
+ * Typography plugin options forwarded from the engine config.
70
+ *
71
+ * @default `undefined`
72
+ */
34
73
  typography?: TypographyPluginOptions;
35
74
  }
36
75
  }
76
+ /**
77
+ * Creates the PikaCSS typography engine plugin.
78
+ *
79
+ * @returns An engine plugin that registers prose CSS variables and shortcut
80
+ * utilities (`prose`, `prose-sm`, `prose-lg`, `prose-xl`, `prose-2xl`).
81
+ *
82
+ * @remarks The plugin reads the `typography` key from the engine config,
83
+ * merges user-provided variable overrides with the defaults, and registers
84
+ * a full set of typography shortcuts covering paragraphs, links, headings,
85
+ * lists, code, tables, and more.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * import { typography } from '@pikacss/plugin-typography'
90
+ *
91
+ * export default defineEngineConfig({
92
+ * plugins: [typography()],
93
+ * typography: {
94
+ * variables: { '--pk-prose-color-links': '#3b82f6' },
95
+ * },
96
+ * })
97
+ * ```
98
+ */
37
99
  declare function typography(): EnginePlugin;
38
100
  //#endregion
39
101
  export { TypographyPluginOptions, typography };
package/dist/index.mjs CHANGED
@@ -1,6 +1,22 @@
1
1
  import { defineEnginePlugin, defineStyleDefinition } from "@pikacss/core";
2
-
3
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
+ */
4
20
  const typographyVariables = {
5
21
  "--pk-prose-color-body": "currentColor",
6
22
  "--pk-prose-color-headings": "currentColor",
@@ -21,6 +37,18 @@ const typographyVariables = {
21
37
  "--pk-prose-color-kbd": "currentColor",
22
38
  "--pk-prose-kbd-shadows": "currentColor"
23
39
  };
40
+ /**
41
+ * Base prose container styles that set color, max-width, font size, and line height.
42
+ * @internal
43
+ *
44
+ * @remarks Also collapses margins on the first and last child elements to
45
+ * prevent unwanted spacing at the edges of the prose container.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * engine.shortcuts.add(['prose-base', proseBaseStyle])
50
+ * ```
51
+ */
24
52
  const proseBaseStyle = defineStyleDefinition({
25
53
  "color": "var(--pk-prose-color-body)",
26
54
  "maxWidth": "65ch",
@@ -29,6 +57,18 @@ const proseBaseStyle = defineStyleDefinition({
29
57
  "$ > :first-child": { marginTop: "0" },
30
58
  "$ > :last-child": { marginBottom: "0" }
31
59
  });
60
+ /**
61
+ * Paragraph and lead-text styles for prose content.
62
+ * @internal
63
+ *
64
+ * @remarks Applies vertical margins to `<p>` elements and additional size,
65
+ * color, and spacing overrides for elements carrying the `lead` class.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * engine.shortcuts.add(['prose-paragraphs', ['prose-base', proseParagraphsStyle]])
70
+ * ```
71
+ */
32
72
  const proseParagraphsStyle = defineStyleDefinition({
33
73
  "$ p": {
34
74
  marginTop: "1.25em",
@@ -42,6 +82,18 @@ const proseParagraphsStyle = defineStyleDefinition({
42
82
  marginBottom: "1.2em"
43
83
  }
44
84
  });
85
+ /**
86
+ * Anchor link styles for prose content.
87
+ * @internal
88
+ *
89
+ * @remarks Sets link color, underline decoration, and medium font weight.
90
+ * Nested `<strong>` and `<code>` inside links inherit the link color.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * engine.shortcuts.add(['prose-links', ['prose-base', proseLinksStyle]])
95
+ * ```
96
+ */
45
97
  const proseLinksStyle = defineStyleDefinition({
46
98
  "$ a": {
47
99
  color: "var(--pk-prose-color-links)",
@@ -51,6 +103,19 @@ const proseLinksStyle = defineStyleDefinition({
51
103
  "$ a strong": { color: "inherit" },
52
104
  "$ a code": { color: "inherit" }
53
105
  });
106
+ /**
107
+ * Strong and italic emphasis styles for prose content.
108
+ * @internal
109
+ *
110
+ * @remarks Bold text receives a dedicated color variable and semi-bold weight.
111
+ * When `<strong>` appears inside links, blockquotes, or table headers the
112
+ * color inherits from the parent to avoid clashing with contextual colors.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * engine.shortcuts.add(['prose-emphasis', ['prose-base', proseEmphasisStyle]])
117
+ * ```
118
+ */
54
119
  const proseEmphasisStyle = defineStyleDefinition({
55
120
  "$ strong": {
56
121
  color: "var(--pk-prose-color-bold)",
@@ -61,6 +126,18 @@ const proseEmphasisStyle = defineStyleDefinition({
61
126
  "$ thead th strong": { color: "inherit" },
62
127
  "$ em": { fontStyle: "italic" }
63
128
  });
129
+ /**
130
+ * Keyboard input (`<kbd>`) styles for prose content.
131
+ * @internal
132
+ *
133
+ * @remarks Renders `<kbd>` elements with a subtle raised appearance using
134
+ * box-shadow borders. Color and shadow are driven by dedicated CSS variables.
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * engine.shortcuts.add(['prose-kbd', ['prose-base', proseKbdStyle]])
139
+ * ```
140
+ */
64
141
  const proseKbdStyle = defineStyleDefinition({ "$ kbd": {
65
142
  color: "var(--pk-prose-color-kbd)",
66
143
  fontSize: "0.875em",
@@ -73,6 +150,19 @@ const proseKbdStyle = defineStyleDefinition({ "$ kbd": {
73
150
  paddingLeft: "0.375em",
74
151
  boxShadow: "0 0 0 1px var(--pk-prose-kbd-shadows), 0 3px 0 var(--pk-prose-kbd-shadows)"
75
152
  } });
153
+ /**
154
+ * Ordered list, unordered list, and definition list styles for prose content.
155
+ * @internal
156
+ *
157
+ * @remarks Handles list markers (decimal, alpha, roman), nested list bullet
158
+ * progression (disc → circle → square), item spacing, and definition list
159
+ * (`<dl>`, `<dt>`, `<dd>`) layout.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * engine.shortcuts.add(['prose-lists', ['prose-base', proseListsStyle]])
164
+ * ```
165
+ */
76
166
  const proseListsStyle = defineStyleDefinition({
77
167
  "$ ol": {
78
168
  listStyleType: "decimal",
@@ -129,6 +219,19 @@ const proseListsStyle = defineStyleDefinition({
129
219
  paddingLeft: "1.625em"
130
220
  }
131
221
  });
222
+ /**
223
+ * Horizontal rule (`<hr>`) styles for prose content.
224
+ * @internal
225
+ *
226
+ * @remarks Applies generous vertical margins and a single-pixel top border
227
+ * colored by the `--pk-prose-color-hr` variable. The element immediately
228
+ * following an `<hr>` has its top margin collapsed.
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * engine.shortcuts.add(['prose-hr', ['prose-base', proseHrStyle]])
233
+ * ```
234
+ */
132
235
  const proseHrStyle = defineStyleDefinition({
133
236
  "$ hr": {
134
237
  borderColor: "var(--pk-prose-color-hr)",
@@ -138,6 +241,20 @@ const proseHrStyle = defineStyleDefinition({
138
241
  },
139
242
  "$ hr + *": { marginTop: "0" }
140
243
  });
244
+ /**
245
+ * Heading (h1–h4) styles for prose content.
246
+ * @internal
247
+ *
248
+ * @remarks Each heading level gets a distinct font size, weight, line height,
249
+ * and vertical margin. Nested `<strong>` receives a heavier weight and
250
+ * `<code>` inherits the heading color. Sibling elements after h2/h3/h4
251
+ * have their top margin collapsed.
252
+ *
253
+ * @example
254
+ * ```ts
255
+ * engine.shortcuts.add(['prose-headings', ['prose-base', proseHeadingsStyle]])
256
+ * ```
257
+ */
141
258
  const proseHeadingsStyle = defineStyleDefinition({
142
259
  "$ h1": {
143
260
  color: "var(--pk-prose-color-headings)",
@@ -182,6 +299,19 @@ const proseHeadingsStyle = defineStyleDefinition({
182
299
  "$ h4 code": { color: "inherit" },
183
300
  "$ h4 + *": { marginTop: "0" }
184
301
  });
302
+ /**
303
+ * Blockquote styles for prose content.
304
+ * @internal
305
+ *
306
+ * @remarks Renders blockquotes with italic text, a left border accent,
307
+ * and automatic open/close curly quotes via CSS `content`. Nested
308
+ * `<code>` inherits the quote color.
309
+ *
310
+ * @example
311
+ * ```ts
312
+ * engine.shortcuts.add(['prose-quotes', ['prose-base', proseQuotesStyle]])
313
+ * ```
314
+ */
185
315
  const proseQuotesStyle = defineStyleDefinition({
186
316
  "$ blockquote": {
187
317
  fontWeight: "500",
@@ -198,6 +328,19 @@ const proseQuotesStyle = defineStyleDefinition({
198
328
  "$ blockquote p:last-of-type::after": { content: "close-quote" },
199
329
  "$ blockquote code": { color: "inherit" }
200
330
  });
331
+ /**
332
+ * Image, video, picture, figure, and figcaption styles for prose content.
333
+ * @internal
334
+ *
335
+ * @remarks Applies consistent vertical margins to media elements and
336
+ * collapses inner margins within `<figure>`. Figcaptions receive a
337
+ * smaller font size and the captions color variable.
338
+ *
339
+ * @example
340
+ * ```ts
341
+ * engine.shortcuts.add(['prose-media', ['prose-base', proseMediaStyle]])
342
+ * ```
343
+ */
201
344
  const proseMediaStyle = defineStyleDefinition({
202
345
  "$ img": {
203
346
  marginTop: "2em",
@@ -227,6 +370,20 @@ const proseMediaStyle = defineStyleDefinition({
227
370
  marginTop: "0.85em"
228
371
  }
229
372
  });
373
+ /**
374
+ * Inline code and preformatted code block styles for prose content.
375
+ * @internal
376
+ *
377
+ * @remarks Inline `<code>` receives backtick-style pseudo-element wrappers
378
+ * and bold weight. `<pre>` blocks get background color, rounded corners,
379
+ * horizontal scroll, and padding. Code inside `<pre>` resets to inherit
380
+ * parent styles and removes the backtick wrappers.
381
+ *
382
+ * @example
383
+ * ```ts
384
+ * engine.shortcuts.add(['prose-code', ['prose-base', proseCodeStyle]])
385
+ * ```
386
+ */
230
387
  const proseCodeStyle = defineStyleDefinition({
231
388
  "$ code": {
232
389
  color: "var(--pk-prose-color-code)",
@@ -264,6 +421,20 @@ const proseCodeStyle = defineStyleDefinition({
264
421
  "$ pre code::before": { content: "none" },
265
422
  "$ pre code::after": { content: "none" }
266
423
  });
424
+ /**
425
+ * Table, thead, tbody, and tfoot styles for prose content.
426
+ * @internal
427
+ *
428
+ * @remarks Tables span the full width with auto layout. Header cells receive
429
+ * the headings color and bottom border; body rows get per-row bottom
430
+ * borders (removed on the last row). First and last cell padding is
431
+ * collapsed flush with the table edges.
432
+ *
433
+ * @example
434
+ * ```ts
435
+ * engine.shortcuts.add(['prose-tables', ['prose-base', proseTablesStyle]])
436
+ * ```
437
+ */
267
438
  const proseTablesStyle = defineStyleDefinition({
268
439
  "$ table": {
269
440
  width: "100%",
@@ -304,7 +475,6 @@ const proseTablesStyle = defineStyleDefinition({
304
475
  "$ tbody td:first-child, $ tfoot td:first-child": { paddingLeft: "0" },
305
476
  "$ tbody td:last-child, $ tfoot td:last-child": { paddingRight: "0" }
306
477
  });
307
-
308
478
  //#endregion
309
479
  //#region src/index.ts
310
480
  const proseShortcutModules = [
@@ -348,6 +518,29 @@ function registerTypographyShortcuts(engine) {
348
518
  engine.shortcuts.add([`prose-${size}`, ["prose", overrides]]);
349
519
  });
350
520
  }
521
+ /**
522
+ * Creates the PikaCSS typography engine plugin.
523
+ *
524
+ * @returns An engine plugin that registers prose CSS variables and shortcut
525
+ * utilities (`prose`, `prose-sm`, `prose-lg`, `prose-xl`, `prose-2xl`).
526
+ *
527
+ * @remarks The plugin reads the `typography` key from the engine config,
528
+ * merges user-provided variable overrides with the defaults, and registers
529
+ * a full set of typography shortcuts covering paragraphs, links, headings,
530
+ * lists, code, tables, and more.
531
+ *
532
+ * @example
533
+ * ```ts
534
+ * import { typography } from '@pikacss/plugin-typography'
535
+ *
536
+ * export default defineEngineConfig({
537
+ * plugins: [typography()],
538
+ * typography: {
539
+ * variables: { '--pk-prose-color-links': '#3b82f6' },
540
+ * },
541
+ * })
542
+ * ```
543
+ */
351
544
  function typography() {
352
545
  let typographyConfig = {};
353
546
  return defineEnginePlugin({
@@ -364,6 +557,5 @@ function typography() {
364
557
  }
365
558
  });
366
559
  }
367
-
368
560
  //#endregion
369
- export { typography };
561
+ export { typography };
package/package.json CHANGED
@@ -4,12 +4,13 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.0.47",
7
+ "version": "0.0.48",
8
8
  "author": "DevilTea <ch19980814@gmail.com>",
9
9
  "license": "MIT",
10
+ "homepage": "https://pikacss.com",
10
11
  "repository": {
11
12
  "type": "git",
12
- "url": "https://github.com/pikacss/pikacss.git",
13
+ "url": "git+https://github.com/pikacss/pikacss.git",
13
14
  "directory": "packages/plugin-typography"
14
15
  },
15
16
  "bugs": {
@@ -20,6 +21,7 @@
20
21
  "pikacss-plugin",
21
22
  "typography"
22
23
  ],
24
+ "sideEffects": false,
23
25
  "exports": {
24
26
  ".": {
25
27
  "import": {
@@ -33,19 +35,22 @@
33
35
  "files": [
34
36
  "dist"
35
37
  ],
38
+ "engines": {
39
+ "node": ">=22"
40
+ },
36
41
  "peerDependencies": {
37
- "@pikacss/core": "0.0.47"
42
+ "@pikacss/core": "0.0.48"
38
43
  },
39
44
  "devDependencies": {
40
- "@pikacss/core": "0.0.47"
45
+ "@pikacss/core": "0.0.48"
41
46
  },
42
47
  "scripts": {
43
48
  "build": "tsdown",
44
- "build:pack": "pnpm build && pnpm pack",
49
+ "build:watch": "tsdown --watch",
45
50
  "typecheck": "pnpm typecheck:package && pnpm typecheck:test",
46
51
  "typecheck:package": "tsc --project ./tsconfig.package.json --noEmit",
47
52
  "typecheck:test": "tsc --project ./tsconfig.tests.json --noEmit",
48
- "test": "vitest run",
49
- "test:watch": "vitest"
53
+ "test": "vitest run --config ./vitest.config.ts",
54
+ "test:watch": "vitest --config ./vitest.config.ts"
50
55
  }
51
56
  }