varvara-typedoc-theme 0.1.2 → 0.2.0

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 CHANGED
@@ -1,15 +1,16 @@
1
1
  # Varvara TypeDoc Theme
2
2
 
3
- Varvara TypeDoc Theme is a [custom theme](https://typedoc.org/documents/Development.Custom_Themes.html) for TypeDoc, designed to provide an seamless documentation experience for TypeScript projects.
3
+ _View a_ [_live example here_](https://marcmarine.github.io/western-signs).
4
4
 
5
- [![license](https://img.shields.io/github/license/marcmarine/varvara-js)](https://github.com/marcmarine/varvara-js/blob/main/LICENSE)
5
+ Varvara TypeDoc Theme is a custom theme for TypeDoc, designed to provide a seamless documentation experience for TypeScript projects.
6
6
 
7
- ## Prerequisites
8
-
9
- Ensure TypeDoc is [installed](https://typedoc.org/index.html#quick-start) in your project.
7
+ [![NPM Version](https://img.shields.io/npm/v/varvara-typedoc-theme)](https://www.npmjs.com/package/varvara-typedoc-theme)
8
+ [![GitHub License](https://img.shields.io/github/license/marcmarine/varvara-js)](https://github.com/marcmarine/varvara-js/blob/main/LICENSE)
10
9
 
11
10
  ## Installation
12
11
 
12
+ Ensure TypeDoc is [installed](https://typedoc.org/index.html#quick-start) in your project.
13
+
13
14
  Install the Varvara TypeDoc theme as a development dependency:
14
15
 
15
16
  ```bash
@@ -55,6 +56,53 @@ export default config
55
56
  > [!IMPORTANT]
56
57
  > The theme must be explicitly specified. If not set, the plugin will not be loaded by default.
57
58
 
59
+ ### Customization
60
+
61
+ Add custom styling by specifying an extra CSS file using the [customCss](https://typedoc.org/documents/Options.Output.html#customcss) option:
62
+
63
+ ```bash
64
+ npx typedoc --customCss ./styles/custom.css
65
+ ```
66
+
67
+ Varvara CSS provides variables to customize the theme appearance:
68
+
69
+ ```css
70
+ /* custom.css */
71
+
72
+ @media (prefers-color-scheme: light) {
73
+ :root {
74
+ --va-color-foreground: DimGray;
75
+ --va-color-background: WhiteSmoke;
76
+ --va-border-color: Gainsboro;
77
+ --va-space-ratio: 0.5;
78
+ }
79
+ }
80
+ @media (prefers-color-scheme: dark) {
81
+ :root {
82
+ --va-color-foreground: Silver;
83
+ --va-color-background: MidnightBlue;
84
+ --va-border-color: RoyalBlue;
85
+ --va-space-ratio: 0.5;
86
+ }
87
+ }
88
+
89
+ [data-theme='light'] {
90
+ --va-color-foreground: DimGray;
91
+ --va-color-background: WhiteSmoke;
92
+ --va-border-color: Gainsboro;
93
+ --va-space-ratio: 0.5;
94
+ }
95
+
96
+ [data-theme='dark'] {
97
+ --va-color-foreground: Silver;
98
+ --va-color-background: MidnightBlue;
99
+ --va-border-color: RoyalBlue;
100
+ --va-space-ratio: 0.5;
101
+ }
102
+ ```
103
+
104
+ See the [documentation](https://varvara.js.org/variables) for the complete list of available properties.
105
+
58
106
  ## Contributing
59
107
 
60
108
  Feel free to explore, test, and provide feedback. Your contribution is highly appreciated as we work towards improving and stabilizing the project.
@@ -1,22 +1,9 @@
1
- :root {
2
- --va-collapse-tree-indentation: var(--va-space-4);
3
- }
4
-
5
- html[data-theme='light'] {
6
- --va-color-foreground: #29353d;
7
- --va-color-background: #f3f5f7;
8
- --va-border-color: lightgray;
9
- }
10
- html[data-theme='dark'] {
11
- --va-color-foreground: #b3ccd6;
12
- --va-color-background: #2a303c;
13
- }
14
-
15
1
  @media (prefers-color-scheme: light) {
16
2
  :root {
17
3
  --va-color-foreground: #29353d;
18
4
  --va-color-background: #f3f5f7;
19
- --va-border-color: lightgray;
5
+ --va-border-color: LightGray;
6
+ --va-color-primary: RoyalBlue;
20
7
  }
21
8
  }
22
9
 
@@ -24,14 +11,34 @@ html[data-theme='dark'] {
24
11
  :root {
25
12
  --va-color-foreground: #b3ccd6;
26
13
  --va-color-background: #2a303c;
14
+ --va-border-color: LightSlateGray;
15
+ --va-color-primary: LightSkyBlue;
27
16
  }
28
17
  }
29
18
 
19
+ [data-theme='light'] {
20
+ --va-color-foreground: #29353d;
21
+ --va-color-background: #f3f5f7;
22
+ --va-border-color: LightGray;
23
+ --va-color-primary: RoyalBlue;
24
+ }
25
+
26
+ [data-theme='dark'] {
27
+ --va-color-foreground: #b3ccd6;
28
+ --va-color-background: #2a303c;
29
+ --va-border-color: LightSlateGray;
30
+ --va-color-primary: LightSkyBlue;
31
+ }
32
+
30
33
  body {
31
34
  background-color: var(--va-color-background);
32
35
  color: var(--va-color-foreground);
33
36
  }
34
37
 
38
+ a {
39
+ color: var(--va-color-primary);
40
+ }
41
+
35
42
  .va-button:has(.version-badge) {
36
43
  position: relative;
37
44
  }
@@ -162,7 +169,7 @@ footer {
162
169
  }
163
170
 
164
171
  .container {
165
- padding: 0 1.5rem;
172
+ padding: 0 var(--va-space-8);
166
173
  }
167
174
 
168
175
  @media (max-width: 769px) {
@@ -187,9 +194,10 @@ footer {
187
194
  .container-main {
188
195
  grid-template-areas: 'header content' 'sidebar content';
189
196
  grid-auto-rows: auto 1fr;
197
+ margin: var(--va-space-8) 0;
190
198
  }
191
199
  .container {
192
- padding: 0 2rem;
200
+ padding: 0 var(--va-space-8);
193
201
  }
194
202
  }
195
203
 
@@ -202,8 +210,8 @@ footer {
202
210
  }
203
211
  .page-menu,
204
212
  .site-menu {
205
- top: 2rem;
206
- max-height: calc(100vh - 4rem);
213
+ top: var(--va-space-8);
214
+ max-height: calc(100vh - calc(var(--va-space-8) * 2));
207
215
  }
208
216
  }
209
217
 
package/dist/index.js CHANGED
@@ -89,21 +89,28 @@ function sidebar(context) {
89
89
  };
90
90
  }
91
91
 
92
- // src/partials/pageSidebar.tsx
92
+ // src/partials/navigation.tsx
93
93
  import {
94
94
  JSX as JSX3,
95
95
  ReflectionFlag
96
96
  } from "typedoc";
97
97
  function pageSidebar(context) {
98
98
  return (props) => {
99
+ return /* @__PURE__ */ JSX3.createElement("div", {
100
+ class: "va-button-group"
101
+ }, context.settings(), context.pageNavigation(props));
102
+ };
103
+ }
104
+ var flagOptionNameToReflectionFlag = {
105
+ protected: ReflectionFlag.Protected,
106
+ private: ReflectionFlag.Private,
107
+ external: ReflectionFlag.External,
108
+ inherited: ReflectionFlag.Inherited
109
+ };
110
+ function settings(context) {
111
+ return () => {
99
112
  const defaultFilters = context.options.getValue("visibilityFilters");
100
113
  const visibilityOptions = [];
101
- const flagOptionNameToReflectionFlag = {
102
- protected: ReflectionFlag.Protected,
103
- private: ReflectionFlag.Private,
104
- external: ReflectionFlag.External,
105
- inherited: ReflectionFlag.Inherited
106
- };
107
114
  for (const key of Object.keys(defaultFilters)) {
108
115
  if (key.startsWith("@")) {
109
116
  const filterName = key.substring(1).replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
@@ -112,25 +119,7 @@ function pageSidebar(context) {
112
119
  visibilityOptions.push(buildFilterItem(context, key, context.internationalization.flagString(flagOptionNameToReflectionFlag[key]), defaultFilters[key]));
113
120
  }
114
121
  }
115
- if (!props.pageSections.some((sect) => sect.headings.length)) {
116
- return /* @__PURE__ */ JSX3.createElement(JSX3.Fragment, null);
117
- }
118
- const sections = [];
119
- for (const section of props.pageSections) {
120
- if (section.title) {
121
- sections.push(/* @__PURE__ */ JSX3.createElement("details", {
122
- open: true,
123
- class: "va-collapse tsd-accordion"
124
- }, /* @__PURE__ */ JSX3.createElement("summary", {
125
- "data-key": `section-${section.title}`
126
- }, section.title), buildSectionNavigation(context, section.headings)));
127
- } else {
128
- sections.push(buildSectionNavigation(context, section.headings));
129
- }
130
- }
131
- return /* @__PURE__ */ JSX3.createElement("div", {
132
- class: "va-button-group"
133
- }, /* @__PURE__ */ JSX3.createElement("details", {
122
+ return /* @__PURE__ */ JSX3.createElement("details", {
134
123
  class: "va-collapse settings tsd-accordion",
135
124
  open: false
136
125
  }, /* @__PURE__ */ JSX3.createElement("summary", null, context.i18n.theme_settings()), visibilityOptions.length && /* @__PURE__ */ JSX3.createElement("div", {
@@ -150,10 +139,7 @@ function pageSidebar(context) {
150
139
  value: "light"
151
140
  }, context.i18n.theme_light()), /* @__PURE__ */ JSX3.createElement("option", {
152
141
  value: "dark"
153
- }, context.i18n.theme_dark())))), /* @__PURE__ */ JSX3.createElement("details", {
154
- open: false,
155
- class: "va-collapse page-navigation tsd-accordion"
156
- }, /* @__PURE__ */ JSX3.createElement("summary", null, context.i18n.theme_on_this_page()), sections));
142
+ }, context.i18n.theme_dark()))));
157
143
  };
158
144
  }
159
145
  function buildSectionNavigation(context, headings) {
@@ -201,6 +187,30 @@ function buildFilterItem(context, name, displayName, defaultValue) {
201
187
  checked: defaultValue
202
188
  }), context.icons.checkbox(), /* @__PURE__ */ JSX3.createElement("span", null, displayName)));
203
189
  }
190
+ function pageNavigation(context) {
191
+ return (props) => {
192
+ if (!props.pageSections.some((sect) => sect.headings.length)) {
193
+ return /* @__PURE__ */ JSX3.createElement(JSX3.Fragment, null);
194
+ }
195
+ const sections = [];
196
+ for (const section of props.pageSections) {
197
+ if (section.title) {
198
+ sections.push(/* @__PURE__ */ JSX3.createElement("details", {
199
+ open: true,
200
+ class: "va-collapse tsd-accordion"
201
+ }, /* @__PURE__ */ JSX3.createElement("summary", {
202
+ "data-key": `section-${section.title}`
203
+ }, section.title), buildSectionNavigation(context, section.headings)));
204
+ } else {
205
+ sections.push(buildSectionNavigation(context, section.headings));
206
+ }
207
+ }
208
+ return /* @__PURE__ */ JSX3.createElement("details", {
209
+ open: false,
210
+ class: "va-collapse page-navigation tsd-accordion"
211
+ }, /* @__PURE__ */ JSX3.createElement("summary", null, context.i18n.theme_on_this_page()), sections);
212
+ };
213
+ }
204
214
 
205
215
  // src/partials/toolbar.tsx
206
216
  import {
@@ -332,15 +342,9 @@ function layout(context) {
332
342
  }), /* @__PURE__ */ JSX5.createElement("link", {
333
343
  rel: "stylesheet",
334
344
  href: context.relativeURL("assets/highlight.css", true)
335
- }), context.options.getValue("customCss") && /* @__PURE__ */ JSX5.createElement("link", {
336
- rel: "stylesheet",
337
- href: context.relativeURL("assets/custom.css", true)
338
345
  }), /* @__PURE__ */ JSX5.createElement("script", {
339
346
  defer: true,
340
347
  src: context.relativeURL("assets/main.js", true)
341
- }), context.options.getValue("customJs") && /* @__PURE__ */ JSX5.createElement("script", {
342
- defer: true,
343
- src: context.relativeURL("assets/custom.js", true)
344
348
  }), /* @__PURE__ */ JSX5.createElement("script", {
345
349
  async: true,
346
350
  src: context.relativeURL("assets/icons.js", true),
@@ -357,7 +361,13 @@ function layout(context) {
357
361
  async: true,
358
362
  src: context.relativeURL("assets/hierarchy.js", true),
359
363
  id: "tsd-hierarchy-script"
360
- }), context.hook("head.end", context)), /* @__PURE__ */ JSX5.createElement("body", null, context.hook("body.begin", context), /* @__PURE__ */ JSX5.createElement("script", null, /* @__PURE__ */ JSX5.createElement(JSX5.Raw, {
364
+ }), context.hook("head.end", context), context.options.getValue("customCss") && /* @__PURE__ */ JSX5.createElement("link", {
365
+ rel: "stylesheet",
366
+ href: context.relativeURL("assets/custom.css", true)
367
+ }), context.options.getValue("customJs") && /* @__PURE__ */ JSX5.createElement("script", {
368
+ defer: true,
369
+ src: context.relativeURL("assets/custom.js", true)
370
+ })), /* @__PURE__ */ JSX5.createElement("body", null, context.hook("body.begin", context), /* @__PURE__ */ JSX5.createElement("script", null, /* @__PURE__ */ JSX5.createElement(JSX5.Raw, {
361
371
  html: 'document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";'
362
372
  })), /* @__PURE__ */ JSX5.createElement("div", {
363
373
  class: "container container-main"
@@ -428,6 +438,8 @@ class VarvaraThemeContext extends DefaultThemeRenderContext3 {
428
438
  this.toolbar = toolbar(this);
429
439
  this.defaultLayout = layout(this);
430
440
  this.sidebar = sidebar(this);
441
+ this.settings = settings(this);
442
+ this.pageNavigation = pageNavigation(this);
431
443
  }
432
444
  footer = () => footer(this);
433
445
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "varvara-typedoc-theme",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "author": "Marc Mariné <shenobi@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",