docpensieve 0.1.2 → 0.1.4

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.
@@ -27,6 +27,8 @@ folder. Nothing can leave it: a page does not read the rest of the machine.
27
27
 
28
28
  Placed in a text, the icon takes its size and colour.
29
29
 
30
+ <ForTheme framework="tailwind">
31
+
30
32
  <div className="text-indigo-600 text-2xl">
31
33
  <LogoIcon src="./icons/star.svg" /> at the size and colour of the text
32
34
  </div>
@@ -35,38 +37,64 @@ Placed in a text, the icon takes its size and colour.
35
37
  <LogoIcon src="./icons/star.svg" /> and here, smaller and greyer
36
38
  </div>
37
39
 
40
+ </ForTheme>
41
+ <ForTheme framework="custom">
42
+
43
+ <div className="accent-text large">
44
+ <LogoIcon src="./icons/star.svg" /> at the size and colour of the text
45
+ </div>
46
+
47
+ <div className="small muted">
48
+ <LogoIcon src="./icons/star.svg" /> and here, smaller and greyer
49
+ </div>
50
+
51
+ </ForTheme>
52
+
38
53
  ## Sizes
39
54
 
40
55
  `size` accepts any CSS length.
41
56
 
42
- <div className="flex items-end gap-4 text-emerald-600">
57
+ <div style={{ display: 'flex', alignItems: 'flex-end', gap: '1rem', color: '#10b981' }}>
43
58
  <LogoIcon src="./icons/shield.svg" size="1rem" />
44
59
  <LogoIcon src="./icons/shield.svg" size="2rem" />
45
60
  <LogoIcon src="./icons/shield.svg" size="3rem" />
46
61
  <LogoIcon src="./icons/shield.svg" size="4rem" />
47
62
  </div>
48
63
 
64
+ <ForTheme framework="tailwind">
65
+
66
+ ```mdx
67
+ <LogoIcon src="./icons/shield.svg" size="3rem" style={{ color: '#10b981' }} />
68
+ ```
69
+
70
+ </ForTheme>
71
+ <ForTheme framework="custom">
72
+
49
73
  ```mdx
50
- <LogoIcon src="./icons/shield.svg" size="3rem" className="text-emerald-600" />
74
+ <LogoIcon src="./icons/shield.svg" size="3rem" className="green" />
51
75
  ```
52
76
 
77
+ `green` comes from `theme/99-docpensieve.css`, and sets `color`.
78
+
79
+ </ForTheme>
80
+
53
81
  The colour only follows if the file relies on `currentColor` rather than on a
54
82
  fixed colour.
55
83
 
56
84
  ## In a list
57
85
 
58
- <ul className="list-none pl-0 space-y-2">
59
- <li className="flex items-center gap-2">
60
- <LogoIcon src="./icons/lightning.svg" size="1.1rem" className="text-amber-500" /> No script to
86
+ <ul style={{ listStyle: 'none', paddingInlineStart: 0, display: 'grid', gap: '0.5rem' }}>
87
+ <li style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
88
+ <LogoIcon src="./icons/lightning.svg" size="1.1rem" style={{ color: '#f59e0b' }} /> No script to
61
89
  load
62
90
  </li>
63
- <li className="flex items-center gap-2">
64
- <LogoIcon src="./icons/shield.svg" size="1.1rem" className="text-emerald-600" /> Links are read
91
+ <li style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
92
+ <LogoIcon src="./icons/shield.svg" size="1.1rem" style={{ color: '#10b981' }} /> Links are read
65
93
  back before publishing
66
94
  </li>
67
- <li className="flex items-center gap-2">
68
- <LogoIcon src="./icons/book.svg" size="1.1rem" className="text-indigo-600" /> One version per
69
- branch
95
+ <li style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
96
+ <LogoIcon src="./icons/book.svg" size="1.1rem" style={{ color: 'var(--dp-accent)' }} /> One
97
+ version per branch
70
98
  </li>
71
99
  </ul>
72
100
 
@@ -74,10 +102,10 @@ fixed colour.
74
102
 
75
103
  <Columns>
76
104
  <Column span={6}>
77
- <Card className="h-full">
105
+ <Card style={{ height: '100%' }}>
78
106
  <CardBody>
79
- <LogoIcon src="./icons/lightning.svg" size="1.6rem" className="text-amber-500" />
80
- <strong className="block mt-2 mb-1 text-base font-semibold">Fast</strong>
107
+ <LogoIcon src="./icons/lightning.svg" size="1.6rem" style={{ color: '#f59e0b' }} />
108
+ <strong style={{ display: 'block', margin: '0.5rem 0 0.25rem', fontSize: '1rem' }}>Fast</strong>
81
109
 
82
110
  No hydration, no bundle to download before reading.
83
111
  </CardBody>
@@ -85,10 +113,10 @@ fixed colour.
85
113
 
86
114
  </Column>
87
115
  <Column span={6}>
88
- <Card className="h-full">
116
+ <Card style={{ height: '100%' }}>
89
117
  <CardBody>
90
- <LogoIcon src="./icons/shield.svg" size="1.6rem" className="text-emerald-600" />
91
- <strong className="block mt-2 mb-1 text-base font-semibold">Verified</strong>
118
+ <LogoIcon src="./icons/shield.svg" size="1.6rem" style={{ color: '#10b981' }} />
119
+ <strong style={{ display: 'block', margin: '0.5rem 0 0.25rem', fontSize: '1rem' }}>Verified</strong>
92
120
 
93
121
  Dead links and invalid markup stop the publication.
94
122
  </CardBody>
@@ -0,0 +1,45 @@
1
+ ---
2
+ title: ForTheme
3
+ description: Content kept for one theme only.
4
+ ---
5
+
6
+ # ForTheme
7
+
8
+ Keeps its content for the sites whose theme matches. The choice is made at
9
+ build time: the other variant does not even reach the HTML.
10
+
11
+ ```mdx
12
+ <ForTheme framework="tailwind">
13
+
14
+ With Tailwind, a utility: `className="max-w-sm"`.
15
+
16
+ </ForTheme>
17
+ <ForTheme framework="custom">
18
+
19
+ With the custom theme, a class of the `theme/` folder: `className="narrow"`.
20
+
21
+ </ForTheme>
22
+ ```
23
+
24
+ It is how the pages of this documentation show each example in the terms of
25
+ your theme. Changing `theme.framework` in the configuration changes what they
26
+ show, without editing them.
27
+
28
+ ## On this site
29
+
30
+ <ForTheme framework="tailwind">
31
+
32
+ This site is built with the **Tailwind** theme.
33
+
34
+ </ForTheme>
35
+ <ForTheme framework="custom">
36
+
37
+ This site is built with the **custom** theme.
38
+
39
+ </ForTheme>
40
+
41
+ ## What it refuses
42
+
43
+ A `framework` other than `tailwind` or `custom` stops the build, with the
44
+ accepted values: a typo would otherwise hide the content under every theme,
45
+ without a word.
@@ -8,7 +8,12 @@ description: The components available in every page, without an import.
8
8
  These components can be used in any `.mdx` page **without an import**.
9
9
 
10
10
  They provide the **structure** — wrappers, separators, spacing. The look is set
11
- with `className`, in utilities of the active theme:
11
+ with `className`.
12
+
13
+ <ForTheme framework="tailwind">
14
+
15
+ With the Tailwind theme, a `className` holds utilities, compiled from the ones
16
+ your pages use:
12
17
 
13
18
  ```mdx
14
19
  <Card className="max-w-sm">
@@ -19,6 +24,43 @@ with `className`, in utilities of the active theme:
19
24
  The component classes live in the `components` layer, below the utilities: a
20
25
  `className` set at use always wins.
21
26
 
27
+ </ForTheme>
28
+ <ForTheme framework="custom">
29
+
30
+ With the custom theme, a `className` names classes of your own: there are no
31
+ utilities. Every `.css` file of the `theme/` folder, at the root of the
32
+ project, is appended to the stylesheet, and `docpensieve dev` picks up every
33
+ change.
34
+
35
+ ```mdx
36
+ <Card className="narrow">
37
+ <CardHeader className="centered">Title</CardHeader>
38
+ </Card>
39
+ ```
40
+
41
+ ```css
42
+ /* theme/custom.css */
43
+ .narrow {
44
+ max-inline-size: 24rem;
45
+ }
46
+
47
+ .centered {
48
+ text-align: center;
49
+ }
50
+ ```
51
+
52
+ The component classes live in the `components` layer, those of the theme
53
+ folder in none: a class of yours always wins.
54
+
55
+ The examples of these pages use the classes of `theme/99-docpensieve.css`,
56
+ which `init` wrote next to this documentation: delete both together.
57
+
58
+ </ForTheme>
59
+
60
+ Every example is shown in the terms of the site's theme, through
61
+ [ForTheme](./for-theme/): changing `theme.framework` in the configuration
62
+ changes the examples too.
63
+
22
64
  ## Available
23
65
 
24
66
  - [Card](./card/) — card, with header, body, footer and image
@@ -29,6 +71,7 @@ The component classes live in the `components` layer, below the utilities: a
29
71
  - [ScrollToTop](./scroll-to-top/) — back to the top of the page
30
72
  - [Skill](./skill/) — level gauge
31
73
  - [LogoIcon](./logo-icon/) — SVG icon inlined in the page
74
+ - [ForTheme](./for-theme/) — content kept for one theme only
32
75
 
33
76
  ## Without JavaScript
34
77
 
@@ -35,11 +35,21 @@ npx docpensieve init [dir]
35
35
 
36
36
  Without `--force`, the command refuses to overwrite an existing configuration.
37
37
 
38
+ Without an interactive terminal — a script, continuous integration, or a
39
+ terminal that gives the programs it runs no interactive input — the command
40
+ asks nothing: it says so, then sticks to the options and the defaults. `--yes`
41
+ makes that choice explicit and silences the notice.
42
+
38
43
  Unless `--minimal` is given, the command installs DocPensieve's documentation
39
44
  in the new site, in `docs/<version>/99-docpensieve/`: a **DocPensieve** section
40
45
  at the end of the menu, matching the installed version. Delete that folder when
41
46
  you no longer need it.
42
47
 
48
+ Under the `custom` theme, the command also writes `theme/custom.css`, where the
49
+ project's own classes go, and — with the documentation —
50
+ `theme/99-docpensieve.css`, the classes of its examples, to delete along with
51
+ it. An existing `theme/custom.css` is never overwritten, even with `--force`.
52
+
43
53
  ## `build`
44
54
 
45
55
  Generates the site.
@@ -103,6 +103,11 @@ theme: {
103
103
 
104
104
  The available tokens are listed in [Themes](../guide/themes/).
105
105
 
106
+ Longer rules go in the `theme/` folder, at the root of the project: every
107
+ `.css` file in it is appended after `css`, in name order, and
108
+ `docpensieve dev` picks up every change. Under the `custom` theme, `init`
109
+ starts it with `theme/custom.css`.
110
+
106
111
  ## `baseUrl`, and why you rarely write it
107
112
 
108
113
  A `siteUrl` with a sub-path already gives it: `https://example.com/my-project`
@@ -124,7 +124,8 @@ The delivered stylesheet is assembled from four pieces, in this order:
124
124
  | a skin or a bridge | `custom.css`, or `tailwind-bridge.css` |
125
125
  | the components' one | The `dp-*` rules of the shipped components |
126
126
 
127
- Then comes what the project adds through `theme.css`.
127
+ Then comes what the project adds: `theme.css`, then every `.css` file of its
128
+ `theme/` folder, in name order.
128
129
 
129
130
  The layout is **never** duplicated in a provider: it lives in `structure.css`,
130
131
  which both share. A provider only takes care of the styling.
@@ -144,6 +145,6 @@ The `custom` theme has no utility layer: its stylesheets are in no layer, and
144
145
  therefore come before the component rules, which stay in the `components`
145
146
  layer.
146
147
 
147
- What `theme.css` adds is in no layer: without a layer, a rule wins over all
148
- those that have one. That is what lets you write a fix there without worrying
148
+ What `theme.css` and the `theme/` folder add is in no layer: without a layer, a
149
+ rule wins over all those that have one. That is what lets you write a fix there without worrying
149
150
  about specificity.
@@ -0,0 +1,156 @@
1
+ /*
2
+ * Classes of the documentation's examples, for the custom theme.
3
+ *
4
+ * The custom theme loads no utility framework: the classes a page uses are
5
+ * written by the project. These are the ones DocPensieve's own pages use.
6
+ * "docpensieve init" installs this file as theme/99-docpensieve.css, next to
7
+ * the documentation in 99-docpensieve/: delete both together.
8
+ *
9
+ * Every colour comes from the --dp-* tokens, or is mixed with them, so that
10
+ * the examples follow the light and dark palettes.
11
+ */
12
+
13
+ /* Sizes */
14
+
15
+ .narrow {
16
+ max-inline-size: 24rem;
17
+ }
18
+
19
+ .full-height {
20
+ block-size: 100%;
21
+ }
22
+
23
+ /* Text */
24
+
25
+ .centered {
26
+ text-align: center;
27
+ }
28
+
29
+ .small {
30
+ font-size: 0.875rem;
31
+ }
32
+
33
+ .large {
34
+ font-size: 1.5rem;
35
+ }
36
+
37
+ .caps {
38
+ text-transform: uppercase;
39
+ letter-spacing: 0.05em;
40
+ }
41
+
42
+ .italic {
43
+ font-style: italic;
44
+ }
45
+
46
+ .muted {
47
+ color: var(--dp-text-soft);
48
+ }
49
+
50
+ .accent-text {
51
+ color: var(--dp-accent);
52
+ }
53
+
54
+ .figure {
55
+ font-size: 2.25rem;
56
+ font-weight: 600;
57
+ line-height: 1.2;
58
+ color: var(--dp-accent);
59
+ }
60
+
61
+ .label {
62
+ display: block;
63
+ margin-block: 0.5rem 0.25rem;
64
+ font-size: 1rem;
65
+ font-weight: 600;
66
+ }
67
+
68
+ /* Colours, for the text and the gauges alike */
69
+
70
+ .green {
71
+ --dp-skill-color: #10b981;
72
+ color: #10b981;
73
+ }
74
+
75
+ .amber {
76
+ --dp-skill-color: #f59e0b;
77
+ color: #f59e0b;
78
+ }
79
+
80
+ /* Cards */
81
+
82
+ .highlight {
83
+ border-color: var(--dp-accent);
84
+ background: var(--dp-accent-soft);
85
+ }
86
+
87
+ .warning {
88
+ border-color: #f59e0b;
89
+ background: color-mix(in oklab, #f59e0b 12%, var(--dp-bg));
90
+ }
91
+
92
+ .warning-title {
93
+ color: color-mix(in oklab, #d97706 70%, var(--dp-text));
94
+ }
95
+
96
+ .plain {
97
+ border: 0;
98
+ box-shadow: none;
99
+ background: transparent;
100
+ }
101
+
102
+ .flush {
103
+ padding-inline: 0;
104
+ }
105
+
106
+ /* Layout */
107
+
108
+ .row {
109
+ display: flex;
110
+ flex-wrap: wrap;
111
+ align-items: center;
112
+ gap: 0.75rem;
113
+ }
114
+
115
+ .row.align-end {
116
+ align-items: flex-end;
117
+ }
118
+
119
+ .plain-list {
120
+ display: grid;
121
+ gap: 0.5rem;
122
+ padding-inline-start: 0;
123
+ list-style: none;
124
+ }
125
+
126
+ .wide-gap {
127
+ gap: 2.5rem;
128
+ }
129
+
130
+ /* Content that flows from one column to the next, as in a newspaper */
131
+
132
+ .flow {
133
+ columns: 2;
134
+ column-gap: 1.5rem;
135
+ }
136
+
137
+ @media (min-width: 40rem) {
138
+ .flow {
139
+ columns: 3;
140
+ }
141
+ }
142
+
143
+ .flow > * {
144
+ break-inside: avoid;
145
+ margin-block-end: 1.5rem;
146
+ }
147
+
148
+ /* A back-to-top button placed in the text rather than fixed on the screen */
149
+
150
+ .inline-button {
151
+ position: static;
152
+ display: inline-flex;
153
+ inline-size: auto;
154
+ box-shadow: none;
155
+ padding-inline: 1rem;
156
+ }
package/types/theme.d.ts CHANGED
@@ -4,14 +4,24 @@
4
4
  * @module docpensieve/theme
5
5
  */
6
6
  import { ThemeEngine } from '@docpensieve/theme';
7
+ /**
8
+ * Reads the project's own stylesheets: every `.css` file of its `theme/`
9
+ * folder, in name order. None when the folder does not exist.
10
+ *
11
+ * @param {string} [rootDir] Project root.
12
+ * @returns {string[]} The contents of each file.
13
+ */
14
+ export declare function projectCss(rootDir?: string): string[];
7
15
  /**
8
16
  * Mounts the ThemeEngine matching the declared framework.
9
17
  *
10
18
  * The CLI does this wiring: `core` deliberately ignores the `theme` package
11
19
  * and receives the engine by injection (ADR-002).
12
20
  *
13
- * Along the way, the class table is handed to the components: that is what
14
- * lets them ask for their class instead of hard-coding it (ADR-007).
21
+ * Along the way, the class table and the framework are handed to the
22
+ * components: that is what lets them ask for their class instead of
23
+ * hard-coding it (ADR-007), and lets `ForTheme` keep the variant of the active
24
+ * theme.
15
25
  *
16
26
  * @param {Record<string, any>} config Normalised configuration.
17
27
  * @param {string} [extraCss] CSS appended after the theme's — the look of the